diff --git a/examples/Android/SnowboyAlexaDemo/src/ai/kitt/snowboy/audio/RecordingThread.java b/examples/Android/SnowboyAlexaDemo/src/ai/kitt/snowboy/audio/RecordingThread.java index 793c4f36..850e955a 100644 --- a/examples/Android/SnowboyAlexaDemo/src/ai/kitt/snowboy/audio/RecordingThread.java +++ b/examples/Android/SnowboyAlexaDemo/src/ai/kitt/snowboy/audio/RecordingThread.java @@ -41,7 +41,7 @@ public RecordingThread(Handler handler, AudioDataReceivedListener listener) { this.listener = listener; detector.SetSensitivity("0.6"); - //-detector.SetAudioGain(1); + detector.SetAudioGain(1); detector.ApplyFrontend(true); try { player.setDataSource(strEnvWorkSpace+"ding.wav"); diff --git a/examples/C++/demo.cc b/examples/C++/demo.cc index 0f5cd1ef..330e6ffa 100644 --- a/examples/C++/demo.cc +++ b/examples/C++/demo.cc @@ -207,11 +207,13 @@ int main(int argc, char* argv[]) { std::string model_filename = "resources/models/snowboy.umdl"; std::string sensitivity_str = "0.5"; float audio_gain = 1; + bool apply_frontend = false; // Initializes Snowboy detector. snowboy::SnowboyDetect detector(resource_filename, model_filename); detector.SetSensitivity(sensitivity_str); detector.SetAudioGain(audio_gain); + detector.ApplyFrontend(apply_frontend); // Initializes PortAudio. You may use other tools to capture the audio. PortAudioWrapper pa_wrapper(detector.SampleRate(), diff --git a/examples/C++/demo2.cc b/examples/C++/demo2.cc index ed74f728..64a17e6e 100644 --- a/examples/C++/demo2.cc +++ b/examples/C++/demo2.cc @@ -5,6 +5,8 @@ #define resource_filename "resources/common.res" #define model_filename "resources/models/snowboy.umdl" #define sensitivity_str "0.5" +#define audio_gain 1.0 +#define apply_frontend false struct wavHeader { //44 byte HEADER only char RIFF[4]; @@ -136,6 +138,8 @@ int main(int argc, char * argv[]) { // Initializes Snowboy detector. snowboy::SnowboyDetect detector(resource_filename, model_filename); detector.SetSensitivity(sensitivity_str); + detector.SetAudioGain(audio_gain); + detector.ApplyFrontend(apply_frontend); int result = detector.RunDetection(&data_buffer[0], fsize/sizeof(short)); std::cout << ">>>>> Result: " << result << " <<<<<" << std::endl; diff --git a/examples/C/demo.c b/examples/C/demo.c index 971d7407..f72f36ba 100644 --- a/examples/C/demo.c +++ b/examples/C/demo.c @@ -190,12 +190,14 @@ int main(int argc, char* argv[]) { const char model_filename[] = "resources/models/snowboy.umdl"; const char sensitivity_str[] = "0.5"; float audio_gain = 1; + bool apply_frontend = false; // Initializes Snowboy detector. SnowboyDetect* detector = SnowboyDetectConstructor(resource_filename, model_filename); SnowboyDetectSetSensitivity(detector, sensitivity_str); SnowboyDetectSetAudioGain(detector, audio_gain); + SnowboyDetectApplyFrontend(detector, apply_frontend); // Initializes PortAudio. You may use other tools to capture the audio. StartAudioCapturing(SnowboyDetectSampleRate(detector), diff --git a/examples/Go/detect/main.go b/examples/Go/detect/main.go index 2300be5b..00ec04d6 100644 --- a/examples/Go/detect/main.go +++ b/examples/Go/detect/main.go @@ -18,6 +18,7 @@ func main() { detector := snowboydetect.NewSnowboyDetect("../../../resources/common.res", os.Args[1]) detector.SetSensitivity("0.5") detector.SetAudioGain(1) + detector.ApplyFrontend(false) defer snowboydetect.DeleteSnowboyDetect(detector) dat, err := ioutil.ReadFile(os.Args[2]) @@ -36,4 +37,4 @@ func main() { } else { fmt.Println("Snowboy detected keyword ", res) } -} \ No newline at end of file +} diff --git a/examples/Java/Demo.java b/examples/Java/Demo.java index 840a610d..d064007d 100644 --- a/examples/Java/Demo.java +++ b/examples/Java/Demo.java @@ -24,6 +24,7 @@ public static void main(String[] args) { "resources/models/snowboy.umdl"); detector.SetSensitivity("0.5"); detector.SetAudioGain(1); + detector.ApplyFrontend(false); try { TargetDataLine targetLine = diff --git a/examples/Node/file.js b/examples/Node/file.js index 055f1237..c97bf540 100644 --- a/examples/Node/file.js +++ b/examples/Node/file.js @@ -14,7 +14,8 @@ models.add({ const detector = new Detector({ resource: "resources/common.res", models: models, - audioGain: 1.0 + audioGain: 1.0, + applyFrontend: false }); detector.on('silence', function () { diff --git a/examples/Node/microphone.js b/examples/Node/microphone.js index 4e573182..a0dfe2ee 100644 --- a/examples/Node/microphone.js +++ b/examples/Node/microphone.js @@ -13,7 +13,8 @@ models.add({ const detector = new Detector({ resource: "resources/common.res", models: models, - audioGain: 2.0 + audioGain: 2.0, + applyFrontend: true }); detector.on('silence', function () { diff --git a/examples/Perl/snowboy_googlevoice.pl b/examples/Perl/snowboy_googlevoice.pl index 9c4075ca..97b5d055 100755 --- a/examples/Perl/snowboy_googlevoice.pl +++ b/examples/Perl/snowboy_googlevoice.pl @@ -133,6 +133,7 @@ $sb = new Snowboy::SnowboyDetect('resources/common.res', $model); $sb->SetSensitivity('0.5'); $sb->SetAudioGain(1.0); +$sb->ApplyFrontend(0); # Running the detection forever. print "\n"; diff --git a/examples/Perl/snowboy_unit_test.pl b/examples/Perl/snowboy_unit_test.pl index 6a9a856d..b54cc306 100755 --- a/examples/Perl/snowboy_unit_test.pl +++ b/examples/Perl/snowboy_unit_test.pl @@ -16,6 +16,7 @@ $sb->SetSensitivity ("0.5"); $sb->SetAudioGain (1); +$sb->ApplyFrontend (0); print "==== SnowBoy object properties ====\n"; print "Sample Rate : ", $sb->SampleRate(), "\n"; diff --git a/examples/Python/snowboydecoder.py b/examples/Python/snowboydecoder.py index 1a9aa9a2..5da9aff0 100644 --- a/examples/Python/snowboydecoder.py +++ b/examples/Python/snowboydecoder.py @@ -88,11 +88,13 @@ class HotwordDetector(object): decoder. If an empty list is provided, then the default sensitivity in the model will be used. :param audio_gain: multiply input volume by this factor. + :param apply_frontend: applies the frontend processing algorithm if True. """ def __init__(self, decoder_model, resource=RESOURCE_FILE, sensitivity=[], - audio_gain=1): + audio_gain=1, + apply_frontend=False): def audio_callback(in_data, frame_count, time_info, status): self.ring_buffer.extend(in_data) @@ -110,6 +112,7 @@ def audio_callback(in_data, frame_count, time_info, status): self.detector = snowboydetect.SnowboyDetect( resource_filename=resource.encode(), model_str=model_str.encode()) self.detector.SetAudioGain(audio_gain) + self.detector.ApplyFrontend(apply_frontend) self.num_hotwords = self.detector.NumHotwords() if len(decoder_model) > 1 and len(sensitivity) == 1: diff --git a/examples/Python3/snowboydecoder.py b/examples/Python3/snowboydecoder.py index f7ad02d4..34ee26fb 100644 --- a/examples/Python3/snowboydecoder.py +++ b/examples/Python3/snowboydecoder.py @@ -89,12 +89,14 @@ class HotwordDetector(object): decoder. If an empty list is provided, then the default sensitivity in the model will be used. :param audio_gain: multiply input volume by this factor. + :param apply_frontend: applies the frontend processing algorithm if True. """ def __init__(self, decoder_model, resource=RESOURCE_FILE, sensitivity=[], - audio_gain=1): + audio_gain=1, + apply_frontend=False): tm = type(decoder_model) ts = type(sensitivity) @@ -107,6 +109,7 @@ def __init__(self, decoder_model, self.detector = snowboydetect.SnowboyDetect( resource_filename=resource.encode(), model_str=model_str.encode()) self.detector.SetAudioGain(audio_gain) + self.detector.ApplyFrontend(apply_frontend) self.num_hotwords = self.detector.NumHotwords() if len(decoder_model) > 1 and len(sensitivity) == 1: diff --git a/examples/iOS/Obj-C/SnowboyTest/ViewController.mm b/examples/iOS/Obj-C/SnowboyTest/ViewController.mm index 4497ec50..d1d6c91b 100644 --- a/examples/iOS/Obj-C/SnowboyTest/ViewController.mm +++ b/examples/iOS/Obj-C/SnowboyTest/ViewController.mm @@ -31,6 +31,7 @@ - (void)initSnowboy { std::string([[[NSBundle mainBundle]pathForResource:@"alexa" ofType:@"umdl"] UTF8String])); _snowboyDetect->SetSensitivity("0.5"); _snowboyDetect->SetAudioGain(1.0); + _snowboyDetect->ApplyFrotnend(false); } - (void) initMic {