From 7776a6cbcec259eab1d832dd86e99b8880441154 Mon Sep 17 00:00:00 2001 From: Rebecca Taylor Date: Mon, 15 Oct 2018 13:53:04 -0700 Subject: [PATCH] Access Display Names of enum fields via enum object [(#1738)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1738) * Get display name of enums using IntEnum Requires updating google-cloud-language to 1.1.0 * Add note about gs://demomaker for video test files * Get display name of enums using IntEnum * Get display name of enums using IntEnum * Revert "Add note about gs://demomaker for video test files" This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62. --- texttospeech/snippets/list_voices.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/texttospeech/snippets/list_voices.py b/texttospeech/snippets/list_voices.py index 3f43499c6742..a2da5a178528 100644 --- a/texttospeech/snippets/list_voices.py +++ b/texttospeech/snippets/list_voices.py @@ -25,6 +25,7 @@ def list_voices(): """Lists the available voices.""" from google.cloud import texttospeech + from google.cloud.texttospeech import enums client = texttospeech.TextToSpeechClient() # Performs the list voices request @@ -38,13 +39,10 @@ def list_voices(): for language_code in voice.language_codes: print('Supported language: {}'.format(language_code)) - # SSML Voice Gender values from google.cloud.texttospeech.enums - ssml_voice_genders = ['SSML_VOICE_GENDER_UNSPECIFIED', 'MALE', - 'FEMALE', 'NEUTRAL'] + ssml_gender = enums.SsmlVoiceGender(voice.ssml_gender) # Display the SSML Voice Gender - print('SSML Voice Gender: {}'.format( - ssml_voice_genders[voice.ssml_gender])) + print('SSML Voice Gender: {}'.format(ssml_gender.name)) # Display the natural sample rate hertz for this voice. Example: 24000 print('Natural Sample Rate Hertz: {}\n'.format(