Improve recognition accuracy with phrase list

A phrase list is a list of words or phrases provided ahead of time to help improve their recognition. Adding a phrase to a phrase list increases its importance, thus making it more likely to be recognized.

For supported phrase list locales, see Language and voice support for the Speech service.

Examples of phrases include:

  • Names
  • Geographical locations
  • Homonyms
  • Words or acronyms unique to your industry or organization

Phrase lists are simple and lightweight:

  • Just-in-time: A phrase list is provided just before starting the speech recognition, eliminating the need to train a custom model.
  • Lightweight: You don't need a large data set. Provide a word or phrase to boost its recognition.

You can use phrase lists with the Speech Studio, Speech SDK, or Speech Command Line Interface (CLI). The Batch transcription API doesn't support phrase lists.

You can use phrase lists with both standard and custom speech. There are some situations where training a custom model that includes phrases is likely the best option to improve accuracy. For example, in the following cases you would use custom speech:

  • If you need to use a large list of phrases. A phrase list shouldn't have more than 500 phrases.
  • If you need a phrase list for languages that aren't currently supported.

Try it in Speech Studio

You can use Speech Studio to test how phrase list would help improve recognition for your audio. To implement a phrase list with your application in production, you use the Speech SDK or Speech CLI.

For example, let's say that you want the Speech service to recognize this sentence: "Hi Rehaan, I'm Jessie from Contoso bank."

You might find that a phrase is incorrectly recognized as: "Hi everyone, I'm Jesse from can't do so bank."

In the previous scenario, you would want to add "Rehaan", "Jessie", and "Contoso" to your phrase list. Then the names should be recognized correctly.

Now try Speech Studio to see how phrase list can improve recognition accuracy.

Note

You may be prompted to select your Azure subscription and Speech resource, and then acknowledge billing for your region.

  1. Go to Real-time Speech to text in Speech Studio.
  2. You test speech recognition by uploading an audio file or recording audio with a microphone. For example, select record audio with a microphone and then say "Hi Rehaan, I'm Jessie from Contoso bank. " Then select the red button to stop recording.
  3. You should see the transcription result in the Test results text box. If "Rehaan", "Jessie", or "Contoso" were recognized incorrectly, you can add the terms to a phrase list in the next step.
  4. Select Show advanced options and turn on Phrase list.
  5. Enter "Contoso;Jessie;Rehaan" in the phrase list text box. Multiple phrases need to be separated by a semicolon. Screenshot of a phrase list applied in Speech Studio.
  6. Use the microphone to test recognition again. Otherwise you can select the retry arrow next to your audio file to re-run your audio. The terms "Rehaan", "Jessie", or "Contoso" should be recognized.

Implement phrase list

With the Speech SDK you can add phrases individually and then run speech recognition.

var phraseList = PhraseListGrammar.FromRecognizer(recognizer);
phraseList.AddPhrase("Contoso");
phraseList.AddPhrase("Jessie");
phraseList.AddPhrase("Rehaan");

With the Speech SDK you can add phrases individually and then run speech recognition.

auto phraseListGrammar = PhraseListGrammar::FromRecognizer(recognizer);
phraseListGrammar->AddPhrase("Contoso");
phraseListGrammar->AddPhrase("Jessie");
phraseListGrammar->AddPhrase("Rehaan");

With the Speech SDK you can add phrases individually and then run speech recognition.

PhraseListGrammar phraseList = PhraseListGrammar.fromRecognizer(recognizer);
phraseList.addPhrase("Contoso");
phraseList.addPhrase("Jessie");
phraseList.addPhrase("Rehaan");

With the Speech SDK you can add phrases individually and then run speech recognition.

const phraseList = sdk.PhraseListGrammar.fromRecognizer(recognizer);
phraseList.addPhrase("Contoso");
phraseList.addPhrase("Jessie");
phraseList.addPhrase("Rehaan");

With the Speech SDK you can add phrases individually and then run speech recognition.

phrase_list_grammar = speechsdk.PhraseListGrammar.from_recognizer(reco)
phrase_list_grammar.addPhrase("Contoso")
phrase_list_grammar.addPhrase("Jessie")
phrase_list_grammar.addPhrase("Rehaan")

With the Speech CLI you can include a phrase list in-line or with a text file along with the recognize command.

Try recognition from a microphone or an audio file.

spx recognize --microphone --phrases "Contoso;Jessie;Rehaan;"
spx recognize --file "your\path\to\audio.wav" --phrases "Contoso;Jessie;Rehaan;"

You can also add a phrase list using a text file that contains one phrase per line.

spx recognize --microphone --phrases @phrases.txt
spx recognize --file "your\path\to\audio.wav" --phrases @phrases.txt

Allowed characters include locale-specific letters and digits, white space characters, and special characters such as +, -, $, :, (, ), {, }, _, ., ?, @, \, ’, &, #, %, ^, *, `, <, >, ;, /. Other special characters are removed internally from the phrase.

Next steps

Check out more options to improve recognition accuracy.