Skip to content

Commit 8d59fdd

Browse files
authored
Revert "feat(Text to Speech): Synthesize using web sockets"
1 parent abaffc7 commit 8d59fdd

File tree

13 files changed

+10
-521
lines changed

13 files changed

+10
-521
lines changed

README.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/watson-developer-cloud/python-sdk.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/python-sdk)
44
[![Slack](https://wdc-slack-inviter.mybluemix.net/badge.svg)](https://wdc-slack-inviter.mybluemix.net)
5+
[![codecov.io](https://codecov.io/github/watson-developer-cloud/python-sdk/coverage.svg?branch=master)](https://codecov.io/github/watson-developer-cloud/python-sdk?branch=master)
56
[![Latest Stable Version](https://img.shields.io/pypi/v/watson-developer-cloud.svg)](https://pypi.python.org/pypi/watson-developer-cloud)
67
[![CLA assistant](https://cla-assistant.io/readme/badge/watson-developer-cloud/python-sdk)](https://cla-assistant.io/watson-developer-cloud/python-sdk)
78

@@ -250,37 +251,13 @@ This would give an output of `DetailedResponse` having the structure:
250251
```
251252
You can use the `get_result()`, `get_headers()` and get_status_code() to return the result, headers and status code respectively.
252253

253-
## 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`. Note: The service accepts one request per connection.
255-
256-
```py
257-
from watson_developer_cloud.websocket import SynthesizeCallback
258-
259-
class MySynthesizeCallback(SynthesizeCallback):
260-
def __init__(self):
261-
SynthesizeCallback.__init__(self)
262-
263-
def on_audio_stream(self, audio_stream):
264-
return audio_stream
265-
266-
def on_data(self, data):
267-
return data
268-
269-
my_callback = MySynthesizeCallback()
270-
service.synthesize_using_websocket('I like to pet dogs',
271-
my_callback,
272-
accept='audio/wav',
273-
voice='en-US_AllisonVoice'
274-
)
275-
```
276-
277254
## Dependencies
278255

279256
* [requests]
280257
* `python_dateutil` >= 2.5.3
281258
* [responses] for testing
282259
* Following for web sockets support in speech to text
283-
* `websocket-client` 0.52.0
260+
* `websocket-client` 0.47.0
284261

285262
## Contributing
286263

examples/speaker_text_to_speech.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

examples/text_to_speech_v1.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import json
44
from os.path import join, dirname
55
from watson_developer_cloud import TextToSpeechV1
6-
from watson_developer_cloud.websocket import SynthesizeCallback
76

87
# If service instance provides API key authentication
98
# service = TextToSpeechV1(
@@ -64,36 +63,3 @@
6463

6564
# response = service.delete_voice_model('YOUR CUSTOMIZATION ID').get_result()
6665
# print(response)
67-
68-
# Synthesize using websocket. Note: The service accepts one request per connection
69-
file_path = join(dirname(__file__), "../resources/dog.wav")
70-
class MySynthesizeCallback(SynthesizeCallback):
71-
def __init__(self):
72-
SynthesizeCallback.__init__(self)
73-
self.fd = open(file_path, 'ab')
74-
75-
def on_connected(self):
76-
print('Connection was successful')
77-
78-
def on_error(self, error):
79-
print('Error received: {}'.format(error))
80-
81-
def on_content_type(self, content_type):
82-
print('Content type: {}'.format(content_type))
83-
84-
def on_timing_information(self, timing_information):
85-
print(timing_information)
86-
87-
def on_audio_stream(self, audio_stream):
88-
self.fd.write(audio_stream)
89-
90-
def on_close(self):
91-
self.fd.close()
92-
print('Done synthesizing. Closing the connection')
93-
94-
my_callback = MySynthesizeCallback()
95-
service.synthesize_using_websocket('I like to pet dogs',
96-
my_callback,
97-
accept='audio/wav',
98-
voice='en-US_AllisonVoice'
99-
)

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Sphinx>=1.3.1
1717
bumpversion>=0.5.3
1818

1919
# Web sockets
20-
websocket-client==0.52.0
20+
websocket-client==0.47.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests>=2.0,<3.0
22
python_dateutil>=2.5.3
3-
websocket-client==0.52.0
3+
websocket-client==0.47.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def run_tests(self):
6464
version=__version__,
6565
description='Client library to use the IBM Watson Services',
6666
license='Apache 2.0',
67-
install_requires=['requests>=2.0, <3.0', 'python_dateutil>=2.5.3', 'websocket-client==0.52.0'],
67+
install_requires=['requests>=2.0, <3.0', 'python_dateutil>=2.5.3', 'websocket-client==0.47.0'],
6868
tests_require=['responses', 'pytest', 'python_dotenv', 'pytest-rerunfailures', 'tox'],
6969
cmdclass={'test': PyTest},
7070
author='Jeffrey Stylos',

test/integration/test_speech_to_text_v1.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ def on_error(self, error):
9797
def on_transcription(self, transcript):
9898
self.transcript = transcript
9999

100-
test_callback = MyRecognizeCallback()
100+
testCallback = MyRecognizeCallback()
101101
with open(os.path.join(os.path.dirname(__file__), '../../resources/speech.wav'), 'rb') as audio_file:
102102
audio_source = AudioSource(audio_file, False)
103-
t = threading.Thread(target=self.speech_to_text.recognize_using_websocket, args=(audio_source, "audio/l16; rate=44100", test_callback))
103+
t = threading.Thread(target=self.speech_to_text.recognize_using_websocket, args=(audio_source, "audio/l16; rate=44100", testCallback))
104104
t.start()
105105
t.join()
106-
assert test_callback.error is None
107-
assert test_callback.transcript is not None
108-
assert test_callback.transcript[0]['transcript'] == 'thunderstorms could produce large hail isolated tornadoes and heavy rain '
106+
assert testCallback.error is None
107+
assert testCallback.transcript is not None
108+
assert testCallback.transcript[0]['transcript'] == 'thunderstorms could produce large hail isolated tornadoes and heavy rain '

test/integration/test_text_to_speech_v1.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# coding: utf-8
22
import unittest
33
import watson_developer_cloud
4-
from watson_developer_cloud.websocket import SynthesizeCallback
54
import pytest
65
import os
76

@@ -68,34 +67,3 @@ def test_custom_words(self):
6867
self.text_to_speech.delete_word(customization_id, 'ACLs')
6968
word = self.text_to_speech.get_word(customization_id, 'MACLs').get_result()
7069
assert word['translation'] == 'mackles'
71-
72-
def test_synthesize_using_websocket(self):
73-
file = 'tongue_twister.wav'
74-
class MySynthesizeCallback(SynthesizeCallback):
75-
def __init__(self):
76-
SynthesizeCallback.__init__(self)
77-
self.fd = None
78-
self.error = None
79-
80-
def on_connected(self):
81-
self.fd = open(file, 'ab')
82-
83-
def on_error(self, error):
84-
self.error = error
85-
86-
def on_audio_stream(self, audio_stream):
87-
self.fd.write(audio_stream)
88-
89-
def on_close(self):
90-
self.fd.close()
91-
92-
test_callback = MySynthesizeCallback()
93-
self.text_to_speech.synthesize_using_websocket('She sells seashells by the seashore',
94-
test_callback,
95-
accept='audio/wav',
96-
voice='en-GB_KateVoice'
97-
)
98-
assert test_callback.error is None
99-
assert test_callback.fd is not None
100-
assert os.stat(file).st_size > 0
101-
os.remove(file)

watson_developer_cloud/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@
3131
from .discovery_v1 import DiscoveryV1
3232
from .version import __version__
3333
from .speech_to_text_v1_adapter import SpeechToTextV1Adapter as SpeechToTextV1
34-
from .text_to_speech_adapter_v1 import TextToSpeechV1Adapter as TextToSpeechV1
3534
from .visual_recognition_v3_adapter import VisualRecognitionV3Adapter as VisualRecognitionV3
3635
from .discovery_v1_adapter import DiscoveryV1Adapter as DiscoveryV1

0 commit comments

Comments
 (0)