-
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
feat: adds media translation samples #3117
feat: adds media translation samples #3117
Conversation
|
||
config = mediatranslation.StreamingTranslateSpeechConfig( | ||
audio_config=mediatranslation.TranslateSpeechConfig( | ||
audio_encoding='linear16', |
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.
Why is this a string?
It should be an enum like this: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/transcribe_model_selection.py#L43
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.
Acknowledged. I will raise that issue with product engineering.
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
description=__doc__, | ||
formatter_class=argparse.RawDescriptionHelpFormatter) | ||
parser.add_argument('stream', help='File to stream to the API') | ||
args = parser.parse_args() | ||
translate_from_file(args.stream) |
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 __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
description=__doc__, | |
formatter_class=argparse.RawDescriptionHelpFormatter) | |
parser.add_argument('stream', help='File to stream to the API') | |
args = parser.parse_args() | |
translate_from_file(args.stream) | |
# [END media_translation_translate_from_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.
Done
os.path.join(RESOURCES, 'audio.raw')) | ||
out, err = capsys.readouterr() | ||
|
||
assert re.search(r'Partial translation', out, re.DOTALL | re.I) |
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 seems fine, you can also just do : assert 'Partial translation' 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.
Good to know!
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
Blocked by: #3116 |
|
||
client = mediatranslation.SpeechTranslationServiceClient() | ||
|
||
speech_config = mediatranslation.TranslateSpeechConfig( |
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: so up to you, personally I like to have the variables names match the argument they'll be used in later, but the object name is TranslateSpeechConfig
speech_config = mediatranslation.TranslateSpeechConfig( | |
audio_config = mediatranslation.TranslateSpeechConfig( |
Same thing for config
below --> streaming_config
, but again object name isn't the same.
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 (once README.rst is added)
Note: I still don't like that the audio_encoding
is a string, but that is outside the scope here.
This pull request adds the following code snippet region tags: