Skip to content

Commit 85fae76

Browse files
committed
ref
1 parent 000c147 commit 85fae76

File tree

7 files changed

+6
-59
lines changed

7 files changed

+6
-59
lines changed

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.transformers-cache
33
composer.lock
44
vendor
5+
tmp

examples/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"symfony/event-dispatcher": "^6.4|^7.0",
2323
"symfony/filesystem": "^6.4|^7.0",
2424
"symfony/finder": "^6.4|^7.0",
25-
"symfony/mime": "^7.3",
2625
"symfony/process": "^6.4|^7.0",
2726
"symfony/var-dumper": "^6.4|^7.0"
2827
},

examples/elevenlabs/text-to-speech.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
$platform = PlatformFactory::create(
1919
apiKey: env('ELEVEN_LABS_API_KEY'),
20-
outputPath: __DIR__.'/tmp',
20+
outputPath: dirname(__DIR__).'/tmp',
2121
httpClient: http_client(),
2222
);
2323
$model = new ElevenLabs(options: [
@@ -26,4 +26,4 @@
2626

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

29-
echo $result->asAudio().\PHP_EOL;
29+
echo $result->asBase64() .\PHP_EOL;

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313

1414
use Symfony\AI\Platform\Exception\RuntimeException;
1515
use Symfony\AI\Platform\Model;
16-
use Symfony\AI\Platform\Result\AudioResult;
16+
use Symfony\AI\Platform\Result\BinaryResult;
1717
use Symfony\AI\Platform\Result\RawResultInterface;
1818
use Symfony\AI\Platform\Result\ResultInterface;
1919
use Symfony\AI\Platform\Result\TextResult;
2020
use Symfony\AI\Platform\ResultConverterInterface;
2121
use Symfony\Component\Filesystem\Filesystem;
22-
use Symfony\Component\Mime\MimeTypes;
2322
use Symfony\Contracts\HttpClient\ResponseInterface;
2423

2524
/**
@@ -33,10 +32,6 @@ public function __construct(
3332
if (!class_exists(Filesystem::class)) {
3433
throw new RuntimeException('For using ElevenLabs as platform, the symfony/filesystem package is required. Try running "composer require symfony/filesystem".');
3534
}
36-
37-
if (!class_exists(MimeTypes::class)) {
38-
throw new RuntimeException('For using ElevenLabs as platform, the symfony/mime package is required. Try running "composer require symfony/mime".');
39-
}
4035
}
4136

4237
public function supports(Model $model): bool
@@ -65,6 +60,6 @@ private function doConvertTextToSpeech(RawResultInterface $result): ResultInterf
6560
$filesystem = new Filesystem();
6661
$filesystem->dumpFile($path, $payload);
6762

68-
return new AudioResult($path, (new MimeTypes())->guessMimeType($path));
63+
return new BinaryResult($filesystem->readFile($path), 'audio/mpeg');
6964
}
7065
}

src/platform/src/Message/Content/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function asDataUrl(): string
7373
return \sprintf('data:%s;base64,%s', $this->format, $this->asBase64());
7474
}
7575

76-
public function asPath(): string
76+
public function asPath(): ?string
7777
{
7878
return $this->path;
7979
}

src/platform/src/Result/AudioResult.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/platform/src/Result/ResultPromise.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ public function asBinary(): string
7373
return $this->as(BinaryResult::class)->getContent();
7474
}
7575

76-
public function asAudio(): string
77-
{
78-
$result = $this->as(AudioResult::class);
79-
80-
\assert($result instanceof AudioResult);
81-
82-
return $result->getPath();
83-
}
84-
8576
public function asBase64(): string
8677
{
8778
$result = $this->as(BinaryResult::class);

0 commit comments

Comments
 (0)