Skip to content

Commit 57c8519

Browse files
committed
feat(Speech to Text): New param force in upgrade_acoustic_model
1 parent 5a12383 commit 57c8519

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

test/unit/test_speech_to_text_v1.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,29 @@ def test_acoustic_model():
297297

298298
assert len(responses.calls) == 6
299299

300+
@responses.activate
301+
def test_upgrade_acoustic_model():
302+
acoustic_customization_url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/acoustic_customizations'
303+
upgrade_url = "{0}/{1}/upgrade_model".format(acoustic_customization_url, 'customid')
304+
305+
responses.add(
306+
responses.POST,
307+
upgrade_url,
308+
body='{"bogus_response": "yep"}',
309+
status=200,
310+
content_type='application/json')
311+
312+
speech_to_text = watson_developer_cloud.SpeechToTextV1(
313+
username="username", password="password")
314+
315+
speech_to_text.upgrade_acoustic_model(
316+
'customid',
317+
'model_x',
318+
force=True)
319+
assert responses.calls[0].response.json() == {"bogus_response": "yep"}
320+
321+
assert len(responses.calls) == 1
322+
300323

301324
def test_custom_corpora():
302325

watson_developer_cloud/speech_to_text_v1.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,7 @@ def train_acoustic_model(self,
23062306
def upgrade_acoustic_model(self,
23072307
customization_id,
23082308
custom_language_model_id=None,
2309+
force=None,
23092310
**kwargs):
23102311
"""
23112312
Upgrade a custom acoustic model.
@@ -2339,7 +2340,15 @@ def upgrade_acoustic_model(self,
23392340
:param str custom_language_model_id: If the custom acoustic model was trained with
23402341
a custom language model, the customization ID (GUID) of that custom language
23412342
model. The custom language model must be upgraded before the custom acoustic model
2342-
can be upgraded.
2343+
can be upgraded. The credentials specified with the request must own both custom
2344+
models.
2345+
:param bool force: If `true`, forces the upgrade of a custom acoustic model for
2346+
which no input data has been modified since it was last trained. Use this
2347+
parameter only to force the upgrade of a custom acoustic model that is trained
2348+
with a custom language model, and only if you receive a 400 response code and the
2349+
message `No input data modified since last training`. See [Upgrading a custom
2350+
acoustic
2351+
model](https://cloud.ibm.com/docs/services/speech-to-text/custom-upgrade.html#upgradeAcoustic).
23432352
:param dict headers: A `dict` containing the request headers
23442353
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
23452354
:rtype: DetailedResponse
@@ -2351,8 +2360,13 @@ def upgrade_acoustic_model(self,
23512360
headers = {}
23522361
if 'headers' in kwargs:
23532362
headers.update(kwargs.get('headers'))
2363+
headers[
2364+
'X-IBMCloud-SDK-Analytics'] = 'service_name=speech_to_text;service_version=V1;operation_id=upgrade_acoustic_model'
23542365

2355-
params = {'custom_language_model_id': custom_language_model_id}
2366+
params = {
2367+
'custom_language_model_id': custom_language_model_id,
2368+
'force': force
2369+
}
23562370

23572371
url = '/v1/acoustic_customizations/{0}/upgrade_model'.format(
23582372
*self._encode_path_vars(customization_id))

0 commit comments

Comments
 (0)