Browse Source

add sensitivity to snowboy (#303)

Nicolas Marcq 7 years ago
parent
commit
6db3920d30
2 changed files with 14 additions and 5 deletions
  1. 7 3
      Docs/trigger.md
  2. 7 2
      kalliope/trigger/snowboy/snowboy.py

+ 7 - 3
Docs/trigger.md

@@ -7,9 +7,13 @@ With Kalliope project, you can set whatever Hotword you want to wake it up.
 
 You can create your magic word by connecting to [Snowboy](https://snowboy.kitt.ai/) and then download the trained model file.
 
-Once downloaded:
-- place the file in your personal config folder.
-- update the path of **pmdl_file** in [your settings](settings.md).
+Once downloaded, place the file in your personal config folder and configure snowboy in your [your settings](settings.md) following the table bellow
+
+| parameter   | required | type   | default | choices         | comment                                                                                          |
+|-------------|----------|--------|---------|-----------------|--------------------------------------------------------------------------------------------------|
+| pmdl_file   | TRUE     | string |         |                 | Path to the snowboy model file. The path can be absolute or relative to the brain file           |
+| sensitivity | FALSE    | string | 0.5     | between 0 and 1 | Increasing the sensitivity value lead to better detection rate, but also higher false alarm rate |
+
 
 If you want to keep "Kalliope" as the name of your bot, we recommend you to __enhance the existing Snowboy model for your language__.
 

+ 7 - 2
kalliope/trigger/snowboy/snowboy.py

@@ -27,6 +27,9 @@ class Snowboy(Thread):
         self.interrupted = False
         self.kill_received = False
 
+        # get the sensitivity if set by the user
+        self.sensitivity = kwargs.get('sensitivity', 0.5)
+
         # callback function to call when hotword caught
         self.callback = kwargs.get('callback', None)
         if self.callback is None:
@@ -41,7 +44,9 @@ class Snowboy(Thread):
         if not os.path.isfile(self.pmdl_path):
             raise SnowboyModelNotFounfd("The snowboy model file %s does not exist" % self.pmdl_path)
 
-        self.detector = snowboydecoder.HotwordDetector(self.pmdl_path, sensitivity=0.5, detected_callback=self.callback,
+        self.detector = snowboydecoder.HotwordDetector(self.pmdl_path,
+                                                       sensitivity=self.sensitivity,
+                                                       detected_callback=self.callback,
                                                        interrupt_check=self.interrupt_callback,
                                                        sleep_time=0.03)
 
@@ -106,4 +111,4 @@ class Snowboy(Thread):
             try:
                 stdio.__stderrp = devnull
             except KeyError:
-                stdio.fclose(devnull)
+                stdio.fclose(devnull)