Skip to content

Commit b1fb44a

Browse files
committed
feat(Speech to Text): New params grammar_name and redaction to recognize_using_websocket
1 parent c471d0d commit b1fb44a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

watson_developer_cloud/speech_to_text_v1_adapter.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def recognize_using_websocket(self,
4949
http_proxy_host=None,
5050
http_proxy_port=None,
5151
customization_id=None,
52+
grammar_name=None,
53+
redaction=None,
5254
**kwargs):
5355
"""
5456
Sends audio for speech recognition using web sockets.
@@ -149,6 +151,26 @@ def recognize_using_websocket(self,
149151
parameter to specify the customization ID (GUID) of a custom language model that
150152
is to be used with the recognition request. Do not specify both parameters with a
151153
request.
154+
:param str grammar_name: The name of a grammar that is to be used with the
155+
recognition request. If you specify a grammar, you must also use the
156+
`language_customization_id` parameter to specify the name of the custom language
157+
model for which the grammar is defined. The service recognizes only strings that
158+
are recognized by the specified grammar; it does not recognize other custom words
159+
from the model's words resource. See
160+
[Grammars](https://cloud.ibm.com/docs/services/speech-to-text/output.html).
161+
:param bool redaction: If `true`, the service redacts, or masks, numeric data from
162+
final transcripts. The feature redacts any number that has three or more
163+
consecutive digits by replacing each digit with an `X` character. It is intended
164+
to redact sensitive numeric data, such as credit card numbers. By default, the
165+
service performs no redaction.
166+
When you enable redaction, the service automatically enables smart formatting,
167+
regardless of whether you explicitly disable that feature. To ensure maximum
168+
security, the service also disables keyword spotting (ignores the `keywords` and
169+
`keywords_threshold` parameters) and returns only a single final transcript
170+
(forces the `max_alternatives` parameter to be `1`).
171+
**Note:** Applies to US English, Japanese, and Korean transcription only.
172+
See [Numeric
173+
redaction](https://cloud.ibm.com/docs/services/speech-to-text/output.html#redaction).
152174
:param dict headers: A `dict` containing the request headers
153175
:return: A `dict` containing the `SpeechRecognitionResults` response.
154176
:rtype: dict
@@ -188,6 +210,8 @@ def recognize_using_websocket(self,
188210
'customization_weight': customization_weight,
189211
'base_model_version': base_model_version,
190212
'language_customization_id': language_customization_id,
213+
'grammar_name': grammar_name,
214+
'redaction': redaction
191215
}
192216
params = _remove_null_values(params)
193217
url += '/v1/recognize?{0}'.format(urlencode(params))

0 commit comments

Comments
 (0)