File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
texttospeech/cloud-client Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 25
25
def list_voices ():
26
26
"""Lists the available voices."""
27
27
from google .cloud import texttospeech
28
+ from google .cloud .texttospeech import enums
28
29
client = texttospeech .TextToSpeechClient ()
29
30
30
31
# Performs the list voices request
@@ -38,13 +39,10 @@ def list_voices():
38
39
for language_code in voice .language_codes :
39
40
print ('Supported language: {}' .format (language_code ))
40
41
41
- # SSML Voice Gender values from google.cloud.texttospeech.enums
42
- ssml_voice_genders = ['SSML_VOICE_GENDER_UNSPECIFIED' , 'MALE' ,
43
- 'FEMALE' , 'NEUTRAL' ]
42
+ ssml_gender = enums .SsmlVoiceGender (voice .ssml_gender )
44
43
45
44
# Display the SSML Voice Gender
46
- print ('SSML Voice Gender: {}' .format (
47
- ssml_voice_genders [voice .ssml_gender ]))
45
+ print ('SSML Voice Gender: {}' .format (ssml_gender .name ))
48
46
49
47
# Display the natural sample rate hertz for this voice. Example: 24000
50
48
print ('Natural Sample Rate Hertz: {}\n ' .format (
You can’t perform that action at this time.
0 commit comments