From 04a4754ce4b2e3514a66495cff2ace48c399de27 Mon Sep 17 00:00:00 2001 From: Angelo Paparazzi Date: Wed, 13 Mar 2024 13:03:39 -0500 Subject: [PATCH 1/2] fix(stt): change smartFormattingVersion to an int --- ibm_watson/speech_to_text_v1.py | 16 ++++++++-------- test/unit/test_speech_to_text_v1.py | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ibm_watson/speech_to_text_v1.py b/ibm_watson/speech_to_text_v1.py index f6d1022b..c1b3be1f 100644 --- a/ibm_watson/speech_to_text_v1.py +++ b/ibm_watson/speech_to_text_v1.py @@ -209,7 +209,7 @@ def recognize( timestamps: Optional[bool] = None, profanity_filter: Optional[bool] = None, smart_formatting: Optional[bool] = None, - smart_formatting_version: Optional[bool] = None, + smart_formatting_version: Optional[int] = None, speaker_labels: Optional[bool] = None, grammar_name: Optional[str] = None, redaction: Optional[bool] = None, @@ -447,9 +447,9 @@ def recognize( (all dialects) transcription only. See [Smart formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). - :param bool smart_formatting_version: (optional) Smart formatting version - is for next-generation models and that is supported in US English, - Brazilian Portuguese, French and German languages. + :param int smart_formatting_version: (optional) Smart formatting version is + for next-generation models and that is supported in US English, Brazilian + Portuguese, French and German languages. :param bool speaker_labels: (optional) If `true`, the response includes labels that identify which words were spoken by which participants in a multi-person exchange. By default, the service returns no speaker labels. @@ -818,7 +818,7 @@ def create_job( timestamps: Optional[bool] = None, profanity_filter: Optional[bool] = None, smart_formatting: Optional[bool] = None, - smart_formatting_version: Optional[bool] = None, + smart_formatting_version: Optional[int] = None, speaker_labels: Optional[bool] = None, grammar_name: Optional[str] = None, redaction: Optional[bool] = None, @@ -1106,9 +1106,9 @@ def create_job( (all dialects) transcription only. See [Smart formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). - :param bool smart_formatting_version: (optional) Smart formatting version - is for next-generation models and that is supported in US English, - Brazilian Portuguese, French and German languages. + :param int smart_formatting_version: (optional) Smart formatting version is + for next-generation models and that is supported in US English, Brazilian + Portuguese, French and German languages. :param bool speaker_labels: (optional) If `true`, the response includes labels that identify which words were spoken by which participants in a multi-person exchange. By default, the service returns no speaker labels. diff --git a/test/unit/test_speech_to_text_v1.py b/test/unit/test_speech_to_text_v1.py index 922c7815..30475296 100644 --- a/test/unit/test_speech_to_text_v1.py +++ b/test/unit/test_speech_to_text_v1.py @@ -237,7 +237,7 @@ def test_recognize_all_params(self): timestamps = False profanity_filter = True smart_formatting = False - smart_formatting_version = False + smart_formatting_version = 0 speaker_labels = False grammar_name = 'testString' redaction = False @@ -299,7 +299,7 @@ def test_recognize_all_params(self): assert 'timestamps={}'.format('true' if timestamps else 'false') in query_string assert 'profanity_filter={}'.format('true' if profanity_filter else 'false') in query_string assert 'smart_formatting={}'.format('true' if smart_formatting else 'false') in query_string - assert 'smart_formatting_version={}'.format('true' if smart_formatting_version else 'false') in query_string + assert 'smart_formatting_version={}'.format(smart_formatting_version) in query_string assert 'speaker_labels={}'.format('true' if speaker_labels else 'false') in query_string assert 'grammar_name={}'.format(grammar_name) in query_string assert 'redaction={}'.format('true' if redaction else 'false') in query_string @@ -657,7 +657,7 @@ def test_create_job_all_params(self): timestamps = False profanity_filter = True smart_formatting = False - smart_formatting_version = False + smart_formatting_version = 0 speaker_labels = False grammar_name = 'testString' redaction = False @@ -731,7 +731,7 @@ def test_create_job_all_params(self): assert 'timestamps={}'.format('true' if timestamps else 'false') in query_string assert 'profanity_filter={}'.format('true' if profanity_filter else 'false') in query_string assert 'smart_formatting={}'.format('true' if smart_formatting else 'false') in query_string - assert 'smart_formatting_version={}'.format('true' if smart_formatting_version else 'false') in query_string + assert 'smart_formatting_version={}'.format(smart_formatting_version) in query_string assert 'speaker_labels={}'.format('true' if speaker_labels else 'false') in query_string assert 'grammar_name={}'.format(grammar_name) in query_string assert 'redaction={}'.format('true' if redaction else 'false') in query_string From f49d91e6a9c0ecd71cb3dfb173f6dcc1c436d9bf Mon Sep 17 00:00:00 2001 From: Angelo Paparazzi Date: Wed, 13 Mar 2024 13:06:45 -0500 Subject: [PATCH 2/2] fix(wss): add smartFormattingVersion param --- ibm_watson/speech_to_text_v1_adapter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ibm_watson/speech_to_text_v1_adapter.py b/ibm_watson/speech_to_text_v1_adapter.py index 5b0fa08d..fedc5af5 100644 --- a/ibm_watson/speech_to_text_v1_adapter.py +++ b/ibm_watson/speech_to_text_v1_adapter.py @@ -42,6 +42,7 @@ def recognize_using_websocket(self, timestamps=None, profanity_filter=None, smart_formatting=None, + smart_formatting_version=None, speaker_labels=None, http_proxy_host=None, http_proxy_port=None, @@ -175,6 +176,9 @@ def recognize_using_websocket(self, **Note:** Applies to US English, Japanese, and Spanish transcription only. See [Smart formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). + :param int smart_formatting_version: (optional) Smart formatting version is + for next-generation models and that is supported in US English, Brazilian + Portuguese, French and German languages. :param bool speaker_labels: (optional) If `true`, the response includes labels that identify which words were spoken by which participants in a multi-person exchange. By default, the service returns no speaker labels. @@ -360,6 +364,7 @@ def recognize_using_websocket(self, 'timestamps': timestamps, 'profanity_filter': profanity_filter, 'smart_formatting': smart_formatting, + 'smart_formatting_version': smart_formatting_version, 'speaker_labels': speaker_labels, 'grammar_name': grammar_name, 'redaction': redaction,