|
54 | 54 | use Symfony\AI\Platform\Bridge\Cerebras\PlatformFactory as CerebrasPlatformFactory; |
55 | 55 | use Symfony\AI\Platform\Bridge\DeepSeek\PlatformFactory as DeepSeekPlatformFactory; |
56 | 56 | use Symfony\AI\Platform\Bridge\DockerModelRunner\PlatformFactory as DockerModelRunnerPlatformFactory; |
| 57 | +use Symfony\AI\Platform\Bridge\ElevenLabs\ElevenLabsSpeechListener; |
57 | 58 | use Symfony\AI\Platform\Bridge\ElevenLabs\ElevenLabsSpeechProvider; |
58 | 59 | use Symfony\AI\Platform\Bridge\ElevenLabs\PlatformFactory as ElevenLabsPlatformFactory; |
59 | 60 | use Symfony\AI\Platform\Bridge\Gemini\PlatformFactory as GeminiPlatformFactory; |
|
77 | 78 | use Symfony\AI\Platform\PlatformInterface; |
78 | 79 | use Symfony\AI\Platform\ResultConverterInterface; |
79 | 80 | use Symfony\AI\Platform\Speech\SpeechConfiguration; |
| 81 | +use Symfony\AI\Platform\Speech\SpeechListenerInterface; |
80 | 82 | use Symfony\AI\Platform\Speech\SpeechProviderInterface; |
81 | 83 | use Symfony\AI\Store\Bridge\Azure\SearchStore as AzureSearchStore; |
82 | 84 | use Symfony\AI\Store\Bridge\ChromaDb\Store as ChromaDbStore; |
@@ -260,6 +262,11 @@ public function loadExtension(array $config, ContainerConfigurator $container, C |
260 | 262 | $builder->removeDefinition('ai.speech_provider.listener'); |
261 | 263 | } |
262 | 264 |
|
| 265 | + $speechListeners = array_keys($builder->findTaggedServiceIds('ai.speech_listener')); |
| 266 | + if ([] === $speechListeners) { |
| 267 | + $builder->removeDefinition('ai.speech_listener.listener'); |
| 268 | + } |
| 269 | + |
263 | 270 | foreach ($config['vectorizer'] ?? [] as $vectorizerName => $vectorizer) { |
264 | 271 | $this->processVectorizerConfig($vectorizerName, $vectorizer, $builder); |
265 | 272 | } |
@@ -435,6 +442,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB |
435 | 442 | new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), |
436 | 443 | new Reference('ai.platform.model_catalog.elevenlabs'), |
437 | 444 | null, |
| 445 | + new Reference('ai.speech.eleven_labs.configuration'), |
438 | 446 | new Reference('event_dispatcher'), |
439 | 447 | ]) |
440 | 448 | ->addTag('proxy', ['interface' => PlatformInterface::class]) |
@@ -1817,30 +1825,49 @@ private function processChatConfig(string $name, array $configuration, Container |
1817 | 1825 | private function processSpeechConfig(string $name, array $providers, ContainerBuilder $container): void |
1818 | 1826 | { |
1819 | 1827 | if ('eleven_labs' === $name) { |
1820 | | - foreach ($providers as $config) { |
| 1828 | + foreach ($providers as $type => $config) { |
1821 | 1829 | $configurationDefinition = new Definition(SpeechConfiguration::class); |
1822 | 1830 | $configurationDefinition |
1823 | 1831 | ->setLazy(true) |
1824 | 1832 | ->setArguments([ |
1825 | 1833 | $config['tts_model'], |
1826 | 1834 | $config['tts_voice'], |
| 1835 | + $config['tts_extra_options'], |
1827 | 1836 | $config['stt_model'], |
| 1837 | + $config['stt_extra_options'], |
1828 | 1838 | ]); |
1829 | 1839 |
|
1830 | 1840 | $container->setDefinition('ai.speech.eleven_labs.configuration', $configurationDefinition); |
1831 | 1841 |
|
1832 | | - $definition = new Definition(ElevenLabsSpeechProvider::class); |
1833 | | - $definition |
1834 | | - ->setLazy(true) |
1835 | | - ->setArguments([ |
1836 | | - new Reference('ai.platform.eleven_labs'), |
1837 | | - new Reference('ai.speech.eleven_labs.configuration'), |
1838 | | - ]) |
1839 | | - ->addTag('proxy', ['interface' => SpeechProviderInterface::class]) |
1840 | | - ->addTag('kernel.event_subscriber') |
1841 | | - ->addTag('ai.speech_provider'); |
| 1842 | + if (\array_key_exists('tts_model', $config)) { |
| 1843 | + $definition = new Definition(ElevenLabsSpeechProvider::class); |
| 1844 | + $definition |
| 1845 | + ->setLazy(true) |
| 1846 | + ->setArguments([ |
| 1847 | + new Reference('ai.platform.eleven_labs'), |
| 1848 | + ]) |
| 1849 | + ->addTag('proxy', ['interface' => SpeechProviderInterface::class]) |
| 1850 | + ->addTag('ai.speech_provider'); |
| 1851 | + |
| 1852 | + $container->setDefinition('ai.speech_provider.'.$type.'.'.$name, $definition); |
| 1853 | + $container->registerAliasForArgument('ai.speech_provider.'.$type.'.'.$name, SpeechProviderInterface::class, $name); |
| 1854 | + $container->registerAliasForArgument('ai.speech_provider.'.$type.'.'.$name, SpeechProviderInterface::class, $type.'_'.$name); |
| 1855 | + } |
1842 | 1856 |
|
1843 | | - $container->setDefinition('ai.speech.eleven_labs.'.$name, $definition); |
| 1857 | + if (\array_key_exists('stt_model', $config)) { |
| 1858 | + $definition = new Definition(ElevenLabsSpeechListener::class); |
| 1859 | + $definition |
| 1860 | + ->setLazy(true) |
| 1861 | + ->setArguments([ |
| 1862 | + new Reference('ai.platform.eleven_labs'), |
| 1863 | + ]) |
| 1864 | + ->addTag('proxy', ['interface' => SpeechListenerInterface::class]) |
| 1865 | + ->addTag('ai.speech_listener'); |
| 1866 | + |
| 1867 | + $container->setDefinition('ai.speech_listener.'.$type.'.'.$name, $definition); |
| 1868 | + $container->registerAliasForArgument('ai.speech_listener.'.$type.'.'.$name, SpeechListenerInterface::class, $name); |
| 1869 | + $container->registerAliasForArgument('ai.speech_listener.'.$type.'.'.$name, SpeechListenerInterface::class, $type.'_'.$name); |
| 1870 | + } |
1844 | 1871 | } |
1845 | 1872 | } |
1846 | 1873 | } |
|
0 commit comments