Skip to content

Commit adcd62b

Browse files
wangbill-googletseaver
authored andcommitted
tests(texttospeech): create system tests for V1 / V1beta1 (#9418)
1 parent 6cc4962 commit adcd62b

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from google.cloud import texttospeech_v1
16+
17+
18+
class TestSystemSpeech(object):
19+
def test_synthesize_speech(self):
20+
client = texttospeech_v1.TextToSpeechClient()
21+
22+
synthesis_input = texttospeech_v1.types.SynthesisInput(text="Hello, World!")
23+
voice = texttospeech_v1.types.VoiceSelectionParams(
24+
language_code="en-US",
25+
ssml_gender=texttospeech_v1.enums.SsmlVoiceGender.NEUTRAL,
26+
)
27+
audio_config = texttospeech_v1.types.AudioConfig(
28+
audio_encoding=texttospeech_v1.enums.AudioEncoding.MP3
29+
)
30+
31+
response = client.synthesize_speech(synthesis_input, voice, audio_config)
32+
assert response.audio_content is not None
33+
34+
def test_list_voices(self):
35+
client = texttospeech_v1.TextToSpeechClient()
36+
37+
voices = client.list_voices()
38+
assert len(voices.voices) > 0
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from google.cloud import texttospeech_v1beta1
16+
17+
18+
class TestSystemSpeech(object):
19+
def test_synthesize_speech(self):
20+
client = texttospeech_v1beta1.TextToSpeechClient()
21+
22+
synthesis_input = texttospeech_v1beta1.types.SynthesisInput(
23+
text="Hello, World!"
24+
)
25+
voice = texttospeech_v1beta1.types.VoiceSelectionParams(
26+
language_code="en-US",
27+
ssml_gender=texttospeech_v1beta1.enums.SsmlVoiceGender.NEUTRAL,
28+
)
29+
audio_config = texttospeech_v1beta1.types.AudioConfig(
30+
audio_encoding=texttospeech_v1beta1.enums.AudioEncoding.MP3
31+
)
32+
33+
response = client.synthesize_speech(synthesis_input, voice, audio_config)
34+
assert response.audio_content is not None
35+
36+
def test_list_voices(self):
37+
client = texttospeech_v1beta1.TextToSpeechClient()
38+
39+
voices = client.list_voices()
40+
assert len(voices.voices) > 0

0 commit comments

Comments
 (0)