5454use Symfony \AI \Platform \Bridge \Cerebras \PlatformFactory as CerebrasPlatformFactory ;
5555use Symfony \AI \Platform \Bridge \DeepSeek \PlatformFactory as DeepSeekPlatformFactory ;
5656use Symfony \AI \Platform \Bridge \DockerModelRunner \PlatformFactory as DockerModelRunnerPlatformFactory ;
57+ use Symfony \AI \Platform \Bridge \ElevenLabs \ElevenLabsSpeechProvider ;
5758use Symfony \AI \Platform \Bridge \ElevenLabs \PlatformFactory as ElevenLabsPlatformFactory ;
5859use Symfony \AI \Platform \Bridge \Gemini \PlatformFactory as GeminiPlatformFactory ;
5960use Symfony \AI \Platform \Bridge \HuggingFace \PlatformFactory as HuggingFacePlatformFactory ;
7576use Symfony \AI \Platform \Platform ;
7677use Symfony \AI \Platform \PlatformInterface ;
7778use Symfony \AI \Platform \ResultConverterInterface ;
79+ use Symfony \AI \Platform \Speech \SpeechConfiguration ;
80+ use Symfony \AI \Platform \Speech \SpeechProviderInterface ;
7881use Symfony \AI \Store \Bridge \Azure \SearchStore as AzureSearchStore ;
7982use Symfony \AI \Store \Bridge \ChromaDb \Store as ChromaDbStore ;
8083use Symfony \AI \Store \Bridge \ClickHouse \Store as ClickHouseStore ;
102105use Symfony \AI \Store \Indexer ;
103106use Symfony \AI \Store \IndexerInterface ;
104107use Symfony \AI \Store \StoreInterface ;
105- use Symfony \AI \Voice \Bridge \ElevenLabs \ElevenLabsSpeechProvider as ElevenLabsVoiceProvider ;
106- use Symfony \AI \Voice \VoiceProviderInterface ;
107108use Symfony \Component \Clock \ClockInterface ;
108109use Symfony \Component \Config \Definition \Configurator \DefinitionConfigurator ;
109110use Symfony \Component \DependencyInjection \Attribute \Target ;
@@ -251,7 +252,12 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
251252 }
252253
253254 foreach ($ config ['voice ' ] as $ voiceProvider => $ provider ) {
254- $ this ->processVoiceProviderConfig ($ voiceProvider , $ provider , $ builder );
255+ $ this ->processSpeechConfig ($ voiceProvider , $ provider , $ builder );
256+ }
257+
258+ $ speechProviders = array_keys ($ builder ->findTaggedServiceIds ('ai.speech_provider ' ));
259+ if ([] === $ speechProviders ) {
260+ $ builder ->removeDefinition ('ai.speech_provider.listener ' );
255261 }
256262
257263 foreach ($ config ['vectorizer ' ] ?? [] as $ vectorizerName => $ vectorizer ) {
@@ -420,11 +426,9 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
420426 }
421427
422428 if ('eleven_labs ' === $ type ) {
423- $ platformId = 'ai.platform.eleven_labs ' ;
424429 $ definition = (new Definition (Platform::class))
425430 ->setFactory (ElevenLabsPlatformFactory::class.'::create ' )
426431 ->setLazy (true )
427- ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
428432 ->setArguments ([
429433 $ platform ['api_key ' ],
430434 $ platform ['host ' ],
@@ -433,9 +437,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
433437 null ,
434438 new Reference ('event_dispatcher ' ),
435439 ])
440+ ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
436441 ->addTag ('ai.platform ' , ['name ' => 'eleven_labs ' ]);
437442
438- $ container ->setDefinition ($ platformId , $ definition );
443+ $ container ->setDefinition (' ai.platform.eleven_labs ' , $ definition );
439444
440445 return ;
441446 }
@@ -1809,23 +1814,33 @@ private function processChatConfig(string $name, array $configuration, Container
18091814 /**
18101815 * @param array<string, mixed> $providers
18111816 */
1812- private function processVoiceProviderConfig (string $ name , array $ providers , ContainerBuilder $ container ): void
1817+ private function processSpeechConfig (string $ name , array $ providers , ContainerBuilder $ container ): void
18131818 {
18141819 if ('eleven_labs ' === $ name ) {
1815- foreach ($ providers as $ type => $ config ) {
1820+ foreach ($ providers as $ config ) {
1821+ $ configurationDefinition = new Definition (SpeechConfiguration::class);
1822+ $ configurationDefinition
1823+ ->setLazy (true )
1824+ ->setArguments ([
1825+ $ config ['tts_model ' ],
1826+ $ config ['tts_voice ' ],
1827+ $ config ['stt_model ' ],
1828+ ]);
1829+
1830+ $ container ->setDefinition ('ai.speech.eleven_labs.configuration ' , $ configurationDefinition );
1831+
18161832 $ definition = new Definition (ElevenLabsSpeechProvider::class);
18171833 $ definition
18181834 ->setLazy (true )
18191835 ->setArguments ([
18201836 new Reference ('ai.platform.eleven_labs ' ),
1821- $ config [ ' model ' ] ,
1837+ new Reference ( ' ai.speech.eleven_labs.configuration ' ) ,
18221838 ])
1823- ->addTag ('proxy ' , ['interface ' => VoiceProviderInterface::class])
1824- ->addTag ('ai.voice.provider ' );
1839+ ->addTag ('proxy ' , ['interface ' => SpeechProviderInterface::class])
1840+ ->addTag ('kernel.event_subscriber ' )
1841+ ->addTag ('ai.speech_provider ' );
18251842
1826- $ container ->setDefinition ('ai.voice.eleven_labs. ' .$ name , $ definition );
1827- $ container ->registerAliasForArgument ('ai.voice. ' .$ type .'. ' .$ name , VoiceProviderInterface::class, $ name );
1828- $ container ->registerAliasForArgument ('ai.voice. ' .$ type .'. ' .$ name , VoiceProviderInterface::class, $ type .'_ ' .$ name );
1843+ $ container ->setDefinition ('ai.speech.eleven_labs. ' .$ name , $ definition );
18291844 }
18301845 }
18311846 }
0 commit comments