@@ -155,6 +155,35 @@ public function testClientCanPerformTextToSpeechRequest()
155
155
$ this ->assertSame (2 , $ httpClient ->getRequestsCount ());
156
156
}
157
157
158
+ public function testClientCanPerformTextToSpeechRequestWhenVoiceKeyIsProvidedAsRequestOption ()
159
+ {
160
+ $ payload = Audio::fromFile (\dirname (__DIR__ , 5 ).'/fixtures/audio.mp3 ' );
161
+
162
+ $ httpClient = new MockHttpClient ([
163
+ new JsonMockResponse ([
164
+ [
165
+ 'model_id ' => ElevenLabs::ELEVEN_MULTILINGUAL_V2 ,
166
+ 'can_do_text_to_speech ' => true ,
167
+ ],
168
+ ]),
169
+ new MockResponse ($ payload ->asBinary ()),
170
+ ]);
171
+
172
+ $ client = new ElevenLabsClient (
173
+ $ httpClient ,
174
+ 'https://api.elevenlabs.io/v1 ' ,
175
+ 'my-api-key ' ,
176
+ );
177
+
178
+ $ client ->request (new ElevenLabs (ElevenLabs::ELEVEN_MULTILINGUAL_V2 ), [
179
+ 'text ' => 'foo ' ,
180
+ ], [
181
+ 'voice ' => 'Dslrhjl3ZpzrctukrQSN ' ,
182
+ ]);
183
+
184
+ $ this ->assertSame (2 , $ httpClient ->getRequestsCount ());
185
+ }
186
+
158
187
public function testClientCanPerformTextToSpeechRequestAsStream ()
159
188
{
160
189
$ payload = Audio::fromFile (\dirname (__DIR__ , 5 ).'/fixtures/audio.mp3 ' );
@@ -185,4 +214,35 @@ public function testClientCanPerformTextToSpeechRequestAsStream()
185
214
$ this ->assertInstanceOf (RawHttpResult::class, $ result );
186
215
$ this ->assertSame (2 , $ httpClient ->getRequestsCount ());
187
216
}
217
+
218
+ public function testClientCanPerformTextToSpeechRequestAsStreamVoiceKeyIsProvidedAsRequestOption ()
219
+ {
220
+ $ payload = Audio::fromFile (\dirname (__DIR__ , 5 ).'/fixtures/audio.mp3 ' );
221
+
222
+ $ httpClient = new MockHttpClient ([
223
+ new JsonMockResponse ([
224
+ [
225
+ 'model_id ' => ElevenLabs::ELEVEN_MULTILINGUAL_V2 ,
226
+ 'can_do_text_to_speech ' => true ,
227
+ ],
228
+ ]),
229
+ new MockResponse ($ payload ->asBinary ()),
230
+ ]);
231
+
232
+ $ client = new ElevenLabsClient (
233
+ $ httpClient ,
234
+ 'https://api.elevenlabs.io/v1 ' ,
235
+ 'my-api-key ' ,
236
+ );
237
+
238
+ $ result = $ client ->request (new ElevenLabs (ElevenLabs::ELEVEN_MULTILINGUAL_V2 ), [
239
+ 'text ' => 'foo ' ,
240
+ ], [
241
+ 'voice ' => 'Dslrhjl3ZpzrctukrQSN ' ,
242
+ 'stream ' => true ,
243
+ ]);
244
+
245
+ $ this ->assertInstanceOf (RawHttpResult::class, $ result );
246
+ $ this ->assertSame (2 , $ httpClient ->getRequestsCount ());
247
+ }
188
248
}
0 commit comments