Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
docs(samples): fixed model adaptation sample to correctly refer to cu…
Browse files Browse the repository at this point in the history
…stom classes (#246)

* fix: fixed model adaptation sample to correctly refer to custom classes

* fix: fixed model adaptation sample to correctly refer to custom classes
  • Loading branch information
b-loved-dreamer committed Sep 3, 2021
1 parent b0c5caf commit 5fa2433
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions samples/snippets/speech_model_adaptation_beta.py
Expand Up @@ -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,
Expand All @@ -47,15 +47,19 @@ 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(
{
"parent": parent,
"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}}}"}
],
},
}
)
Expand Down Expand Up @@ -88,4 +92,5 @@ def transcribe_with_model_adaptation(
print("Transcript: {}".format(result.alternatives[0].transcript))

# [END speech_transcribe_with_model_adaptation]

return response.results[0].alternatives[0].transcript

0 comments on commit 5fa2433

Please sign in to comment.