2121use Symfony \AI \Platform \Result \RawResultInterface ;
2222use Symfony \AI \Platform \Result \TextResult ;
2323use Symfony \AI \Platform \ResultConverterInterface ;
24+ use Symfony \AI \Platform \Speech \SpeechAwarePlatform ;
2425use Symfony \AI \Platform \Speech \SpeechConfiguration ;
2526
2627final class ElevenLabsSpeechProviderTest extends TestCase
2728{
2829 public function testProviderCannotSupportOnWrongModel ()
2930 {
30- $ speechConfiguration = new SpeechConfiguration (ttsModel: 'foo ' );
3131 $ model = new ElevenLabs ('foo ' );
3232
3333 $ rawResult = $ this ->createMock (RawResultInterface::class);
@@ -39,17 +39,17 @@ public function testProviderCannotSupportOnWrongModel()
3939 $ modelCatalog ->expects ($ this ->once ())->method ('getModel ' )->willReturn ($ model );
4040
4141 $ platform = $ this ->createMock (PlatformInterface::class);
42- $ platform ->expects ($ this ->once ())->method ('getSpeechConfiguration ' )->willReturn ($ speechConfiguration );
4342 $ platform ->expects ($ this ->once ())->method ('getModelCatalog ' )->willReturn ($ modelCatalog );
4443
45- $ speechListener = new ElevenLabsSpeechProvider ($ platform );
44+ $ speechAwarePlatform = new SpeechAwarePlatform ($ platform , new SpeechConfiguration (ttsModel: 'foo ' ));
45+
46+ $ speechListener = new ElevenLabsSpeechProvider ($ speechAwarePlatform );
4647
4748 $ this ->assertFalse ($ speechListener ->support ($ deferredResult , []));
4849 }
4950
5051 public function testProviderCanSupportOnValidModel ()
5152 {
52- $ speechConfiguration = new SpeechConfiguration (ttsModel: 'foo ' );
5353 $ model = new ElevenLabs ('foo ' , [
5454 Capability::TEXT_TO_SPEECH ,
5555 ]);
@@ -63,18 +63,17 @@ public function testProviderCanSupportOnValidModel()
6363 $ modelCatalog ->expects ($ this ->once ())->method ('getModel ' )->willReturn ($ model );
6464
6565 $ platform = $ this ->createMock (PlatformInterface::class);
66- $ platform ->expects ($ this ->once ())->method ('getSpeechConfiguration ' )->willReturn ($ speechConfiguration );
6766 $ platform ->expects ($ this ->once ())->method ('getModelCatalog ' )->willReturn ($ modelCatalog );
6867
69- $ speechListener = new ElevenLabsSpeechProvider ($ platform );
68+ $ speechAwarePlatform = new SpeechAwarePlatform ($ platform , new SpeechConfiguration (ttsModel: 'foo ' ));
69+
70+ $ speechListener = new ElevenLabsSpeechProvider ($ speechAwarePlatform );
7071
7172 $ this ->assertTrue ($ speechListener ->support ($ deferredResult , []));
7273 }
7374
7475 public function testProviderCanGenerate ()
7576 {
76- $ configuration = new SpeechConfiguration (ttsModel: 'foo ' , ttsVoice: 'bar ' );
77-
7877 $ rawResult = $ this ->createMock (RawResultInterface::class);
7978
8079 $ resultConverter = $ this ->createMock (ResultConverterInterface::class);
@@ -88,10 +87,11 @@ public function testProviderCanGenerate()
8887 $ speechResult = new DeferredResult ($ secondResultConverter , $ rawResult );
8988
9089 $ platform = $ this ->createMock (PlatformInterface::class);
91- $ platform ->expects ($ this ->once ())->method ('getSpeechConfiguration ' )->willReturn ($ configuration );
9290 $ platform ->expects ($ this ->once ())->method ('invoke ' )->willReturn ($ speechResult );
9391
94- $ speechListener = new ElevenLabsSpeechProvider ($ platform );
92+ $ speechAwarePlatform = new SpeechAwarePlatform ($ platform , new SpeechConfiguration (ttsModel: 'foo ' , ttsVoice: 'bar ' ));
93+
94+ $ speechListener = new ElevenLabsSpeechProvider ($ speechAwarePlatform );
9595
9696 $ speech = $ speechListener ->generate ($ deferredResult , []);
9797
0 commit comments