Skip to content

Commit

Permalink
changed default snowboy tick pattern + logging improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
alexylem committed Mar 12, 2017
1 parent 9534b0f commit 87d4c31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -44,3 +44,5 @@ hooks/stop_listening
hooks/start_speaking

hooks/stop_speaking

*.pyc
2 changes: 1 addition & 1 deletion stt_engines/snowboy/main.py
Expand Up @@ -58,7 +58,7 @@ def detected_callback(modelid):
# max voice ticks after detection
# [3] ticks_silence_after_detect:
# min silence ticks after detection
trigger_ticks = [ 2, 10, 3, 2 ]
trigger_ticks = [ 2, 20, 5, -1 ]

detector = maindecoder.JarvisHotwordDetector(
models,
Expand Down
11 changes: 6 additions & 5 deletions stt_engines/snowboy/maindecoder.py
Expand Up @@ -86,6 +86,7 @@ def audio_callback(in_data, frame_count, time_info, status):
rate=self.detector.SampleRate(),
frames_per_buffer=2048,
stream_callback=audio_callback)
logger.info ("Ticks: %s", self.trigger_ticks)

def match_ticks(self,aticks):
tticks = self.trigger_ticks
Expand Down Expand Up @@ -142,19 +143,19 @@ def match_ticks(self,aticks):
""" Match? """
if tticks[0]>0 and silence_before < tticks[0]:
""" will never match """
logger.info( "No match silence_before" )
logger.warning( "No match silence_before" )
return -1
if tticks[1]>0 and voice_before > tticks[1]:
""" will never match """
logger.info( "No match voice_before" )
logger.warning( "No match voice_before" )
return -1
if tticks[2]>0 and voice_after > tticks[2]:
""" will never match """
logger.info( "No match voice_after" )
logger.warning( "No match voice_after" )
return -1
if tticks[3]>0 and silence_after < tticks[3]:
""" can still match on next tick """
logger.info( "No match silence_after - wait next tick" )
logger.warning( "No match silence_after - wait next tick" )
return 0
""" A match ! """
return 1
Expand Down Expand Up @@ -251,7 +252,7 @@ def start(self, detected_callback=snowboydecoder.play_audio_file,
""" Not a match """
callback = None
elif ret == 1:
logger.warning("Callback run");
#logger.warning("Callback run");
callback()
callback = None
""" ret == 0 : Not a match yet """
Expand Down

0 comments on commit 87d4c31

Please sign in to comment.