Skip to content

Commit 061cb4f

Browse files
jameszhao00telpirion
authored andcommitted
Update speech_model_adaptation_beta.py
chore: fix model adaptation sample to actually use the resource
1 parent ce9bf4d commit 061cb4f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

speech/snippets/speech_model_adaptation_beta.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def transcribe_with_model_adaptation(
3333
# The parent resource where the custom class and phrase set will be created.
3434
parent = f"projects/{project_id}/locations/{location}"
3535

36-
# Create the custom class
36+
# Create the custom class resource
3737
custom_class_response = adaptation_client.create_custom_class(
3838
{
3939
"parent": parent,
@@ -47,25 +47,25 @@ def transcribe_with_model_adaptation(
4747
},
4848
}
4949
)
50-
51-
# Create the phrase set
50+
custom_class_name = custom_class_response.name
51+
# Create the phrase set resource
5252
phrase_set_response = adaptation_client.create_phrase_set(
5353
{
5454
"parent": parent,
5555
"phrase_set_id": phrase_set_id,
5656
"phrase_set": {
5757
"boost": 10,
58-
"phrases": [{"value": f"Visit restaurants like ${custom_class_id}"}],
58+
"phrases": [{"value": f"Visit restaurants like ${custom_class_name}"}],
5959
},
6060
}
6161
)
62-
62+
phrase_set_name = phrase_set_response.name
6363
# The next section shows how to use the newly created custom
6464
# class and phrase set to send a transcription request with speech adaptation
6565

6666
# Speech adaptation configuration
6767
speech_adaptation = speech.SpeechAdaptation(
68-
phrase_sets=[phrase_set_response], custom_classes=[custom_class_response]
68+
phrase_set_references=[phrase_set_name]
6969
)
7070

7171
# speech configuration object

0 commit comments

Comments
 (0)