Skip to content

Commit d6f9c5d

Browse files
fix(tts): remove extraneous filename param
1 parent cd1dadf commit d6f9c5d

File tree

2 files changed

+3
-58
lines changed

2 files changed

+3
-58
lines changed

ibm_watson/text_to_speech_v1.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"""
3939

4040
from enum import Enum
41-
from os.path import basename
4241
from typing import BinaryIO, Dict, List
4342
import json
4443

@@ -1061,13 +1060,8 @@ def list_custom_prompts(self, customization_id: str,
10611060
response = self.send(request)
10621061
return response
10631062

1064-
def add_custom_prompt(self,
1065-
customization_id: str,
1066-
prompt_id: str,
1067-
metadata: 'PromptMetadata',
1068-
file: BinaryIO,
1069-
*,
1070-
filename: str = None,
1063+
def add_custom_prompt(self, customization_id: str, prompt_id: str,
1064+
metadata: 'PromptMetadata', file: BinaryIO,
10711065
**kwargs) -> DetailedResponse:
10721066
"""
10731067
Add a custom prompt.
@@ -1166,7 +1160,6 @@ def add_custom_prompt(self,
11661160
rate of 16 kHz. The service accepts audio with higher sampling rates. The
11671161
service transcodes all audio to 16 kHz before processing it.
11681162
* The length of the prompt audio is limited to 30 seconds.
1169-
:param str filename: (optional) The filename for file.
11701163
:param dict headers: A `dict` containing the request headers
11711164
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
11721165
:rtype: DetailedResponse with `dict` result representing a `Prompt` object
@@ -1189,11 +1182,7 @@ def add_custom_prompt(self,
11891182
form_data = []
11901183
form_data.append(
11911184
('metadata', (None, json.dumps(metadata), 'application/json')))
1192-
if not filename and hasattr(file, 'name'):
1193-
filename = basename(file.name)
1194-
if not filename:
1195-
raise ValueError('filename must be provided')
1196-
form_data.append(('file', (filename, file, 'audio/wav')))
1185+
form_data.append(('file', (None, file, 'audio/wav')))
11971186

11981187
if 'headers' in kwargs:
11991188
headers.update(kwargs.get('headers'))

test/unit/test_text_to_speech_v1.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,56 +1319,13 @@ def test_add_custom_prompt_all_params(self):
13191319
prompt_id = 'testString'
13201320
metadata = prompt_metadata_model
13211321
file = io.BytesIO(b'This is a mock file.').getvalue()
1322-
filename = 'testString'
13231322

13241323
# Invoke method
13251324
response = _service.add_custom_prompt(
13261325
customization_id,
13271326
prompt_id,
13281327
metadata,
13291328
file,
1330-
filename=filename,
1331-
headers={}
1332-
)
1333-
1334-
# Check for correct operation
1335-
assert len(responses.calls) == 1
1336-
assert response.status_code == 201
1337-
1338-
1339-
@responses.activate
1340-
def test_add_custom_prompt_required_params(self):
1341-
"""
1342-
test_add_custom_prompt_required_params()
1343-
"""
1344-
# Set up mock
1345-
url = self.preprocess_url(_base_url + '/v1/customizations/testString/prompts/testString')
1346-
mock_response = '{"prompt": "prompt", "prompt_id": "prompt_id", "status": "status", "error": "error", "speaker_id": "speaker_id"}'
1347-
responses.add(responses.POST,
1348-
url,
1349-
body=mock_response,
1350-
content_type='application/json',
1351-
status=201)
1352-
1353-
# Construct a dict representation of a PromptMetadata model
1354-
prompt_metadata_model = {}
1355-
prompt_metadata_model['prompt_text'] = 'testString'
1356-
prompt_metadata_model['speaker_id'] = 'testString'
1357-
1358-
# Set up parameter values
1359-
customization_id = 'testString'
1360-
prompt_id = 'testString'
1361-
metadata = prompt_metadata_model
1362-
file = io.BytesIO(b'This is a mock file.').getvalue()
1363-
filename = 'testString'
1364-
1365-
# Invoke method
1366-
response = _service.add_custom_prompt(
1367-
customization_id,
1368-
prompt_id,
1369-
metadata,
1370-
file,
1371-
filename=filename,
13721329
headers={}
13731330
)
13741331

@@ -1401,7 +1358,6 @@ def test_add_custom_prompt_value_error(self):
14011358
prompt_id = 'testString'
14021359
metadata = prompt_metadata_model
14031360
file = io.BytesIO(b'This is a mock file.').getvalue()
1404-
filename = 'testString'
14051361

14061362
# Pass in all but one required param and check for a ValueError
14071363
req_param_dict = {

0 commit comments

Comments
 (0)