From 001ce5e0e9905dbac45f522fb1dbaf367e20b4b0 Mon Sep 17 00:00:00 2001 From: Noah Negrey Date: Wed, 17 Jul 2019 16:18:02 -0600 Subject: [PATCH] Python 2 compatibility for print statements [(#2226)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2226) * Python 2 compatibility for print statements * Update beta_snippets.py --- .../samples/snippets/beta_snippets.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/google-cloud-python-speech/samples/snippets/beta_snippets.py b/packages/google-cloud-python-speech/samples/snippets/beta_snippets.py index 51bd0d16949b..33957abd3a51 100644 --- a/packages/google-cloud-python-speech/samples/snippets/beta_snippets.py +++ b/packages/google-cloud-python-speech/samples/snippets/beta_snippets.py @@ -58,8 +58,8 @@ def transcribe_file_with_enhanced_model(): for i, result in enumerate(response.results): alternative = result.alternatives[0] print('-' * 20) - print('First alternative of result {}'.format(i)) - print('Transcript: {}'.format(alternative.transcript)) + print(u'First alternative of result {}'.format(i)) + print(u'Transcript: {}'.format(alternative.transcript)) # [END speech_transcribe_enhanced_model_beta] @@ -103,8 +103,8 @@ def transcribe_file_with_metadata(): for i, result in enumerate(response.results): alternative = result.alternatives[0] print('-' * 20) - print('First alternative of result {}'.format(i)) - print('Transcript: {}'.format(alternative.transcript)) + print(u'First alternative of result {}'.format(i)) + print(u'Transcript: {}'.format(alternative.transcript)) # [END speech_transcribe_recognition_metadata_beta] @@ -132,8 +132,8 @@ def transcribe_file_with_auto_punctuation(): for i, result in enumerate(response.results): alternative = result.alternatives[0] print('-' * 20) - print('First alternative of result {}'.format(i)) - print('Transcript: {}'.format(alternative.transcript)) + print(u'First alternative of result {}'.format(i)) + print(u'Transcript: {}'.format(alternative.transcript)) # [END speech_transcribe_auto_punctuation_beta] @@ -170,8 +170,8 @@ def transcribe_file_with_diarization(): # Printing out the output: for word_info in words_info: - print("word: '{}', speaker_tag: {}".format(word_info.word, - word_info.speaker_tag)) + print(u"word: '{}', speaker_tag: {}".format( + word_info.word, word_info.speaker_tag)) # [END speech_transcribe_diarization_beta] @@ -236,7 +236,7 @@ def transcribe_file_with_multilanguage(): for i, result in enumerate(response.results): alternative = result.alternatives[0] print('-' * 20) - print('First alternative of result {}: {}'.format(i, alternative)) + print(u'First alternative of result {}: {}'.format(i, alternative)) print(u'Transcript: {}'.format(alternative.transcript)) # [END speech_transcribe_multilanguage_beta]