Skip to content

Commit 2d23c35

Browse files
committed
ref
1 parent 79a805e commit 2d23c35

File tree

6 files changed

+2
-28
lines changed

6 files changed

+2
-28
lines changed

examples/elevenlabs/speech-to-text.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
$platform = PlatformFactory::create(
1919
apiKey: env('ELEVEN_LABS_API_KEY'),
20-
outputPath: __DIR__.'/tmp',
2120
httpClient: http_client()
2221
);
2322
$model = new ElevenLabs(ElevenLabs::SCRIBE_V1);

examples/elevenlabs/text-to-speech.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
$platform = PlatformFactory::create(
1919
apiKey: env('ELEVEN_LABS_API_KEY'),
20-
outputPath: dirname(__DIR__).'/tmp',
2120
httpClient: http_client(),
2221
);
2322
$model = new ElevenLabs(options: [

src/ai-bundle/src/AiBundle.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
213213
->addTag('proxy', ['interface' => PlatformInterface::class])
214214
->setArguments([
215215
$platform['api_key'],
216-
$platform['output_path'],
217216
$platform['host'],
218217
new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
219218
new Reference('ai.platform.contract.default'),

src/platform/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"symfony/console": "^6.4 || ^7.1",
4545
"symfony/dotenv": "^6.4 || ^7.1",
4646
"symfony/event-dispatcher": "^6.4 || ^7.1",
47-
"symfony/filesystem": "^7.3",
4847
"symfony/finder": "^6.4 || ^7.1",
4948
"symfony/process": "^6.4 || ^7.1",
5049
"symfony/var-dumper": "^6.4 || ^7.1"

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,13 @@
1818
use Symfony\AI\Platform\Result\ResultInterface;
1919
use Symfony\AI\Platform\Result\TextResult;
2020
use Symfony\AI\Platform\ResultConverterInterface;
21-
use Symfony\Component\Filesystem\Filesystem;
2221
use Symfony\Contracts\HttpClient\ResponseInterface;
2322

2423
/**
2524
* @author Guillaume Loulier <[email protected]>
2625
*/
2726
final readonly class ElevenLabsResultConverter implements ResultConverterInterface
2827
{
29-
public function __construct(
30-
private string $outputPath,
31-
) {
32-
if (!class_exists(Filesystem::class)) {
33-
throw new RuntimeException('For using ElevenLabs as platform, the symfony/filesystem package is required. Try running "composer require symfony/filesystem".');
34-
}
35-
}
36-
3728
public function supports(Model $model): bool
3829
{
3930
return $model instanceof ElevenLabs;
@@ -46,20 +37,8 @@ public function convert(RawResultInterface $result, array $options = []): Result
4637

4738
return match (true) {
4839
str_contains($response->getInfo('url'), 'speech-to-text') => new TextResult($result->getData()['text']),
49-
str_contains($response->getInfo('url'), 'text-to-speech') => $this->doConvertTextToSpeech($result),
40+
str_contains($response->getInfo('url'), 'text-to-speech') => new BinaryResult($result->getObject()->getContent(), 'audio/mpeg'),
5041
default => throw new RuntimeException('Unsupported ElevenLabs response.'),
5142
};
5243
}
53-
54-
private function doConvertTextToSpeech(RawResultInterface $result): ResultInterface
55-
{
56-
$payload = $result->getObject()->getContent();
57-
58-
$path = \sprintf('%s/%s.mp3', $this->outputPath, uniqid());
59-
60-
$filesystem = new Filesystem();
61-
$filesystem->dumpFile($path, $payload);
62-
63-
return new BinaryResult($filesystem->readFile($path), 'audio/mpeg');
64-
}
6544
}

src/platform/src/Bridge/ElevenLabs/PlatformFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
{
2525
public static function create(
2626
string $apiKey,
27-
string $outputPath,
2827
string $hostUrl = 'https://api.elevenlabs.io/v1',
2928
?HttpClientInterface $httpClient = null,
3029
?Contract $contract = null,
@@ -33,7 +32,7 @@ public static function create(
3332

3433
return new Platform(
3534
[new ElevenLabsClient($httpClient, $apiKey, $hostUrl)],
36-
[new ElevenLabsResultConverter($outputPath)],
35+
[new ElevenLabsResultConverter()],
3736
$contract ?? ElevenLabsContract::create(),
3837
);
3938
}

0 commit comments

Comments
 (0)