Procházet zdrojové kódy

Add minimum_confidence option

Now setting the minimum_confidence option in options.json allows the
user to control the minimum confidence a plugin must have to be executed
at all.  A value of null (the default) means all values greater than
zero are accepted.  All other values mean all confidences greater than
or equal to that value are accepted.
Clara Hobbs před 7 roky
rodič
revize
d7b54af2f1
2 změnil soubory, kde provedl 6 přidání a 3 odebrání
  1. 2
    1
      kayleevc/conf/options.json
  2. 4
    2
      kayleevc/kaylee.py

+ 2
- 1
kayleevc/conf/options.json Zobrazit soubor

@@ -5,5 +5,6 @@
5 5
     "interface": null,
6 6
     "valid_sentence_command": null,
7 7
     "invalid_sentence_command": null,
8
-    "tts": ["espeak", "-ven-us+f2"]
8
+    "tts": ["espeak", "-ven-us+f2"],
9
+    "minimum_confidence": null
9 10
 }

+ 4
- 2
kayleevc/kaylee.py Zobrazit soubor

@@ -140,14 +140,16 @@ class Kaylee:
140 140
 
141 141
     def recognizer_finished(self, recognizer, text):
142 142
         confidence_heap = queue.PriorityQueue()
143
+        min_confidence = self.options['minimum_confidence']
143 144
         # Add plugins to the heap
144 145
         for index, plugin in enumerate(self.plugins):
145 146
             # Get plugin confidence
146 147
             confidence = plugin.confidence(text)
147 148
             # Clamp confidence to [0, 1]
148 149
             confidence = min(max(confidence, 0), 1)
149
-            # TODO: Only add items if they meet minimum confidence
150
-            if confidence > 0:
150
+            # If the plugin meets minimum confidence
151
+            if ((min_confidence is not None and confidence >= min_confidence)
152
+                or (min_confidence is None and confidence > 0)):
151 153
                 # Add a triple to the heap, so plugins are sorted first by
152 154
                 # confidence, then by index to break ties
153 155
                 confidence_heap.put_nowait((1 - confidence, index, plugin))

Loading…
Zrušit
Uložit