Skip to content

Commit 9c09944

Browse files
committed
fix
1 parent bab79a8 commit 9c09944

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

examples/elevenlabs/text-to-speech.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
http_client(),
2323
);
2424
$model = new ElevenLabs(options: [
25-
'model' => 'Dslrhjl3ZpzrctukrQSN', # Brad (https://elevenlabs.io/app/voice-library?voiceId=Dslrhjl3ZpzrctukrQSN)
25+
'model' => 'Dslrhjl3ZpzrctukrQSN', // Brad (https://elevenlabs.io/app/voice-library?voiceId=Dslrhjl3ZpzrctukrQSN)
2626
]);
2727

2828
$result = $platform->invoke($model, new Text('Hello world'));

src/ai-bundle/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Configuration
3434
class: 'Symfony\AI\Platform\Bridge\OpenAi\Gpt'
3535
name: !php/const Symfony\AI\Platform\Bridge\OpenAi\Gpt::GPT_4O_MINI
3636
37-
**Advanced Example with Anthropic, Azure, ElevenLabs, Gemini, Ollamaand multiple agents**
37+
**Advanced Example with Anthropic, Azure, ElevenLabs, Gemini, Ollama multiple agents**
3838

3939
.. code-block:: yaml
4040

src/platform/src/Bridge/ElevenLabs/ElevenLabsClient.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function request(Model $model, array|string $payload, array $options = []
4040
return match ($model->getName()) {
4141
ElevenLabs::SPEECH_TO_TEXT => $this->doSpeechToTextRequest($model, $payload, $options),
4242
ElevenLabs::TEXT_TO_SPEECH => $this->doTextToSpeechRequest($model, $payload, $options),
43-
default => throw new InvalidArgumentException(sprintf('The model "%s" is not supported.', $model->getName())),
43+
default => throw new InvalidArgumentException(\sprintf('The model "%s" is not supported.', $model->getName())),
4444
};
4545
}
4646

@@ -50,17 +50,17 @@ public function request(Model $model, array|string $payload, array $options = []
5050
*/
5151
private function doSpeechToTextRequest(Model $model, array|string $payload, array $options): RawHttpResult
5252
{
53-
if (!array_key_exists('model', $model->getOptions())) {
53+
if (!\array_key_exists('model', $model->getOptions())) {
5454
throw new InvalidArgumentException('The model option is required.');
5555
}
5656

57-
if (!is_array($payload)) {
58-
throw new InvalidArgumentException(sprintf('The payload must be an array, received "%s".', get_debug_type($payload)));
57+
if (!\is_array($payload)) {
58+
throw new InvalidArgumentException(\sprintf('The payload must be an array, received "%s".', get_debug_type($payload)));
5959
}
6060

6161
$model = $options['model'] ??= $model->getOptions()['model'];
6262

63-
return new RawHttpResult($this->httpClient->request('POST', sprintf('%s/speech-to-text', $this->hostUrl), [
63+
return new RawHttpResult($this->httpClient->request('POST', \sprintf('%s/speech-to-text', $this->hostUrl), [
6464
'headers' => [
6565
'xi-api-key' => $this->apiKey,
6666
],
@@ -77,21 +77,21 @@ private function doSpeechToTextRequest(Model $model, array|string $payload, arra
7777
*/
7878
private function doTextToSpeechRequest(Model $model, array|string $payload, array $options): RawHttpResult
7979
{
80-
if (!array_key_exists('model', $model->getOptions())) {
80+
if (!\array_key_exists('model', $model->getOptions())) {
8181
throw new InvalidArgumentException('The model option is required.');
8282
}
8383

84-
if (!is_array($payload)) {
85-
throw new InvalidArgumentException(sprintf('The payload must be an array, received "%s".', get_debug_type($payload)));
84+
if (!\is_array($payload)) {
85+
throw new InvalidArgumentException(\sprintf('The payload must be an array, received "%s".', get_debug_type($payload)));
8686
}
8787

88-
if (!array_key_exists('text', $payload)) {
88+
if (!\array_key_exists('text', $payload)) {
8989
throw new InvalidArgumentException('The payload must contain a "text" key.');
9090
}
9191

9292
$model = $options['model'] ??= $model->getOptions()['model'];
9393

94-
return new RawHttpResult($this->httpClient->request('POST', sprintf('%s/text-to-speech/%s', $this->hostUrl, $model), [
94+
return new RawHttpResult($this->httpClient->request('POST', \sprintf('%s/text-to-speech/%s', $this->hostUrl, $model), [
9595
'headers' => [
9696
'xi-api-key' => $this->apiKey,
9797
],

src/platform/src/Bridge/ElevenLabs/ElevenLabsResultConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private function doConvertTextToSpeech(RawResultInterface $result): ResultInterf
6060
{
6161
$payload = $result->getObject()->getContent();
6262

63-
$path = sprintf('%s/%s.mp3', $this->outputPath, uniqid());
63+
$path = \sprintf('%s/%s.mp3', $this->outputPath, uniqid());
6464

6565
$filesystem = new Filesystem();
6666
$filesystem->dumpFile($path, $payload);

src/platform/tests/Bridge/ElevenLabs/ElevenLabsClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testClientCannotPerformSpeechToTextRequestWithoutModel()
5151
'my-api-key',
5252
);
5353

54-
$payload = $normalizer->normalize(Audio::fromFile(dirname(__DIR__, 5).'/fixtures/audio.mp3'));
54+
$payload = $normalizer->normalize(Audio::fromFile(\dirname(__DIR__, 5).'/fixtures/audio.mp3'));
5555

5656
$this->expectException(InvalidArgumentException::class);
5757
$this->expectExceptionMessage('The model option is required.');
@@ -86,7 +86,7 @@ public function testClientCanPerformSpeechToTextRequest()
8686
'my-api-key',
8787
);
8888

89-
$payload = $normalizer->normalize(Audio::fromFile(dirname(__DIR__, 5).'/fixtures/audio.mp3'));
89+
$payload = $normalizer->normalize(Audio::fromFile(\dirname(__DIR__, 5).'/fixtures/audio.mp3'));
9090

9191
$client->request(new ElevenLabs(ElevenLabs::SPEECH_TO_TEXT, options: [
9292
'model' => 'bar',

src/platform/tests/Bridge/ElevenLabs/ElevenLabsConverterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testConvertSpeechToTextResponse()
4242
$converter = new ElevenLabsResultConverter(sys_get_temp_dir());
4343
$rawResult = new InMemoryRawResult([
4444
'text' => 'Hello there',
45-
], new class() {
45+
], new class {
4646
public function getInfo(): string
4747
{
4848
return 'speech-to-text';
@@ -58,15 +58,15 @@ public function getInfo(): string
5858
public function testConvertTextToSpeechResponse()
5959
{
6060
$converter = new ElevenLabsResultConverter(sys_get_temp_dir());
61-
$rawResult = new InMemoryRawResult([], new class() {
61+
$rawResult = new InMemoryRawResult([], new class {
6262
public function getInfo(): string
6363
{
6464
return 'text-to-speech';
6565
}
6666

6767
public function getContent(): string
6868
{
69-
return file_get_contents(dirname(__DIR__, 5).'/fixtures/audio.mp3');
69+
return file_get_contents(\dirname(__DIR__, 5).'/fixtures/audio.mp3');
7070
}
7171
});
7272

src/platform/tests/Contract/Normalizer/Message/Content/AudioNormalizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testGetSupportedTypes()
4545
#[DataProvider('provideAudioData')]
4646
public function testNormalize(string $data, string $format, array $expected)
4747
{
48-
$audio = new Audio(base64_decode($data), $format, dirname(__DIR__, 7).'/fixtures/audio.mp3');
48+
$audio = new Audio(base64_decode($data), $format, \dirname(__DIR__, 7).'/fixtures/audio.mp3');
4949

5050
$this->assertSame($expected, $this->normalizer->normalize($audio));
5151
}
@@ -59,7 +59,7 @@ public static function provideAudioData(): \Generator
5959
'type' => 'input_audio',
6060
'input_audio' => [
6161
'data' => 'SUQzBAAAAAAAfVREUkMAAAAMAAADMg==',
62-
'path' => pathinfo(dirname(__DIR__, 7).'/fixtures/audio.mp3', \PATHINFO_DIRNAME).'/audio.mp3',
62+
'path' => pathinfo(\dirname(__DIR__, 7).'/fixtures/audio.mp3', \PATHINFO_DIRNAME).'/audio.mp3',
6363
'format' => 'mp3',
6464
],
6565
],
@@ -72,7 +72,7 @@ public static function provideAudioData(): \Generator
7272
'type' => 'input_audio',
7373
'input_audio' => [
7474
'data' => 'UklGRiQAAABXQVZFZm10IBA=',
75-
'path' => pathinfo(dirname(__DIR__, 7).'/fixtures/audio.mp3', \PATHINFO_DIRNAME).'/audio.mp3',
75+
'path' => pathinfo(\dirname(__DIR__, 7).'/fixtures/audio.mp3', \PATHINFO_DIRNAME).'/audio.mp3',
7676
'format' => 'wav',
7777
],
7878
],

src/platform/tests/ContractTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function providePayloadTestCases(): iterable
113113
'type' => 'input_audio',
114114
'input_audio' => [
115115
'data' => $audio->asBase64(),
116-
'path' => pathinfo(dirname(__DIR__, 3).'/fixtures/audio.mp3', \PATHINFO_DIRNAME).'/audio.mp3',
116+
'path' => pathinfo(\dirname(__DIR__, 3).'/fixtures/audio.mp3', \PATHINFO_DIRNAME).'/audio.mp3',
117117
'format' => 'mp3',
118118
],
119119
],

0 commit comments

Comments
 (0)