@@ -43,7 +43,7 @@ public function testTextToSpeech(): void
43
43
44
44
$ this ->client ->shouldReceive ("request " )
45
45
->once ()
46
- ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&r=0&c=MP3&f=16khz_16bit_stereo " )
46
+ ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&v=Alice& r=0&c=MP3&f=16khz_16bit_stereo " )
47
47
->andReturn ($ response );
48
48
49
49
$ this ->assertSame ("mp3 " , $ this ->provider ->textToSpeech ("Hello " ));
@@ -58,7 +58,7 @@ public function testTextToSpeechFailure(): void
58
58
59
59
$ this ->client ->shouldReceive ("request " )
60
60
->once ()
61
- ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&r=0&c=MP3&f=16khz_16bit_stereo " )
61
+ ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&v=Alice& r=0&c=MP3&f=16khz_16bit_stereo " )
62
62
->andReturn ($ response );
63
63
64
64
$ this ->expectException (ProviderException::class);
@@ -81,7 +81,7 @@ public function testWithLanguage(): void
81
81
82
82
$ this ->client ->shouldReceive ("request " )
83
83
->once ()
84
- ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=fr-fr&r=0&c=MP3&f=16khz_16bit_stereo " )
84
+ ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=fr-fr&v=Alice& r=0&c=MP3&f=16khz_16bit_stereo " )
85
85
->andReturn ($ response );
86
86
87
87
$ this ->assertSame ("mp3 " , $ provider ->textToSpeech ("Hello " ));
@@ -96,6 +96,30 @@ public function testWithLanguageFailure(): void
96
96
}
97
97
98
98
99
+ /**
100
+ * Ensure we can set a different voice.
101
+ */
102
+ public function testWithVoice1 (): void
103
+ {
104
+ $ provider = $ this ->provider ->withVoice ("Harry " );
105
+
106
+ # Ensure immutability
107
+ $ this ->assertSame ("Harry " , $ provider ->getOptions ()["voice " ]);
108
+ $ this ->assertSame ("Alice " , $ this ->provider ->getOptions ()["voice " ]);
109
+
110
+ $ response = Mockery::mock (ResponseInterface::class);
111
+ $ response ->shouldReceive ("getStatusCode " )->once ()->andReturn ("200 " );
112
+ $ response ->shouldReceive ("getBody " )->once ()->andReturn (Utils::streamFor ("mp3 " ));
113
+
114
+ $ this ->client ->shouldReceive ("request " )
115
+ ->once ()
116
+ ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&v=Harry&r=0&c=MP3&f=16khz_16bit_stereo " )
117
+ ->andReturn ($ response );
118
+
119
+ $ this ->assertSame ("mp3 " , $ provider ->textToSpeech ("Hello " ));
120
+ }
121
+
122
+
99
123
public function testWithSpeed (): void
100
124
{
101
125
$ provider = $ this ->provider ->withSpeed (-5 );
@@ -110,7 +134,7 @@ public function testWithSpeed(): void
110
134
111
135
$ this ->client ->shouldReceive ("request " )
112
136
->once ()
113
- ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&r=-5&c=MP3&f=16khz_16bit_stereo " )
137
+ ->with ("GET " , "https://api.voicerss.org/?key=APIKEY&src=Hello&hl=en-gb&v=Alice& r=-5&c=MP3&f=16khz_16bit_stereo " )
114
138
->andReturn ($ response );
115
139
116
140
$ this ->assertSame ("mp3 " , $ provider ->textToSpeech ("Hello " ));
@@ -129,6 +153,7 @@ public function testGetOptions(): void
129
153
{
130
154
$ options = [
131
155
"language " => "en-gb " ,
156
+ "voice " => "Alice " ,
132
157
"speed " => 0 ,
133
158
];
134
159
@@ -138,10 +163,11 @@ public function testGetOptions(): void
138
163
139
164
public function testConstructorOptions1 (): void
140
165
{
141
- $ provider = new VoiceRssProvider ("APIKEY " , "ab-cd " , 10 );
166
+ $ provider = new VoiceRssProvider ("APIKEY " , "ab-cd " , 10 , " Harry " );
142
167
143
168
$ options = [
144
169
"language " => "ab-cd " ,
170
+ "voice " => "Harry " ,
145
171
"speed " => 10 ,
146
172
];
147
173
0 commit comments