実現したいこと
・Laravelでvoicevoxを使用して音声ファイルを作成したい
前提
dockerで環境構築し
Lravelでvoicevoxを使用して音声ファイルを作成するアプリを作成しています。
テキストを書いたcsvファイルをアップロードすると書いたテキストが音声に変換される仕組みです。
アップしたcsvファイルはvoicevoxAPIで処理され音声ファイルを作成してくれます
発生している問題・エラーメッセージ
voicevoxにリクエストを送信した際以下のエラーが、
500 Inrernal server Error
voicevox-voicevox_engine-1 | INFO: 192.168.65.1:39964 - "POST /audio_query?text=%E3%81%82%E3%81%84%E3%81%86%E3%81%88%E3%81%8A%E3%81%8B%E3%81%8D%E3%81%8F%E3%81%91%E3%81%93&style_id=1 HTTP/1.1" 500 Internal Server Error voicevox-voicevox_engine-1 | ERROR: Exception in ASGI application voicevox-voicevox_engine-1 | Traceback (most recent call last): voicevox-voicevox_engine-1 | File "/home/user/.local/lib/python3.11/site-packages/anyio/streams/memory.py", line 98, in receive voicevox-voicevox_engine-1 | return self.receive_nowait() voicevox-voicevox_engine-1 | ^^^^^^^^^^^^^^^^^^^^^ voicevox-voicevox_engine-1 | File "/home/user/.local/lib/python3.11/site-packages/anyio/streams/memory.py", line 93, in receive_nowait voicevox-voicevox_engine-1 | raise WouldBlock voicevox-voicevox_engine-1 | anyio.WouldBlock voicevox-voicevox_engine-1 | voicevox-voicevox_engine-1 | During handling of the above exception, another exception occurred: voicevox-voicevox_engine-1 | voicevox-voicevox_engine-1 | Traceback (most recent call last): voicevox-voicevox_engine-1 | File "/home/user/.local/lib/python3.11/site-packages/starlette/middleware/base.py", line 78, in call_next voicevox-voicevox_engine-1 | message = await recv_stream.receive() voicevox-voicevox_engine-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ voicevox-voicevox_engine-1 | File "/home/user/.local/lib/python3.11/site-packages/anyio/streams/memory.py", line 118, in receive voicevox-voicevox_engine-1 | raise EndOfStream voicevox-voicevox_engine-1 | anyio.EndOfStream voicevox-voicevox_engine-1 | voicevox-voicevox_engine-1 | During handling of the above exception, another exception occurred: voicevox-voicevox_engine-1 | voicevox-voicevox_engine-1 | Traceback (most recent call last): voicevox-voicevox_engine-1 | File "/home/user/.local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi // 途中長いので省略// voicevox-voicevox_engine-1 | self.core.load_model(style_id) voicevox-voicevox_engine-1 | File "/opt/voicevox_engine/voicevox_engine/synthesis_engine/core_wrapper.py", line 526, in load_model voicevox-voicevox_engine-1 | self.assert_core_success(self.core.load_model(c_long(style_id))) voicevox-voicevox_engine-1 | File "/opt/voicevox_engine/voicevox_engine/synthesis_engine/core_wrapper.py", line 536, in assert_core_success voicevox-voicevox_engine-1 | raise CoreError( voicevox-voicevox_engine-1 | voicevox_engine.synthesis_engine.core_wrapper.CoreError: modelデータ読み込みに失敗しました (/opt/voicevox_core/model/d0.bin): Failed to create session: Error calling ONNX Runtime C function: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:124 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, ERRTYPE, const char*) [with ERRTYPE = cudaError; bool THRW = true; std::conditional_t<THRW, void, onnxruntime::common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:117 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, ERRTYPE, const char*) [with ERRTYPE = cudaError; bool THRW = true; std::conditional_t<THRW, void, onnxruntime::common::Status> = void] CUDA failure 35: CUDA driver version is insufficient for CUDA runtime version ; GPU=0 ; hostname=ba2923d24720 ; expr=cudaSetDevice(info_.device_id); voicevox-voicevox_engine-1 | voicevox-voicevox_engine-1 |
何やら、pythonのエラーらしいのはわかるのですがいかんせんpythonの知識も皆無なので困っております。
該当のソースコード
php
1<?php 2 3namespace App\Http\Livewire\App\Pages; 4 5use Illuminate\Support\Facades\Http; 6use Illuminate\Support\Facades\Storage; 7use Livewire\WithFileUploads; 8 9class HomePage extends AppBasePage 10{ 11 use WithFileUploads; 12 13 public $file; 14 15 protected $listeners = ['refreshComponent' => '$refresh']; 16 17 public function render() 18 { 19 return view('livewire.app.pages.home'); 20 } 21 22 public function handleUpload() 23 { 24 $this->validate([ 25 'file' => 'required|mimes:csv,txt', 26 ]); 27 28 $csvPath = $this->file->storeAs('public/csv', $this->file->getClientOriginalName()); 29 30 // CSV解析 31 $csvPath = Storage::disk('local')->path($csvPath); 32 $csvName = pathinfo($csvPath, PATHINFO_FILENAME); 33 34 $texts = collect(array_map('str_getcsv', file($csvPath)))->map(function ($text) { 35 if ($text[0] === '') return true; 36 return $text[0]; 37 }); 38 39 // ディレクトリ作成 40 Storage::makeDirectory($csvName); 41 42 $isSuccess = true; 43 44 $texts->each(function ($text) use($texts, $csvName, &$isSuccess) { 45 $apiAudioQueryUrl = env("VOICEVOX_API_ENDPOINT") . "/audio_query?text={$text}&speaker=" . env('VOICEVOX_SPEAKER_ID'); 46 $apiSynthesisUrl = env("VOICEVOX_API_ENDPOINT") . "/synthesis?speaker=" . env("VOICEVOX_SPEAKER_ID"); 47 48 // 音声合成用のクエリを作成する 49 $audioQueryRes = Http::retry(3, 1000)->post($apiAudioQueryUrl); //ポイント 50 51 if ($audioQueryRes->failed()) { 52 $isSuccess = false; 53 throw new \Exception("音声合成用のクエリの作成に失敗しました。"); 54 } 55 56 // wavの作成音声合成を行う 57 $synthesisRes = Http::post($apiSynthesisUrl, $audioQueryRes->json()); 58 $wav = trim(mb_substr($text, 0, 20)) . ".wav"; 59 60 if ($synthesisRes->failed()) { 61 $isSuccess = false; 62 throw new \Exception("wavファイルの作成に失敗しました。"); 63 } 64 65 Storage::put("public/audio/{$csvName}/$wav", $synthesisRes->body()); 66 }); 67 68 if ($isSuccess) { 69 return to_route("home", []) 70 ->with("message", "音声ファイルを作成しました。"); 71 } 72 return to_route("home", []) 73 ->with("message", "音声ファイルに失敗しました。"); 74 } 75} 76
docker
1version: '3' 2services: 3 laravel.test: 4 build: 5 context: ./docker/8.2 6 dockerfile: Dockerfile 7 args: 8 WWWGROUP: '${WWWGROUP}' 9 image: sail-8.2/app 10 extra_hosts: 11 - 'host.docker.internal:host-gateway' 12 ports: 13 - '${APP_PORT:-80}:80' 14 - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' 15 environment: 16 WWWUSER: '${WWWUSER}' 17 LARAVEL_SAIL: 1 18 XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' 19 XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' 20 volumes: 21 - '.:/var/www/html' 22 networks: 23 - sail 24 depends_on: 25 - mysql 26 - mailpit 27 mysql: 28 image: 'mysql/mysql-server:8.0' 29 platform: linux/x86_64 30 ports: 31 - '${FORWARD_DB_PORT:-3306}:3306' 32 environment: 33 MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' 34 MYSQL_ROOT_HOST: '%' 35 MYSQL_DATABASE: '${DB_DATABASE}' 36 MYSQL_USER: '${DB_USERNAME}' 37 MYSQL_PASSWORD: '${DB_PASSWORD}' 38 MYSQL_ALLOW_EMPTY_PASSWORD: 1 39 volumes: 40 - 'sail-mysql:/var/lib/mysql' 41 - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' 42 networks: 43 - sail 44 healthcheck: 45 test: 46 - CMD 47 - mysqladmin 48 - ping 49 - '-p${DB_PASSWORD}' 50 retries: 3 51 timeout: 5s 52 mailpit: 53 image: 'axllent/mailpit:latest' 54 ports: 55 - '${FORWARD_MAILPIT_PORT:-1025}:1025' 56 - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' 57 networks: 58 - sail 59 voicevox_engine: 60 image: voicevox/voicevox_engine:nvidia-ubuntu20.04-latest 61 ports: 62 - "50021:50021" 63 tty: true 64networks: 65 sail: 66 driver: bridge 67volumes: 68 sail-mysql: 69 driver: local 70
補足
docker-contenerを立ち上げ、http://localhost:50021/docsにアクセスするとvoicevox GUIには繋がります。
補足情報(FW/ツールのバージョンなど)
Mac Os M1 Sonoma v 14.1
Docker Desktop v4.25.0
laravel v10
症状
ポイントとしては、
$audioQueryRes = Http::retry(3, 1000)->post($apiAudioQueryUrl);
ここでpostが失敗しています。一度、$apiAudioQueryUrlの部分を''http://192.168.11.9:50021/audio_query?text=あいうえお&speaker=1"
と直いれで検証。
結果、やはり500 エラー。試しに
'http://192.168.11.9:50021/audio_query?text=&speaker=1'
テキストなしバージョンをpost
結果 200 ステータスコードで成功。
なぜ? テキストを入れてはダメなのか?
わかる人助言をお願い致します。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/11/02 10:30