Skip to content

Commit 1fc85ea

Browse files
author
cclauss
authored
Use print() function on both Python 2 and Python 3
Legacy print statements are syntax errors in Python 3 because __print()__ is a function. One year from Python 2 end of life: http://pythonclock.org @ehdsouza @germanattanasio Your reviews please.
1 parent 37f5b14 commit 1fc85ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/speaker_text_to_speech.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# passed in the request. When the service responds with the synthesized
66
# audio, the pyaudio would play it in a blocking mode
77

8+
from __future__ import print_function
89
from watson_developer_cloud import TextToSpeechV1
910
from watson_developer_cloud.websocket import SynthesizeCallback
1011
import pyaudio
@@ -66,20 +67,20 @@ def __init__(self):
6667
self.play = Play()
6768

6869
def on_connected(self):
69-
print 'Opening stream to play'
70+
print('Opening stream to play')
7071
self.play.start_streaming()
7172

7273
def on_error(self, error):
73-
print 'Error received: {}'.format(error)
74+
print('Error received: {}'.format(error))
7475

7576
def on_timing_information(self, timing_information):
76-
print timing_information
77+
print(timing_information)
7778

7879
def on_audio_stream(self, audio_stream):
7980
self.play.write_stream(audio_stream)
8081

8182
def on_close(self):
82-
print 'Completed synthesizing'
83+
print('Completed synthesizing')
8384
self.play.complete_playing()
8485

8586
test_callback = MySynthesizeCallback()

0 commit comments

Comments
 (0)