语音转文本的短语列表Phrase Lists for speech-to-text

可以通过提供带短语列表的语音服务,改进语音识别的准确度。By providing the Speech service with a list of phrases, you can improve the accuracy of speech recognition. 短语列表用于标识音频数据中的已知短语,如人的姓名或特定位置。Phrase Lists are used to identify known phrases in audio data, like a person's name or a specific location.

例如,如果命令为“Move to”,可能的目标为可以说出来的“Ward”,则可添加条目“Move to Ward”。As an example, if you have a command "Move to" and a possible destination of "Ward" that may be spoken, you can add an entry of "Move to Ward". 添加短语以后,在识别该音频时,将其识别成“Move to Ward”而不是“Move toward”的可能性就会增加。Adding a phrase will increase the probability that when the audio is recognized that "Move to Ward" will be recognized instead of "Move toward".

可以将单个词或完整短语添加到短语列表。Single words or complete phrases can be added to a Phrase List. 在识别过程中,如果音频中包含与整个短语完全匹配的单独短语,则使用短语列表中的一个条目。During recognition, an entry in a phrase list is used if an exact match for the entire phrase is included in the audio as a separate phrase. 如果找不到与短语完全匹配的项,则不支持识别。If an exact match to the phrase is not found, recognition is not assisted.

备注

目前,短语列表仅支持英语版语音转文本。Currently, Phrase Lists supports only English for speech-to-text.

如何使用短语列表How to use Phrase Lists

以下示例演示了如何使用 PhraseListGrammar 对象构建短语列表。The samples below illustrate how to build a Phrase List using the PhraseListGrammar object.

PhraseListGrammar phraseList = PhraseListGrammar.FromRecognizer(recognizer);
phraseList.AddPhrase("Move to Ward");
phraseList.AddPhrase("Move to Bill");
phraseList.AddPhrase("Move to Ted");
auto phraselist = PhraseListGrammar::FromRecognizer(recognizer);
phraselist->AddPhrase("Move to Ward");
phraselist->AddPhrase("Move to Bill");
phraselist->AddPhrase("Move to Ted");
PhraseListGrammar phraseListGrammar = PhraseListGrammar.fromRecognizer(recognizer);
phraseListGrammar.addPhrase("Move to Ward");
phraseListGrammar.addPhrase("Move to Bill");
phraseListGrammar.addPhrase("Move to Ted");
phrase_list_grammar = speechsdk.PhraseListGrammar.from_recognizer(reco)
phrase_list_grammar.addPhrase("Move to Ward")
phrase_list_grammar.addPhrase("Move to Bill")
phrase_list_grammar.addPhrase("Move to Ted")
var phraseListGrammar = SpeechSDK.PhraseListGrammar.fromRecognizer(reco);
phraseListGrammar.addPhrase("Move to Ward");
phraseListGrammar.addPhrase("Move to Bill");
phraseListGrammar.addPhrase("Move to Ted");

备注

语音服务用于匹配语音的短语列表的最大数目为 1024 个短语。The maximum number of Phrase Lists that the Speech service will use to match speech is 1024 phrases.

也可通过调用 clear() 来清理与 PhraseListGrammar 关联的短语。You can also clear the phrases associated with the PhraseListGrammar by calling clear().

phraseList.Clear();
phraselist->Clear();
phraseListGrammar.clear();
phrase_list_grammar.clear()
phraseListGrammar.clear();

备注

PhraseListGrammar 对象的更改会在下次识别时生效,或者会在重新连接到语音服务后生效。Changes to a PhraseListGrammar object take effect on the next recognition or following a reconnection to the Speech service.

后续步骤Next steps