|
55 | 55 | use Symfony\AI\Platform\Bridge\Cerebras\PlatformFactory as CerebrasPlatformFactory; |
56 | 56 | use Symfony\AI\Platform\Bridge\DeepSeek\PlatformFactory as DeepSeekPlatformFactory; |
57 | 57 | use Symfony\AI\Platform\Bridge\DockerModelRunner\PlatformFactory as DockerModelRunnerPlatformFactory; |
| 58 | +use Symfony\AI\Platform\Bridge\ElevenLabs\ElevenLabsSpeechListener; |
58 | 59 | use Symfony\AI\Platform\Bridge\ElevenLabs\ElevenLabsSpeechProvider; |
59 | 60 | use Symfony\AI\Platform\Bridge\ElevenLabs\PlatformFactory as ElevenLabsPlatformFactory; |
60 | 61 | use Symfony\AI\Platform\Bridge\Gemini\PlatformFactory as GeminiPlatformFactory; |
|
78 | 79 | use Symfony\AI\Platform\PlatformInterface; |
79 | 80 | use Symfony\AI\Platform\ResultConverterInterface; |
80 | 81 | use Symfony\AI\Platform\Speech\SpeechConfiguration; |
| 82 | +use Symfony\AI\Platform\Speech\SpeechListenerInterface; |
81 | 83 | use Symfony\AI\Platform\Speech\SpeechProviderInterface; |
82 | 84 | use Symfony\AI\Store\Bridge\Azure\SearchStore as AzureSearchStore; |
83 | 85 | use Symfony\AI\Store\Bridge\ChromaDb\Store as ChromaDbStore; |
@@ -262,6 +264,11 @@ public function loadExtension(array $config, ContainerConfigurator $container, C |
262 | 264 | $builder->removeDefinition('ai.speech_provider.listener'); |
263 | 265 | } |
264 | 266 |
|
| 267 | + $speechListeners = array_keys($builder->findTaggedServiceIds('ai.speech_listener')); |
| 268 | + if ([] === $speechListeners) { |
| 269 | + $builder->removeDefinition('ai.speech_listener.listener'); |
| 270 | + } |
| 271 | + |
265 | 272 | foreach ($config['vectorizer'] ?? [] as $vectorizerName => $vectorizer) { |
266 | 273 | $this->processVectorizerConfig($vectorizerName, $vectorizer, $builder); |
267 | 274 | } |
@@ -437,6 +444,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB |
437 | 444 | new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), |
438 | 445 | new Reference('ai.platform.model_catalog.elevenlabs'), |
439 | 446 | null, |
| 447 | + new Reference('ai.speech.eleven_labs.configuration'), |
440 | 448 | new Reference('event_dispatcher'), |
441 | 449 | ]) |
442 | 450 | ->addTag('proxy', ['interface' => PlatformInterface::class]) |
@@ -1845,30 +1853,49 @@ private function processChatConfig(string $name, array $configuration, Container |
1845 | 1853 | private function processSpeechConfig(string $name, array $providers, ContainerBuilder $container): void |
1846 | 1854 | { |
1847 | 1855 | if ('eleven_labs' === $name) { |
1848 | | - foreach ($providers as $config) { |
| 1856 | + foreach ($providers as $type => $config) { |
1849 | 1857 | $configurationDefinition = new Definition(SpeechConfiguration::class); |
1850 | 1858 | $configurationDefinition |
1851 | 1859 | ->setLazy(true) |
1852 | 1860 | ->setArguments([ |
1853 | 1861 | $config['tts_model'], |
1854 | 1862 | $config['tts_voice'], |
| 1863 | + $config['tts_extra_options'], |
1855 | 1864 | $config['stt_model'], |
| 1865 | + $config['stt_extra_options'], |
1856 | 1866 | ]); |
1857 | 1867 |
|
1858 | 1868 | $container->setDefinition('ai.speech.eleven_labs.configuration', $configurationDefinition); |
1859 | 1869 |
|
1860 | | - $definition = new Definition(ElevenLabsSpeechProvider::class); |
1861 | | - $definition |
1862 | | - ->setLazy(true) |
1863 | | - ->setArguments([ |
1864 | | - new Reference('ai.platform.eleven_labs'), |
1865 | | - new Reference('ai.speech.eleven_labs.configuration'), |
1866 | | - ]) |
1867 | | - ->addTag('proxy', ['interface' => SpeechProviderInterface::class]) |
1868 | | - ->addTag('kernel.event_subscriber') |
1869 | | - ->addTag('ai.speech_provider'); |
| 1870 | + if (\array_key_exists('tts_model', $config)) { |
| 1871 | + $definition = new Definition(ElevenLabsSpeechProvider::class); |
| 1872 | + $definition |
| 1873 | + ->setLazy(true) |
| 1874 | + ->setArguments([ |
| 1875 | + new Reference('ai.platform.eleven_labs'), |
| 1876 | + ]) |
| 1877 | + ->addTag('proxy', ['interface' => SpeechProviderInterface::class]) |
| 1878 | + ->addTag('ai.speech_provider'); |
| 1879 | + |
| 1880 | + $container->setDefinition('ai.speech_provider.'.$type.'.'.$name, $definition); |
| 1881 | + $container->registerAliasForArgument('ai.speech_provider.'.$type.'.'.$name, SpeechProviderInterface::class, $name); |
| 1882 | + $container->registerAliasForArgument('ai.speech_provider.'.$type.'.'.$name, SpeechProviderInterface::class, $type.'_'.$name); |
| 1883 | + } |
1870 | 1884 |
|
1871 | | - $container->setDefinition('ai.speech.eleven_labs.'.$name, $definition); |
| 1885 | + if (\array_key_exists('stt_model', $config)) { |
| 1886 | + $definition = new Definition(ElevenLabsSpeechListener::class); |
| 1887 | + $definition |
| 1888 | + ->setLazy(true) |
| 1889 | + ->setArguments([ |
| 1890 | + new Reference('ai.platform.eleven_labs'), |
| 1891 | + ]) |
| 1892 | + ->addTag('proxy', ['interface' => SpeechListenerInterface::class]) |
| 1893 | + ->addTag('ai.speech_listener'); |
| 1894 | + |
| 1895 | + $container->setDefinition('ai.speech_listener.'.$type.'.'.$name, $definition); |
| 1896 | + $container->registerAliasForArgument('ai.speech_listener.'.$type.'.'.$name, SpeechListenerInterface::class, $name); |
| 1897 | + $container->registerAliasForArgument('ai.speech_listener.'.$type.'.'.$name, SpeechListenerInterface::class, $type.'_'.$name); |
| 1898 | + } |
1872 | 1899 | } |
1873 | 1900 | } |
1874 | 1901 | } |
|
0 commit comments