Skip to content

Commit 1b5f171

Browse files
feat(wss): add and remove websocket params
1 parent 069bba3 commit 1b5f171

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

ibm_watson/speech_to_text_v1_adapter.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def recognize_using_websocket(self,
4545
speaker_labels=None,
4646
http_proxy_host=None,
4747
http_proxy_port=None,
48-
customization_id=None,
4948
grammar_name=None,
5049
redaction=None,
5150
processing_metrics=None,
@@ -56,6 +55,7 @@ def recognize_using_websocket(self,
5655
speech_detector_sensitivity=None,
5756
background_audio_suppression=None,
5857
low_latency=None,
58+
character_insertion_bias: float = None,
5959
**kwargs):
6060
"""
6161
Sends audio for speech recognition using web sockets.
@@ -190,10 +190,6 @@ def recognize_using_websocket(self,
190190
labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speaker-labels).
191191
:param str http_proxy_host: http proxy host name.
192192
:param str http_proxy_port: http proxy port. If not set, set to 80.
193-
:param str customization_id: (optional) **Deprecated.** Use the
194-
`language_customization_id` parameter to specify the customization ID
195-
(GUID) of a custom language model that is to be used with the recognition
196-
request. Do not specify both parameters with a request.
197193
:param str grammar_name: (optional) The name of a grammar that is to be
198194
used with the recognition request. If you specify a grammar, you must also
199195
use the `language_customization_id` parameter to specify the name of the
@@ -287,6 +283,28 @@ def recognize_using_websocket(self,
287283
for next-generation models.
288284
* For more information about the `low_latency` parameter, see [Low
289285
latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency).
286+
:param float character_insertion_bias: (optional) For next-generation
287+
`Multimedia` and `Telephony` models, an indication of whether the service
288+
is biased to recognize shorter or longer strings of characters when
289+
developing transcription hypotheses. By default, the service is optimized
290+
for each individual model to balance its recognition of strings of
291+
different lengths. The model-specific bias is equivalent to 0.0.
292+
The value that you specify represents a change from a model's default bias.
293+
The allowable range of values is -1.0 to 1.0.
294+
* Negative values bias the service to favor hypotheses with shorter strings
295+
of characters.
296+
* Positive values bias the service to favor hypotheses with longer strings
297+
of characters.
298+
As the value approaches -1.0 or 1.0, the impact of the parameter becomes
299+
more pronounced. To determine the most effective value for your scenario,
300+
start by setting the value of the parameter to a small increment, such as
301+
-0.1, -0.05, 0.05, or 0.1, and assess how the value impacts the
302+
transcription results. Then experiment with different values as necessary,
303+
adjusting the value by small increments.
304+
The parameter is not available for previous-generation `Broadband` and
305+
`Narrowband` models.
306+
See [Character insertion
307+
bias](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#insertion-bias).
290308
:param dict headers: A `dict` containing the request headers
291309
:return: A `dict` containing the `SpeechRecognitionResults` response.
292310
:rtype: dict
@@ -321,7 +339,6 @@ def recognize_using_websocket(self,
321339

322340
params = {
323341
'model': model,
324-
'customization_id': customization_id,
325342
'acoustic_customization_id': acoustic_customization_id,
326343
'base_model_version': base_model_version,
327344
'language_customization_id': language_customization_id
@@ -353,7 +370,8 @@ def recognize_using_websocket(self,
353370
'split_transcript_at_phrase_end': split_transcript_at_phrase_end,
354371
'speech_detector_sensitivity': speech_detector_sensitivity,
355372
'background_audio_suppression': background_audio_suppression,
356-
'low_latency': low_latency
373+
'low_latency': low_latency,
374+
'character_insertion_bias': character_insertion_bias
357375
}
358376
options = {k: v for k, v in options.items() if v is not None}
359377
request['options'] = options

ibm_watson/text_to_speech_adapter_v1.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def synthesize_using_websocket(self,
3030
voice=None,
3131
timings=None,
3232
customization_id=None,
33+
spell_out_mode: str = None,
3334
http_proxy_host=None,
3435
http_proxy_port=None,
3536
**kwargs):
@@ -60,6 +61,21 @@ def synthesize_using_websocket(self,
6061
If you include a customization ID, you must call the method with the service credentials of the custom model's owner. Omit the
6162
parameter to use the specified voice with no customization. For more information, see [Understanding customization]
6263
(https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro).
64+
:param str spell_out_mode: (optional) *For German voices,* indicates how
65+
the service is to spell out strings of individual letters. To indicate the
66+
pace of the spelling, specify one of the following values:
67+
* `default` - The service reads the characters at the rate at which it
68+
synthesizes speech for the request. You can also omit the parameter
69+
entirely to achieve the default behavior.
70+
* `singles` - The service reads the characters one at a time, with a brief
71+
pause between each character.
72+
* `pairs` - The service reads the characters two at a time, with a brief
73+
pause between each pair.
74+
* `triples` - The service reads the characters three at a time, with a
75+
brief pause between each triplet.
76+
The parameter is available only for IBM Cloud.
77+
**See also:** [Specifying how strings are spelled
78+
out](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-synthesis-params#params-spell-out-mode).
6379
:param str http_proxy_host: http proxy host name.
6480
:param str http_proxy_port: http proxy port. If not set, set to 80.
6581
:param dict headers: A `dict` containing the request headers
@@ -90,6 +106,7 @@ def synthesize_using_websocket(self,
90106
params = {
91107
'voice': voice,
92108
'customization_id': customization_id,
109+
'spell_out_mode': spell_out_mode
93110
}
94111
params = {k: v for k, v in params.items() if v is not None}
95112
url += '/v1/synthesize?{0}'.format(urlencode(params))

0 commit comments

Comments
 (0)