Skip to content

Commit 1eae634

Browse files
committed
adding customization_id and switching from get to post in synthesize
1 parent 302c9b5 commit 1eae634

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/test_text_to_speech_v1.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ def test_success():
2626
assert responses.calls[0].response.text == voices_response
2727

2828
synthesize_text = 'hello'
29-
synthesize_url = 'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?text=' + \
30-
synthesize_text
29+
synthesize_url = 'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize'
3130
synthesize_response_body = '<binary response>'
3231

33-
responses.add(responses.GET, synthesize_url,
32+
responses.add(responses.POST, synthesize_url,
3433
body=synthesize_response_body, status=200,
3534
content_type='application/json', match_querystring=True)
3635
text_to_speech.synthesize(synthesize_text)

watson_developer_cloud/text_to_speech_v1.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ def __init__(self, url=default_url, username=None, password=None, use_vcap_servi
3232
WatsonDeveloperCloudService.__init__(
3333
self, 'text_to_speech', url, username, password, use_vcap_services)
3434

35-
def synthesize(self, text, voice=None, accept=None):
35+
def synthesize(self, text, voice=None, accept=None, customization_id=None):
3636
"""
3737
Returns the get HTTP response by doing a GET to /synthesize with text, voice, accept
3838
"""
39-
params = {'text': text, 'voice': voice, 'accept': accept}
39+
params = {'voice': voice, 'accept': accept, 'customization_id': customization_id}
40+
data = {'text': text}
4041
response = self.request(
41-
method='GET', url='/v1/synthesize', stream=True, params=params)
42+
method='POST', url='/v1/synthesize', stream=True, params=params, json=data)
4243
return response.content
4344

4445
def voices(self):

0 commit comments

Comments
 (0)