From a1955b138d1f5bd7b1b8ea6ae4f3b978a83ed4c0 Mon Sep 17 00:00:00 2001 From: b-loved-dreamer Date: Thu, 2 Sep 2021 16:36:06 -0700 Subject: [PATCH 1/2] fix: fixed model adaptation sample to correctly refer to custom classes --- samples/snippets/speech_model_adaptation_beta.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/samples/snippets/speech_model_adaptation_beta.py b/samples/snippets/speech_model_adaptation_beta.py index 49fd4ad2..4f201f16 100644 --- a/samples/snippets/speech_model_adaptation_beta.py +++ b/samples/snippets/speech_model_adaptation_beta.py @@ -34,7 +34,7 @@ def transcribe_with_model_adaptation( parent = f"projects/{project_id}/locations/{location}" # Create the custom class resource - custom_class_response = adaptation_client.create_custom_class( + adaptation_client.create_custom_class( { "parent": parent, "custom_class_id": custom_class_id, @@ -47,7 +47,9 @@ def transcribe_with_model_adaptation( }, } ) - custom_class_name = custom_class_response.name + custom_class_name = ( + f"projects/{project_id}/locations/{location}/customClasses/{custom_class_id}" + ) # Create the phrase set resource phrase_set_response = adaptation_client.create_phrase_set( { @@ -55,7 +57,9 @@ def transcribe_with_model_adaptation( "phrase_set_id": phrase_set_id, "phrase_set": { "boost": 10, - "phrases": [{"value": f"Visit restaurants like ${custom_class_name}"}], + "phrases": [ + {"value": f"Visit restaurants like ${{{custom_class_name}}}"} + ], }, } ) @@ -81,11 +85,12 @@ def transcribe_with_model_adaptation( # Create the speech client speech_client = speech.SpeechClient() - + print("WE GOT TO THIS POINT...") response = speech_client.recognize(config=config, audio=audio) for result in response.results: print("Transcript: {}".format(result.alternatives[0].transcript)) # [END speech_transcribe_with_model_adaptation] + return response.results[0].alternatives[0].transcript From b081f431ab760437a3ebd3f0040943e7c95e4cc0 Mon Sep 17 00:00:00 2001 From: b-loved-dreamer Date: Thu, 2 Sep 2021 16:54:09 -0700 Subject: [PATCH 2/2] fix: fixed model adaptation sample to correctly refer to custom classes --- samples/snippets/speech_model_adaptation_beta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/speech_model_adaptation_beta.py b/samples/snippets/speech_model_adaptation_beta.py index 4f201f16..a3ac4e9d 100644 --- a/samples/snippets/speech_model_adaptation_beta.py +++ b/samples/snippets/speech_model_adaptation_beta.py @@ -85,7 +85,7 @@ def transcribe_with_model_adaptation( # Create the speech client speech_client = speech.SpeechClient() - print("WE GOT TO THIS POINT...") + response = speech_client.recognize(config=config, audio=audio) for result in response.results: