Skip to content

Commit

Permalink
Access Display Names of enum fields via enum object [(#1738)](GoogleC…
Browse files Browse the repository at this point in the history
…loudPlatform/python-docs-samples#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.
  • Loading branch information
beccasaurus authored and busunkim96 committed May 20, 2020
1 parent c39d5c5 commit 4725041
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/google-cloud-texttospeech/samples/list_voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 4725041

Please sign in to comment.