OpenEarsの入力音声のレベルを調整する

OpenEarsは、一定時間静音があったときに検知を終了する、という仕組みなので、音楽を流していたり屋外だったりするとずっと認識し続けてうまく機能してくれなくなってしまう。

ということでその対処法として、Inputのlevelをもう少し下げて騒音で反応しないようにしたいと思ってやってみたので、メモしておきます。

以下の記事ですごく参考になりそうなことが言及されてた。

  • [Resolved] Noise problem even setting setVadThreshold openEars 2.0

http://www.politepix.com/forums/topic/noise-problem-even-setting-setvadthreshold-openears-2-0/

  • openEars detect the word without speaking it

http://www.politepix.com/forums/topic/openears-detect-the-word-without-speaking-it/

どうやらsetSecondsOfSilenceToDetectvadThresholdの値をいじれば少しは調整できそうだ。

setSecondsofSilenceToDetectは以下のように説明されている。

This is how long OEPcoketsphinxController should wait after speech ends to attempt to recognize speech. This defaults to .7 seconds.

そしてvadThreshldは以下。

Speech/Silence threshhold setting. You may not need to make any changes to this, however, if you are experiencing quiet background noises triggering speech recognition, you can raise this to a value from 2-5 to 3.5 for the English acoustic model, and between 3.0 and 4.5 for the Spanish acoustic model. If you are experiencing too many words being ignored you can reduce this. The maximum value is 5.0 and the minimum is .5. For the English model, values less than 1.5 or more than 3.5 are likely to lead to poor results. For the Spanish model, higher values can be used. Please test any changes here carefully to see what effect they have on your user experience.*/

ということでこの二つの値を変えて試してみる。

        [[OEPocketsphinxController sharedInstance] setSecondsOfSilenceToDetect:0.2];
        [[OEPocketsphinxController sharedInstance] setVadThreshold:3.0];

なぜか何回もスタートするメソッドが呼ばれて2回目以降呼ばれると止まってしまうので、今スタートしてるかどうか検出してから認識をかいし

        NSLog([[OEPocketsphinxController sharedInstance] isListening] ? @"NOW LISTENING" : @"NOT listening");
        if (![[OEPocketsphinxController sharedInstance] isListening]) {
            [[OEPocketsphinxController sharedInstance] setActive:TRUE error:nil];
            [[OEPocketsphinxController sharedInstance] startListeningWithLanguageModelAtPath:lmPath dictionaryAtPath:dicPath acousticModelAtPath:[OEAcousticModel pathToModel:@"AcousticModelEnglish"] languageModelIsJSGF: NO]; // start listening
        }

ということでsetVadThresholdを3.0~3.5くらいにすると騒音を拾わずだいぶいい感じに認識してくれるようになりました〜。

もうだめかと思ったけど頑張って調べてよかったw