Skip to content

Commit 133b863

Browse files
b-loved-dreamertelpirion
authored andcommitted
docs(samples): fixed model adaptation sample to correctly refer to custom classes (#246)
* fix: fixed model adaptation sample to correctly refer to custom classes * fix: fixed model adaptation sample to correctly refer to custom classes
1 parent 955f64a commit 133b863

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

speech/snippets/speech_model_adaptation_beta.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def transcribe_with_model_adaptation(
3434
parent = f"projects/{project_id}/locations/{location}"
3535

3636
# Create the custom class resource
37-
custom_class_response = adaptation_client.create_custom_class(
37+
adaptation_client.create_custom_class(
3838
{
3939
"parent": parent,
4040
"custom_class_id": custom_class_id,
@@ -47,15 +47,19 @@ def transcribe_with_model_adaptation(
4747
},
4848
}
4949
)
50-
custom_class_name = custom_class_response.name
50+
custom_class_name = (
51+
f"projects/{project_id}/locations/{location}/customClasses/{custom_class_id}"
52+
)
5153
# Create the phrase set resource
5254
phrase_set_response = adaptation_client.create_phrase_set(
5355
{
5456
"parent": parent,
5557
"phrase_set_id": phrase_set_id,
5658
"phrase_set": {
5759
"boost": 10,
58-
"phrases": [{"value": f"Visit restaurants like ${custom_class_name}"}],
60+
"phrases": [
61+
{"value": f"Visit restaurants like ${{{custom_class_name}}}"}
62+
],
5963
},
6064
}
6165
)
@@ -88,4 +92,5 @@ def transcribe_with_model_adaptation(
8892
print("Transcript: {}".format(result.alternatives[0].transcript))
8993

9094
# [END speech_transcribe_with_model_adaptation]
95+
9196
return response.results[0].alternatives[0].transcript

0 commit comments

Comments
 (0)