根据Microsoft文档,我们可以将Web-Chat组件配置为使用我们自己的自定义语音识别,如下所示
const speechOptions = {
speechRecognizer: new YourOwnSpeechRecognizer(),
speechSynthesizer: new YourOwnSpeechSynthesizer()
};
如何在JAVASCRIPT中实现“YourOwnSpeechRecognizer”?
这是你必须要做的事情: -
export interface ISpeechRecognizer {
locale: string;
isStreamingToService: boolean;
referenceGrammarId: string; // unique identifier to send to the speech implementation to bias SR to this scenario
onIntermediateResult: Func<string, void>;
onFinalResult: Func<string, void>;
onAudioStreamingToService: Action;
onRecognitionFailed: Action;
warmup(): void;
setGrammars(grammars?: string[]): void;
startRecognizing(): Promise<void>;
stopRecognizing(): Promise<void>;
speechIsAvailable(): boolean;
}
您必须提供自己的自定义语音识别,以实现ISpeechRecognizer。
希望能帮助到你。