Skip to content
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

Merged
merged 9 commits into from
Mar 26, 2018
Merged

Add text-to-speech beta samples #1421

merged 9 commits into from
Mar 26, 2018

Conversation

nnegrey
Copy link
Contributor

@nnegrey nnegrey commented Mar 21, 2018

No description provided.

@nnegrey nnegrey added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 21, 2018
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 21, 2018
@nnegrey nnegrey changed the title Add text-to-speech beta samples [DO-NOT-MERGE] Add text-to-speech beta samples Mar 21, 2018
"""Google Cloud Text-To-Speech API sample application .

Example usage:
python synthesize_text.py --text "hello" --output hello.mp3
Copy link
Contributor

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 :)

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor

@beccasaurus beccasaurus Mar 23, 2018

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

Copy link
Contributor Author

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"?>
Copy link
Contributor

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 :)

@nnegrey nnegrey changed the title [DO-NOT-MERGE] Add text-to-speech beta samples Add text-to-speech beta samples Mar 26, 2018
@nnegrey nnegrey removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 26, 2018
# 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')
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

@andrewsg andrewsg Mar 26, 2018

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.

@andrewsg andrewsg merged commit c24722f into master Mar 26, 2018
@nnegrey nnegrey deleted the text-to-speech-beta branch March 26, 2018 21:48
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request Apr 9, 2020
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 13, 2020
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 13, 2020
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 13, 2020
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants