Skip to content

Commit 34a394c

Browse files
committed
add list_google_voices
1 parent 24801c5 commit 34a394c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

optional/list_google_voices.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
"""Lists the available voices."""
3+
from google.cloud import texttospeech
4+
from google.cloud.texttospeech import enums
5+
client = texttospeech.TextToSpeechClient()
6+
7+
# Performs the list voices request
8+
voices = client.list_voices()
9+
10+
for voice in voices.voices:
11+
# Display the voice's name. Example: tpc-vocoded
12+
print('Name: {}'.format(voice.name))
13+
14+
# Display the supported language codes for this voice. Example: "en-US"
15+
for language_code in voice.language_codes:
16+
print('Supported language: {}'.format(language_code))
17+
18+
ssml_gender = enums.SsmlVoiceGender(voice.ssml_gender)
19+
20+
# Display the SSML Voice Gender
21+
print('SSML Voice Gender: {}'.format(ssml_gender.name))
22+
23+
# Display the natural sample rate hertz for this voice. Example: 24000
24+
print('Natural Sample Rate Hertz: {}\n'.format(
25+
voice.natural_sample_rate_hertz))

0 commit comments

Comments
 (0)