Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 14 resolved #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions modules/attentionWord/pocketSphinx AlsaAudio/attentionWord.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python3

import time
import zmq
import sys
import datetime
Expand Down Expand Up @@ -102,18 +102,24 @@ def application(self, message):
inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
inp.setperiodsize(32)

while True:
l,buf = inp.read()
if buf:
start_time = time.time()
while True:
l, buf = inp.read()
if buf:
decoder.process_raw(buf, False, False)
else:
else:
break
if decoder.hyp() is not None:
timeOfActivation = datetime.datetime.now().isoformat(' ')
print("Detected keyword, restarting search")
decoder.end_utt()
message = {'timeOfActivation': timeOfActivation}
break
if time.time() - start_time > 15:
print("Timeout reached, stopping listening")
decoder.end_utt()
message = {'timeOfActivation': None}
break
if decoder.hyp() != None:
timeOfActivation = datetime.datetime.now().isoformat(' ')
print ("Detected keyword, restarting search")
decoder.end_utt()
message = {'timeOfActivation': timeOfActivation}
break

# return result
return message
Expand Down