-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add text-to-speech beta samples #1421
Conversation
"""Google Cloud Text-To-Speech API sample application . | ||
|
||
Example usage: | ||
python synthesize_text.py --text "hello" --output hello.mp3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the snippets currently write to output.mp3
and sample functions don't accept a parameter for output file
--output
is not an argument
Either add support for --output
or remove from the example usage :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ssml_voice_genders = ['SSML_VOICE_GENDER_UNSPECIFIED', 'MALE', | ||
'FEMALE', 'NEUTRAL'] | ||
|
||
# Display the supported SSML - gender for this voice. Example: FEMALE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
# SSML Voice Gender values from google.cloud.texttospeech.enums
ssml_voice_genders = ['SSML_VOICE_GENDER_UNSPECIFIED', 'MALE',
'FEMALE', 'NEUTRAL']
# Display the SSML Voice Gender
print('SSML Voice Gender: {}'.format(ssml_voice_genders[voice.ssml_gender]))
(And apply same to Java)
Simply making it as clear as possible that the values used map to the SSML spec, see Voice element here: https://www.w3.org/TR/speech-synthesis11/#g13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#nit
It's good as is! The only thing I really would like to change is this:
the supported SSML - gender for this voice
Rather than "SSML - gender"
which separates the 2, say "SSML gender"
to be clear that the gender
is SSML defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -0,0 +1,7 @@ | |||
<?xml version="1.0"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify this :)
For out samples, let's just use simple SSML:
<speak>Hello there.</speak>
Per request from product :)
# Build the voice request, select the language code ("en-US") and the ssml | ||
# voice gender ("neutral") | ||
voice = texttospeech.types.VoiceSelectionParams(language_code='en-US', | ||
ssml_gender='NEUTRAL') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssml_gender should have its own enums, please use enums to specify this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
synthesize_file.synthesize_text_file(text_file=TEXT_FILE) | ||
out, err = capsys.readouterr() | ||
|
||
assert 'Audio content written to file' in out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible assert that the output file has size greater than zero. (doing this in only one of the tests should be enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. just need a new line between import os and import synthesize_file/text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: is there a flake8 config file I should grab, that would catch that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use nox (pip install nox-automation
; then nox -l
with grep to find the lint session for your particular subproject, then nox -s "lint(your-subproject-here)"
) to use the repo's standard flake8 config.
No description provided.