【问题标题】:Is it possible to limit SFSpeechRecognizer's vocabulary?是否可以限制 SFSpeechRecognizer 词汇?
【发布时间】:2020-07-17 01:01:57
【问题描述】:

我想使用 ios SFSpeechRecognizer 来识别一组封闭的单词和短语。有没有办法指定这些并消除所有其他可能性?我似乎找不到这样做的方法。

【问题讨论】:

    标签: ios speech-recognition speech-to-text sfspeechrecognizer


    【解决方案1】:

    我认为你不能限制SFSpeechRecognizer的词汇量,但只有当你想要的单词被识别时你才能触发动作。

    当你得到你的输出时,你可以尝试这样的事情:

    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
        }
    })
    

    【讨论】:

    • 那太糟糕了。我的意图是让某些词更有可能成为候选词,而不是忽略包含词汇外词的转录。
    • 你的意思是你想要一个包含“特殊”词的个人词汇表,比如“expecto palmum”?
    • 不,而且 SFSpeechRecognizer 在这样做方面做得很糟糕,即使它据称具有该功能。我的意思是,如果我可以控制他们用来识别单词的算法,假设他们有几个候选者作为一个结果,我想让一些候选者不存在。例如,识别器不擅长数学术语。 “N 个数字”却错误地将单词识别为我不关心的公司名称,而无法知道还有哪些其他选择。我认为没有办法在内部指导算法。就是这样。
    • 我明白了……这将非常有用,但我认为这是不可能的。不管怎样,你试过 SiriKit 吗? developer.apple.com/documentation/sirikit我没用过,但我记得我在某个地方读到过你可能有个人词汇的地方。
    • 不幸的是,它对我的​​目的不起作用。还是谢谢。
    【解决方案2】:

    您可以尝试使用 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"];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-11
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 2011-03-29
      • 2019-09-24
      相关资源
      最近更新 更多