-
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
Added Audio Profile sample #1538
Conversation
@nnegrey , @dizcology Can you please review this PR? |
@@ -0,0 +1,69 @@ | |||
#!/usr/bin/env python | |||
|
|||
# Copyright 2018 Google Inc. All Rights Reserved. |
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.
Google LLC
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.
Good point, but it is also Google Inc in every other file.
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.
For new files, I've been told we make the effort to update them, but on older files we just leave them.
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
@@ -0,0 +1,32 @@ | |||
# Copyright 2018, Google, Inc. |
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.
Google LLC
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
|
||
import argparse | ||
|
||
from google.cloud import texttospeech_v1beta1 as texttospeech |
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.
This should be moved to right between line 31/32. (Just learned this myself)
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.
from google.cloud import texttospeech_v1beta1 as texttospeech | ||
|
||
|
||
# [START tts_synthesize_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.
update region tag
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.
|
||
|
||
# [START tts_synthesize_text] | ||
def synthesize_text(text, output, effects_profile_id): |
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.
def synthesize_text_with_audio_profile?
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
"""Synthesizes speech from the input string of text.""" | ||
client = texttospeech.TextToSpeechClient() | ||
|
||
input_text = texttospeech.types.SynthesisInput(text=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.
Does this also support ssml?
@dizcology Should there be a 2nd snippet for ssml support?
|
||
|
||
def test_audio_profile(capsys): | ||
if os.path.exists(OUTOUT): |
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.
We should probably do the clean-up after it runs.
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
@nnegrey , @dizcology when you have time, can you please finalize your review of this PR? |
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.
LGTM
@@ -7,7 +7,7 @@ Google Cloud Text-to-Speech API Python Samples | |||
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/README.rst | |||
|
|||
|
|||
This directory contains samples for Google Cloud Text-to-Speech API. The `Google Cloud Text-to-Speech API`_ enables you to generate and customize synthesized speech from text or SSML. | |||
This directory contains samples for Google Cloud Text-to-Speech API. The `Google Cloud Text To Speech API`_ enables you to generate and customize synthesized speech from text or SSML. |
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.
Switch this one back I think.
|
||
# Note: you can pass in multiple effects_profile_id. They will be applied | ||
# in the same order they are provided. | ||
audio_config = texttospeech.types.AudioConfig( |
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.
Nice to have a comment about what some of the effects_profile_ids are.
out.write(response.audio_content) | ||
print('Audio content written to file "%s"' % output) | ||
|
||
# [END tts_synthesize_text_with_audio_profile] |
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.
Could delete the new line.
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.
3 nit but LGTM
|
||
assert ('Audio content written to file "%s"' % OUTPUT) in out | ||
assert os.path.exists(OUTPUT) | ||
os.remove(OUTPUT) |
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.
Maybe use pytest's temp file for this.
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
* Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
* Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
…rm/python-docs-samples#1538) * Added Audio Profile sample * Adjusted the row lengths * Adjusted the row length * Fixed Import orders * Fixed print statement * Debugging the unit test * Fixed the unit test * Some fixes per Noah's suggestions. * Renamed the function name in the test. * Multilined the long line. * Fixed the misspelling * Fixed the long line * Forcing the CicleCi to build again * Changing Inc to LLC * Updated library version. * Generated README.rst
No description provided.