|
12 | 12 | namespace Symfony\AI\Platform\Bridge\ElevenLabs; |
13 | 13 |
|
14 | 14 | use Symfony\AI\Platform\Exception\RuntimeException; |
15 | | -use Symfony\AI\Platform\Message\Content\Text; |
16 | 15 | use Symfony\AI\Platform\Message\MessageBag; |
17 | 16 | use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface; |
18 | 17 | use Symfony\AI\Platform\PlatformInterface; |
19 | 18 | use Symfony\AI\Platform\Result\DeferredResult; |
20 | | -use Symfony\AI\Platform\Speech\Speech; |
21 | 19 | use Symfony\AI\Platform\Speech\SpeechPlatformInterface; |
22 | 20 | use Symfony\Component\OptionsResolver\OptionsResolver; |
23 | 21 |
|
@@ -48,37 +46,33 @@ public function invoke(string $model, object|array|string $input, array $options |
48 | 46 | return $this->platform->invoke($model, $input, $options); |
49 | 47 | } |
50 | 48 |
|
51 | | - public function generate(DeferredResult $result, array $options): ?Speech |
| 49 | + public function generate(DeferredResult $result, array $options): ?DeferredResult |
52 | 50 | { |
53 | 51 | if (!\array_key_exists('tts_model', $this->speechConfiguration) || !\array_key_exists('tts_voice', $this->speechConfiguration)) { |
54 | 52 | return null; |
55 | 53 | } |
56 | 54 |
|
57 | 55 | $payload = $result->asText(); |
58 | 56 |
|
59 | | - $speechResult = $this->invoke($this->speechConfiguration['tts_model'], ['text' => $payload], [ |
| 57 | + return $this->invoke($this->speechConfiguration['tts_model'], ['text' => $payload], [ |
60 | 58 | 'voice' => $this->speechConfiguration['tts_voice'], |
61 | 59 | ...$this->speechConfiguration['tts_options'] ?? [], |
62 | 60 | ...$options, |
63 | 61 | ]); |
64 | | - |
65 | | - return new Speech($payload, $speechResult, 'elevenlabs'); |
66 | 62 | } |
67 | 63 |
|
68 | | - public function listen(object|array|string $input, array $options): ?Text |
| 64 | + public function listen(object|array|string $input, array $options): ?DeferredResult |
69 | 65 | { |
70 | 66 | if (!\array_key_exists('stt_model', $this->speechConfiguration)) { |
71 | 67 | return null; |
72 | 68 | } |
73 | 69 |
|
74 | 70 | $input = ($input instanceof MessageBag && $input->containsAudio()) ? $input->getUserMessage()->getAudioContent() : $input; |
75 | 71 |
|
76 | | - $result = $this->platform->invoke($this->speechConfiguration['stt_model'], $input, [ |
| 72 | + return $this->platform->invoke($this->speechConfiguration['stt_model'], $input, [ |
77 | 73 | ...$options, |
78 | 74 | ...$this->speechConfiguration['stt_options'] ?? [], |
79 | 75 | ]); |
80 | | - |
81 | | - return new Text($result->asText()); |
82 | 76 | } |
83 | 77 |
|
84 | 78 | public function getModelCatalog(): ModelCatalogInterface |
|
0 commit comments