簡體   English   中英

是否可以限制 SFSpeechRecognizer 的詞匯量?

[英]Is it possible to limit SFSpeechRecognizer's vocabulary?

我想使用 ios SFSpeechRecognizer來識別一組封閉的單詞和短語。 有沒有辦法指定這些並消除所有其他可能性? 我似乎找不到辦法做到這一點。

我認為你不能限制SFSpeechRecognizer的詞匯量,但只有當你想要的單詞被識別時你才能觸發動作。

當您獲得 output 時,您可以嘗試以下操作:

self.recognitionTask = speechRecognizer?.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in
    if result == "Desired word one" {
        // Do something
    } else if result == "Desired word two" {
        // Do something else
    } else {
        // Don't do anything
    }
})

您可以嘗試使用SFSpeechAudioBufferRecognitionRequestcontextualStrings屬性設置高優先級或設置一些不在詞匯表中的單詞。 有關更多信息,請查看此處: https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/1649391-contextualstrings?language=objc

  SFSpeechAudioBufferRecognitionRequest *recognitionRequest = [[SFSpeechAudioBufferRecognitionRequest alloc] init];
    recognitionRequest.contextualStrings = @[@"Your specific word", @"short custom phrases that are unique to your app"];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM