Skip to content

Commit 28d67d2

Browse files
committed
chore(quotes): Update double quotes to single
1 parent 37a688a commit 28d67d2

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ This would give an output of `DetailedResponse` having the structure:
251251
You can use the `get_result()`, `get_headers()` and get_status_code() to return the result, headers and status code respectively.
252252

253253
## Using Websockets
254-
The Text to Speech service supports synthesizing text to spoken audio using web sockets with the `synthesize_using_websocket`. The Speech to Text service supports recognizing speech to text using web sockets with the `recognize_using_websocket`. These methods need a custom callback class to listen to events. Below is an example of `synthesize_using_websocket`.
254+
The Text to Speech service supports synthesizing text to spoken audio using web sockets with the `synthesize_using_websocket`. The Speech to Text service supports recognizing speech to text using web sockets with the `recognize_using_websocket`. These methods need a custom callback class to listen to events. Below is an example of `synthesize_using_websocket`. Note: The service accepts one request per connection.
255255

256256
```py
257257
from watson_developer_cloud.websocket import SynthesizeCallback
@@ -267,10 +267,10 @@ class MySynthesizeCallback(SynthesizeCallback):
267267
return data
268268

269269
my_callback = MySynthesizeCallback()
270-
service.synthesize_using_websocket("I like to pet dogs",
270+
service.synthesize_using_websocket('I like to pet dogs',
271271
my_callback,
272272
accept='audio/wav',
273-
voice="en-US_AllisonVoice"
273+
voice='en-US_AllisonVoice'
274274
)
275275
```
276276

examples/text_to_speech_v1.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@
7070
class MySynthesizeCallback(SynthesizeCallback):
7171
def __init__(self):
7272
SynthesizeCallback.__init__(self)
73-
self.fd = open(file_path, "ab")
73+
self.fd = open(file_path, 'ab')
7474

7575
def on_connected(self):
76-
print("Connection was successful")
76+
print('Connection was successful')
7777

7878
def on_error(self, error):
79-
print("Error received: {}".format(error))
79+
print('Error received: {}'.format(error))
8080

8181
def on_content_type(self, content_type):
82-
print("Content type: {}".format(content_type))
82+
print('Content type: {}'.format(content_type))
8383

8484
def on_timing_information(self, timing_information):
8585
print(timing_information)
@@ -89,11 +89,11 @@ def on_audio_stream(self, audio_stream):
8989

9090
def on_close(self):
9191
self.fd.close()
92-
print("Done synthesizing. Closing the connection")
92+
print('Done synthesizing. Closing the connection')
9393

9494
my_callback = MySynthesizeCallback()
95-
service.synthesize_using_websocket("I like to pet dogs",
95+
service.synthesize_using_websocket('I like to pet dogs',
9696
my_callback,
9797
accept='audio/wav',
98-
voice="en-US_AllisonVoice"
98+
voice='en-US_AllisonVoice'
9999
)

test/integration/test_text_to_speech_v1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ def test_custom_words(self):
7070
assert word['translation'] == 'mackles'
7171

7272
def test_synthesize_using_websocket(self):
73-
file = "tongue_twister.wav"
73+
file = 'tongue_twister.wav'
7474
class MySynthesizeCallback(SynthesizeCallback):
7575
def __init__(self):
7676
SynthesizeCallback.__init__(self)
7777
self.fd = None
7878
self.error = None
7979

8080
def on_connected(self):
81-
self.fd = open(file, "ab")
81+
self.fd = open(file, 'ab')
8282

8383
def on_error(self, error):
8484
self.error = error
@@ -90,10 +90,10 @@ def on_close(self):
9090
self.fd.close()
9191

9292
test_callback = MySynthesizeCallback()
93-
self.text_to_speech.synthesize_using_websocket("She sells seashells by the seashore",
93+
self.text_to_speech.synthesize_using_websocket('She sells seashells by the seashore',
9494
test_callback,
9595
accept='audio/wav',
96-
voice="en-GB_KateVoice"
96+
voice='en-GB_KateVoice'
9797
)
9898
assert test_callback.error is None
9999
assert test_callback.fd is not None

watson_developer_cloud/websocket/synthesize_listener.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self,
5656

5757
self.ws_client.run_forever(http_proxy_host=self.http_proxy_host,
5858
http_proxy_port=self.http_proxy_port,
59-
sslopt={"cert_reqs": ssl.CERT_NONE} if self.verify is not None else None)
59+
sslopt={'cert_reqs': ssl.CERT_NONE} if self.verify is not None else None)
6060

6161
def send_text(self):
6262
"""
@@ -93,10 +93,10 @@ def on_data(self, ws, message, message_type, fin):
9393
try:
9494
if message_type == websocket.ABNF.OPCODE_TEXT:
9595
json_object = json.loads(message)
96-
if "binary_streams" in json_object:
97-
self.callback.on_content_type(json_object["binary_streams"][0]["content_type"])
98-
elif "error" in json_object:
99-
self.on_error(ws, json_object.get("error"))
96+
if 'binary_streams' in json_object:
97+
self.callback.on_content_type(json_object['binary_streams'][0]['content_type'])
98+
elif 'error' in json_object:
99+
self.on_error(ws, json_object.get('error'))
100100
return
101101
else:
102102
self.callback.on_timing_information(json_object)

0 commit comments

Comments
 (0)