@@ -33,7 +33,7 @@ def transcribe_with_model_adaptation(
33
33
# The parent resource where the custom class and phrase set will be created.
34
34
parent = f"projects/{ project_id } /locations/{ location } "
35
35
36
- # Create the custom class
36
+ # Create the custom class resource
37
37
custom_class_response = adaptation_client .create_custom_class (
38
38
{
39
39
"parent" : parent ,
@@ -47,25 +47,25 @@ def transcribe_with_model_adaptation(
47
47
},
48
48
}
49
49
)
50
-
51
- # Create the phrase set
50
+ custom_class_name = custom_class_response . name
51
+ # Create the phrase set resource
52
52
phrase_set_response = adaptation_client .create_phrase_set (
53
53
{
54
54
"parent" : parent ,
55
55
"phrase_set_id" : phrase_set_id ,
56
56
"phrase_set" : {
57
57
"boost" : 10 ,
58
- "phrases" : [{"value" : f"Visit restaurants like ${ custom_class_id } " }],
58
+ "phrases" : [{"value" : f"Visit restaurants like ${ custom_class_name } " }],
59
59
},
60
60
}
61
61
)
62
-
62
+ phrase_set_name = phrase_set_response . name
63
63
# The next section shows how to use the newly created custom
64
64
# class and phrase set to send a transcription request with speech adaptation
65
65
66
66
# Speech adaptation configuration
67
67
speech_adaptation = speech .SpeechAdaptation (
68
- phrase_sets = [ phrase_set_response ], custom_classes = [ custom_class_response ]
68
+ phrase_set_references = [ phrase_set_name ]
69
69
)
70
70
71
71
# speech configuration object
0 commit comments