|
| 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 |
0 commit comments