Search code examples
google-cloud-platformgoogle-speech-to-text-api

Google Speech-to-Text: Cannot use Custom Classes


I am following the Google Docs to do Transcription jobs by providing it with a PhraseSet and CustomClass. From my understanding, the PhraseSet defines the kind of structures with the phrases that Google should expect. the CustomClass defines specific words in those phrases.

Example Phrase Set:

# Name: TextFriend
Items: [
 'Text my friend ${Name}', 'Write a message to ${Name}', 'Shoot a text to ${Name}'
]

Example Custom Class:

# Name: Name
Items: [
  'Kabena', 'Breagieszky', 'Sunni', 'Facebook', 'Bitbucket', 'GitHub'
]

When I try to create a transcription job, it fails with this error:

Error running recognize request. Invalid recognition 'config': Undefined custom class references. referenced class ids: Archwires. defined class ids: .

I doubled checked things and it all seems to be set up correctly. I did it through the GCP Console. Here's all the relevant resources:

Custom Class: Custom Class

Phrase Set: Phrase Set

Job Configuration: Job Configuration

I appreciate any help or insight to resolve this issue!


Solution

  • I figured out the problem.

    For those of you who land here, I found the solution by digging deeper into the code samples.

    Instead of just using the customClassId in your phrase, you need to use the full path.

    So:

    // Don't do this:
    Items: ['Shoot a text to ${Name}']
    
    // Do this:
    Items: ['Shoot a text to ${projects/0000/locations/global/customClasses/Name}']