Closed Korolen closed 7 years ago
Are you running the latest release or a locally built version of Hammerspoon? When I try the above in my console, I get the following:
> hs.logger.setGlobalLogLevel(5)
log = hs.logger.new("speech", "verbose")
require('hs.speech.listener')
listener = hs.speech.listener.new()
-- hs.speech included because looking at the code for listener non-string, non-number value should produce a warning; but it doesn't seem to
listener:commands({"test", hs.speech, "cat"})
listener:blocksOtherRecognizers(true)
listener:setCallback(function(l, s)
log.i('callback executed', l, s)
end)
log.i('starting listener')
listener:start()
hs.logger.setGlobalLogLevel(5)
-- Loading extension: logger
-- Loading extension: speech
20:51:07 ** Warning: LuaSkin: not a string or number value, skipping
speech: starting listener
20:51:10 speech: callback executed hs.speech.listener: (null) (0x7fedfbe66d90) test
20:51:12 speech: callback executed hs.speech.listener: (null) (0x7fedfbe66d90) cat
> listener:stop()
hs.speech.listener: (null) (0x7fedfbe66d90)
Which appears to be working...
I sort of recall reading something about having Enhanced Dictation enabled in the Speech and Dictation preferences panel helps... can't find the reference now, and it wasn't in the Apple docs for the NSSpeechRecognizer class, so YMMV or I may be remembering wrong... It is enabled on my setup, so you might check as shown in this picture and also try adjusting the microphone's input volume under the Sound preferences panel.
Background noise also makes a huge difference in how effective it is.
I'll take a closer look at the code later and see if we can enable additional logging or if any other ideas come to mind.
@korolen, is this still an issue for you? If we need to update the docs to include the "Use Enhanced Dictation" field, I'm happy to do so, if that fixed it for you.
(closing due to no response. please re-open if you disagree :)
Hi,
I'm very excited to try and get hs.speech.listener working and migrate my commands from Dragon, but I can't get it to actually operate. This is my test code, and the callback function never seems to be executed:
`hs.logger.setGlobalLogLevel(5) log = hs.logger.new("speech", "verbose") require('hs.speech.listener')
listener = hs.speech.listener.new()
-- hs.speech included because looking at the code for listener non-string, non-number value should produce a warning; but it doesn't seem to listener:commands({"test", hs.speech, "cat"}) listener:blocksOtherRecognizers(true)
listener:setCallback(function(l, s) log.i('callback executed', l, s) end)
log.i('starting listener') listener:start() hs.logger.setGlobalLogLevel(5)`
I'm able to get the command window to show, with "test" and "cat" in it. The microphone meter shows the microphone is picking up sound. 'starting listener' shows up in the console.
But 'callback executed:' never does show up. Also strange, the hs.speech value included in the list of commands does not produce a warning, as expected.
Any ideas? @asmagill, do you have any thoughts? Happy to perform any diagnostics that might be useful.
Thanks, –Tom