@@ -69,8 +69,8 @@ public function getOptionalInputShape(): array {
6969 EShapeType::Enum
7070 ),
7171 'voice ' => new ShapeDescriptor (
72- $ this ->l ->t ('Voice ' ),
73- $ this ->l ->t ('The voice to use ' ),
72+ $ this ->l ->t ('Output voice ' ),
73+ $ this ->l ->t ('The voice used to generate speech ' ),
7474 EShapeType::Enum
7575 ),
7676 'tts_model ' => new ShapeDescriptor (
@@ -120,7 +120,7 @@ public function getOptionalOutputShape(): array {
120120 return [
121121 'input_transcript ' => new ShapeDescriptor (
122122 $ this ->l ->t ('Input transcript ' ),
123- $ this ->l ->t ('Input transcription ' ),
123+ $ this ->l ->t ('Transcription of the input audio ' ),
124124 EShapeType::Text,
125125 ),
126126 ];
@@ -132,7 +132,7 @@ public function getOptionalOutputShapeEnumValues(): array {
132132
133133 public function process (?string $ userId , array $ input , callable $ reportProgress ): array {
134134 if (!isset ($ input ['input ' ]) || !$ input ['input ' ] instanceof File || !$ input ['input ' ]->isReadable ()) {
135- throw new RuntimeException ('Invalid input file ' );
135+ throw new RuntimeException ('Invalid input audio file in the "input" field. A readable file is expected. ' );
136136 }
137137 $ inputFile = $ input ['input ' ];
138138
@@ -142,7 +142,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
142142 $ systemPrompt = $ input ['system_prompt ' ];
143143
144144 if (!isset ($ input ['history ' ]) || !is_array ($ input ['history ' ])) {
145- throw new RuntimeException ('Invalid history ' );
145+ throw new RuntimeException ('Invalid chat history, array expected ' );
146146 }
147147 $ history = $ input ['history ' ];
148148
@@ -160,9 +160,9 @@ public function process(?string $userId, array $input, callable $reportProgress)
160160
161161
162162 if (isset ($ input ['voice ' ]) && is_string ($ input ['voice ' ])) {
163- $ voice = $ input ['voice ' ];
163+ $ outputVoice = $ input ['voice ' ];
164164 } else {
165- $ voice = $ this ->appConfig ->getValueString (Application::APP_ID , 'default_speech_voice ' , Application::DEFAULT_SPEECH_VOICE ) ?: Application::DEFAULT_SPEECH_VOICE ;
165+ $ outputVoice = $ this ->appConfig ->getValueString (Application::APP_ID , 'default_speech_voice ' , Application::DEFAULT_SPEECH_VOICE ) ?: Application::DEFAULT_SPEECH_VOICE ;
166166 }
167167
168168 $ speed = 1 ;
@@ -184,7 +184,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
184184 $ b64Audio = base64_encode ($ inputFile ->getContent ());
185185 $ extraParams = [
186186 'modalities ' => ['text ' , 'audio ' ],
187- 'audio ' => ['voice ' => $ voice , 'format ' => 'mp3 ' ],
187+ 'audio ' => ['voice ' => $ outputVoice , 'format ' => 'mp3 ' ],
188188 ];
189189 $ completion = $ this ->openAiAPIService ->createChatCompletion (
190190 $ userId , 'gpt-4o-audio-preview ' , null , $ systemPrompt , $ history , 1 , 1000 ,
@@ -230,7 +230,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
230230
231231 // text to speech
232232 try {
233- $ apiResponse = $ this ->openAiAPIService ->requestSpeechCreation ($ userId , $ llmResult , $ ttsModel , $ voice , $ speed );
233+ $ apiResponse = $ this ->openAiAPIService ->requestSpeechCreation ($ userId , $ llmResult , $ ttsModel , $ outputVoice , $ speed );
234234
235235 if (!isset ($ apiResponse ['body ' ])) {
236236 $ this ->logger ->warning ('OpenAI/LocalAI \'s text to speech generation failed: no speech returned ' );
@@ -243,7 +243,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
243243 ];
244244 } catch (\Exception $ e ) {
245245 $ this ->logger ->warning ('OpenAI/LocalAI \'s text to speech generation failed with: ' . $ e ->getMessage (), ['exception ' => $ e ]);
246- throw new RuntimeException ('OpenAI/LocalAI \'s text to image generation failed with: ' . $ e ->getMessage ());
246+ throw new RuntimeException ('OpenAI/LocalAI \'s text to speech generation failed with: ' . $ e ->getMessage ());
247247 }
248248 }
249249}
0 commit comments