pocketsphinx local listener with limited vocab for use inside skills in mycroft-core
- git clone repo_url
- TODO setup.py
or
pip install TODO
from localstt import LocalListener
...
def initialize(self):
self.local = LocalListener(lang=self.lang, emitter=self.emitter)
def handle_my_intent(self, message):
# do stuff
utterance = local.listen()
# do more stuff
def shutdown(self):
self.local.shutdown()
super(MycroftSkill, self).shutdown()
capture one utterance
print local.listen_once()
capture utterances continuously
local = LocalListener()
i = 0
for utterance in local.listen():
print utterance
i += 1
if i > 5:
local.listening = False
listen once
local = LocalListener()
print local.listen_numbers_once()
listen continuous
local = LocalListener()
i = 0
for utterance in local.listen_numbers():
print utterance
i += 1
if i == 5:
local.listening = False
provide the words and phonemes explicitly
vocab = {"hello": ["HH AH L OW"]}
local = LocalListener()
print local.listen_once_specialized(vocab)
i = 0
for utterance in local.listen_specialized(vocab):
print utterance
i += 1
if i > 5:
local.stop_listening()
this listening mode will emit captured answers to the messagebus like a normal speak message
local = LocalListener()
local.listen_async()
# keep doing things, utterances will be handled normally
to stop the listening thread:
local.stop_listening()
if no dictionary is provided it will use a very basic one
END EH N D
HELP HH EH L P
MIND M AY N D
NEVER N EH V ER
NO N OW
PAUZE P AO Z
PLAY P L EY
QUIT K W IH T
REPEAT R IH P IY T
REPEAT(2) R IY P IY T
START S T AA R T
STOP S T AA P
YES Y EH S
ABORT AH B AO R T
NEXT N EH K S T
THANK TH AE NG K
YOU Y UW
any language should be supported if you provide the models, english and spanish supported by default
local = LocalListener(lang="es-es")
local = LocalListener(hmm="path", lm="path2", le_dict="path3")
print local.listen_numbers_once("path/lang/numbers.dic")
19:04:00.832 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {}, "type": "recognizer_loop:sleep", "context": {"source": "LocalListener"}}
19:04:00.835 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {}, "type": "recognizer_loop:local_listener.start", "context": {"source": "LocalListener"}}
19:04:02.951 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {"lang": "en-us", "utterances": ["never mind"]}, "type": "recognizer_loop:utterance", "context": {"source": "LocalListener"}}
19:04:05.337 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {"lang": "en-us", "utterances": ["pauze"]}, "type": "recognizer_loop:utterance", "context": {"source": "LocalListener"}}
19:04:06.773 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {"lang": "en-us", "utterances": ["stop"]}, "type": "recognizer_loop:utterance", "context": {"source": "LocalListener"}}
19:04:08.775 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {"lang": "en-us", "utterances": ["never mind"]}, "type": "recognizer_loop:utterance", "context": {"source": "LocalListener"}}
19:04:10.343 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {"lang": "en-us", "utterances": ["pauze"]}, "type": "recognizer_loop:utterance", "context": {"source": "LocalListener"}}
19:04:10.845 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {}, "type": "recognizer_loop:local_listener.end", "context": {"source": "LocalListener"}}
19:04:10.849 - mycroft.messagebus.service.ws:on_message:41 - DEBUG - {"data": {}, "type": "recognizer_loop:wake_up", "context": {"source": "LocalListener"}}
- pip package
- naptime skill will answer with “i am awake”, PR#9
-
JarbasAI
-
Adapted from tjoen