@@ -40,9 +40,14 @@ public function request(Model $model, array|string $payload, array $options = []
40
40
return match ($ model ->getName ()) {
41
41
ElevenLabs::SPEECH_TO_TEXT => $ this ->doSpeechToTextRequest ($ model , $ payload , $ options ),
42
42
ElevenLabs::TEXT_TO_SPEECH => $ this ->doTextToSpeechRequest ($ model , $ payload , $ options ),
43
+ default => throw new InvalidArgumentException (sprintf ('The model "%s" is not supported. ' , $ model ->getName ())),
43
44
};
44
45
}
45
46
47
+ /**
48
+ * @param array<string|int, mixed> $payload
49
+ * @param array<string, mixed> $options
50
+ */
46
51
private function doSpeechToTextRequest (Model $ model , array |string $ payload , array $ options ): RawHttpResult
47
52
{
48
53
if (!array_key_exists ('model ' , $ model ->getOptions ())) {
@@ -60,12 +65,16 @@ private function doSpeechToTextRequest(Model $model, array|string $payload, arra
60
65
'xi-api-key ' => $ this ->apiKey ,
61
66
],
62
67
'body ' => [
63
- 'file ' => $ payload ['input_audio ' ]['resource ' ] ,
68
+ 'file ' => fopen ( $ payload ['input_audio ' ]['path ' ], ' r ' ) ,
64
69
'model_id ' => $ model ,
65
70
],
66
71
]));
67
72
}
68
73
74
+ /**
75
+ * @param array<string|int, mixed> $payload
76
+ * @param array<string, mixed> $options
77
+ */
69
78
private function doTextToSpeechRequest (Model $ model , array |string $ payload , array $ options ): RawHttpResult
70
79
{
71
80
if (!array_key_exists ('model ' , $ model ->getOptions ())) {
0 commit comments