@@ -69,8 +69,8 @@ public function getOptionalInputShape(): array {
69
69
EShapeType::Enum
70
70
),
71
71
'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 ' ),
74
74
EShapeType::Enum
75
75
),
76
76
'tts_model ' => new ShapeDescriptor (
@@ -120,7 +120,7 @@ public function getOptionalOutputShape(): array {
120
120
return [
121
121
'input_transcript ' => new ShapeDescriptor (
122
122
$ this ->l ->t ('Input transcript ' ),
123
- $ this ->l ->t ('Input transcription ' ),
123
+ $ this ->l ->t ('Transcription of the input audio ' ),
124
124
EShapeType::Text,
125
125
),
126
126
];
@@ -132,7 +132,7 @@ public function getOptionalOutputShapeEnumValues(): array {
132
132
133
133
public function process (?string $ userId , array $ input , callable $ reportProgress ): array {
134
134
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. ' );
136
136
}
137
137
$ inputFile = $ input ['input ' ];
138
138
@@ -142,7 +142,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
142
142
$ systemPrompt = $ input ['system_prompt ' ];
143
143
144
144
if (!isset ($ input ['history ' ]) || !is_array ($ input ['history ' ])) {
145
- throw new RuntimeException ('Invalid history ' );
145
+ throw new RuntimeException ('Invalid chat history, array expected ' );
146
146
}
147
147
$ history = $ input ['history ' ];
148
148
@@ -160,9 +160,9 @@ public function process(?string $userId, array $input, callable $reportProgress)
160
160
161
161
162
162
if (isset ($ input ['voice ' ]) && is_string ($ input ['voice ' ])) {
163
- $ voice = $ input ['voice ' ];
163
+ $ outputVoice = $ input ['voice ' ];
164
164
} 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 ;
166
166
}
167
167
168
168
$ speed = 1 ;
@@ -184,7 +184,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
184
184
$ b64Audio = base64_encode ($ inputFile ->getContent ());
185
185
$ extraParams = [
186
186
'modalities ' => ['text ' , 'audio ' ],
187
- 'audio ' => ['voice ' => $ voice , 'format ' => 'mp3 ' ],
187
+ 'audio ' => ['voice ' => $ outputVoice , 'format ' => 'mp3 ' ],
188
188
];
189
189
$ completion = $ this ->openAiAPIService ->createChatCompletion (
190
190
$ userId , 'gpt-4o-audio-preview ' , null , $ systemPrompt , $ history , 1 , 1000 ,
@@ -230,7 +230,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
230
230
231
231
// text to speech
232
232
try {
233
- $ apiResponse = $ this ->openAiAPIService ->requestSpeechCreation ($ userId , $ llmResult , $ ttsModel , $ voice , $ speed );
233
+ $ apiResponse = $ this ->openAiAPIService ->requestSpeechCreation ($ userId , $ llmResult , $ ttsModel , $ outputVoice , $ speed );
234
234
235
235
if (!isset ($ apiResponse ['body ' ])) {
236
236
$ 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)
243
243
];
244
244
} catch (\Exception $ e ) {
245
245
$ 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 ());
247
247
}
248
248
}
249
249
}
0 commit comments