Commit Graph

108 Commits (refactor/python-detect)

Author SHA1 Message Date
Kris Gesling e75a05557b docstring cleanup 2021-05-11 15:10:32 +09:30
dalgwen 4747dd0e59 Fix UnboundLocalError in AudioProducer
==== Fixed Issues ====

====  Tech Notes ====
The variable should be declared outside the loop.
2020-12-15 10:16:34 +01:00
Kris Gesling d1ea9088fb
Merge pull request #2670 from MycroftAI/remove/startListening
remove deprecated startListening signal
2020-08-21 00:31:30 +00:00
Kris Gesling d4d7d09e40 remove hardcoded timeouts; already moved to conf 2020-08-19 20:35:23 +09:30
Kris Gesling 23d1d35ea9 remove deprecated startListening signal 2020-08-18 22:21:38 +09:30
Kris Gesling 5dac7fe54c disable wakeword uploads before deprecating API 2020-08-13 16:49:54 +09:30
Kris Gesling 7aa80e2b7d remove duplicate and unused method 2020-08-13 16:46:08 +09:30
Åke Forslund a1fdae3415 Add support for watchdog in skills and speech client
If no watchdog is provided a dummy function will be called
2020-07-22 10:52:32 +02:00
Åke Forslund 926d3ff1c1 Extract noise-tracking from _record_phrase
_record_phrase now uses a helper class to track the noise in a sentence
to determine when the user has stopped speaking.

The logic should be the same but the same but allow for easier testing
and manipulation.
2020-05-26 12:12:12 +02:00
Åke Forslund 9e73180206 Make sec_to_bytes a member of MutableMic
The function is based on the parameters of the Mic and is much more a
method of the mic than a static function
2020-05-26 12:12:12 +02:00
Åke Forslund 225f22fe82 Remove unused member variables
Move wakeword duration to the wakeword engine since all wakeword engines
doesn't really use phonemes
2020-05-26 12:12:12 +02:00
Åke Forslund dbf2bf45b1 Return status from wakeword as tuple
- Return the data from the wakeword as a tuple.
- Extract post wakeword actions from wait for wakeword method
2020-05-26 12:12:12 +02:00
Åke Forslund 567e08809a Refactor _wait_for_wakeword
- Add RollingMean data structure
- Add simple CyclicBuffer data structure
- Move out post find actions into separate method
2020-05-26 12:12:12 +02:00
Åke Forslund 7586de86d9 Fix MutableStream __init__ with mute=True
If the stream is restarted while muted this would cause an Exception
leading to an unresponsive voice client due to the read_lock being
called before creation.
2020-04-20 09:26:31 +02:00
Aditya Mehra c5c0881d94 Add configuration option to set microphone timeout
listener->recording_timeout: Maximum length of recording
listener->recording_timeout: Maximum length of silence before stopping
recording
2020-04-17 11:23:25 +02:00
ludwhe 49c6b298f1 Add path checks 2020-02-27 08:33:11 +01:00
ludwhe af6b7353e6 Added a "save_path" configuration for saved wake words and utterances. 2020-02-27 08:33:06 +01:00
Daniel Morse 3751add193 Move emission of recognizer_loop:wakeword
The message is now emitted directly after a wakeword is detected.
2019-11-11 15:13:56 +01:00
Kris Gesling 0197a7ee39 frames to read must be greater than 0 2019-11-01 08:13:26 +01:00
Åke Forslund 8d4413db9c Update account id fetching
Account ID will now be refetched if invalid the first time.

This also adds some general exception handling to avoid client crashing due
to the servers invalid 204 response.
2019-10-26 09:35:03 +02:00
Åke f234354783
Merge pull request #2365 from forslund/bugfix/lock-mic-mute-unmute
Lock mic mute unmute
2019-10-20 14:12:53 +02:00
Åke Forslund 149a236e30 Attemt to restart the mic if there's an IOError
If mic produces an IOError try to restart the microphone's input stream
to recover.
2019-10-20 09:01:17 +02:00
Åke Forslund 5d8c3c6c92 Minor cleanup of mic docstrings, etc 2019-10-18 12:19:45 +02:00
Åke Forslund 9f555015e7 Add lock to mute unmute of mic stream
This should alleviate a potential (or possibly an existing) problem if
mute is triggered while reading of the mic occurs.
2019-10-18 12:12:48 +02:00
Åke Forslund 46b0b94631 Don't go through FS when triggering listener.
This adds a separate handler for triggering listening on the
"mycroft.mic.listen" message
2019-10-03 19:12:56 +02:00
David Wagner a66ec9388d Write mic level with mute 2019-09-25 11:54:22 +02:00
Åke Forslund e2d5b92bfe Remove deprecated methods and checks 2019-09-02 11:45:32 +02:00
Åke Forslund 4ae290d5b1 Send recording message after playing recording sound
This allows the sound to play before any ducking starts
2019-08-26 15:09:01 +02:00
David Wagner f96a69227d W503 2019-08-22 20:48:07 +02:00
David Wagner 60c43ff3a6 close() on already closed file 2019-08-22 20:48:07 +02:00
David Wagner 4bc1e6dcc6 Keep audio frames immediately after wake word and send them to STT 2019-08-22 20:48:07 +02:00
Joshua Watt 601eeb6bdc Implement streaming STT framework
The initial framework for live streaming Speech to Text. STT derived
classes now can report that they support live streaming via their
"can_stream" property. If True, the following member functions will be
called on the object:

stream_start() - Called when a stream is starting. Should setup any
persistent state required to process speech to text.

stream_data(chunk) - Called when a chunk of audio data has been
captured.

stream_stop() - Called when a stream should be stopped. Should tear down
any state setup with stream_start(). Note that this may be called at
anytime (even if stream_start() has not been called).

Note that the execute() API is still used to get the text utterance from
the class.

A typical sequence of calls would be:

 stream_start()
 stream_data(...)
 stream_data(...)
 stream_data(...)
 stream_data(...)
 ...
 execute(...)
 stream_stop()
2019-06-09 22:28:09 -05:00
Åke 72ceed4377 Fix usage of mtd before assignment (#2145)
When opt in is set and local saving of the file no mtd would be generated and the cause a undefined variable exception. This generates metadata if it's missing
2019-06-05 18:43:45 -05:00
Steve Penrod 115bf77763 Restored ability to store wakewords locally (#2141)
* Restored ability to store wakewords locally

The code that handles the local save of wake words configuration -
"record_wake_words" - was removed some time ago.  This restores that
capability.


Add the following to mycroft.conf
  {
    "listener": {
       "record_wake_words": true
    }
  }

Then restart Mycroft.  It should begin saving .wav files under the
/tmp/mycroft_wake_words directory.

The filename, will be  filename structure is: 

<accountId>_<engine>_<model>_<name>_<sessionId>_<time>.wav


* Add documentation for 'record_wake_words' and improve the doc for
'save_utterances'.
2019-05-31 16:07:50 +02:00
Chris Rogers b975f2f9cf file -> audio_file 2019-04-14 18:36:07 -04:00
Åke 526d326ecf Mute the mic while playing the listening "beep" (#2042)
This also extends the stream mute to actually stopping the recording stream while muted.
2019-03-07 13:42:00 -06:00
Steve Penrod 2424fd1c9b Change to "save_utterances" instead of "record_utterances"
Change to match the documented and more intuitive name "save_utterances",
but add backwards compatibility code to support the original
"record_utterances".
2019-02-11 01:53:28 -06:00
Åke Forslund 38701a9790 Remove inheritance from object
Inheriting from object isn't necessary in python3.
2019-01-11 09:24:21 +01:00
Matthew Scholefield 189e0f10ab Refactor Precise engine and support engine timeouts 2018-07-06 00:05:28 -05:00
Matthew D. Scholefield 727e1c787c Change wake word upload to https request
Also strips out old alternative ways to enable wake word upload
The logic for uploading wake words is now:
 - Only if opt-in is enabled
 - With an additional "disable" setting to selectively prevent it
2018-06-06 14:53:11 -05:00
Matthew D. Scholefield 8c0b471d24 Fail wake word upload on first try
Previously failed wake words would collect and each one would attempt an upload and fail. Now, this does the same process but failing on the first wake word that fails to upload
2018-05-15 12:31:06 -05:00
Matthew D. Scholefield 3fa958cbac Make scp upload quiet and reduce saved seconds
The scp upload shows the account id which isn't the best to put in logs
The saved audio seconds used to contain audio before so that it could be used to identify multiple recordings that didn't activate the device. However, we've since moved to tagging only the last 3 seconds
2018-05-15 12:28:28 -05:00
Åke Forslund c6584d603d Make speech client python3 compatible 2018-04-27 08:50:46 -05:00
Matthew D. Scholefield 7e64b49fa3 Replace HTTPError with RequestException
This prevents things like a ReadTimeout exception crashing the speech service
2018-03-07 10:57:13 -06:00
Åke 5327b35f31 Disable overflow exceptions when reading mic (#1359)
Many thanks to mikonse for troubleshooting and suggesting this fix.

==== Fixed Issues ====

====  Tech Notes ====
Disabling this exception should free up the audio producer thread to
continue deliver the available sound data.
2018-02-15 02:23:36 -06:00
Matthew D. Scholefield 716032215d Add model hash to wake word upload 2018-01-03 20:29:27 -06:00
Åke 742558046d Python 2/3 compatibility (#1259)
Add Python 2/3 compatibility

====  Tech Notes ====
This allows the main bus, skills and cli to be run in both python 2.7 and
3.5+.

Mainly trivial changes
- syntax for exceptions
- logic for importing correct Queue module
- .iteritems -> future.utils.iteritems when accessing dicts key value
pairs

* Allow audio service to be run in python 3
* Make speech client work with python 3
* Importing of Queue version dependent
* Exception syntax corrected
* Creating sound buffer is version dependant
- Adapt context use range from builtins
- Use compatible next() instead of .next() when walking the skill
directory

* Make CLI Python 3 Compatible
- Use compatible BytesIO instead of StringsIO
- Open files as text instead of binary
- Make sure integer divisions are used

* Make messagebus send compatible
* Fix failing travis

Re-add future 0.16.0

* Make string checks compatible
* basestring doesn't exist in python 3 so it's imported from the "past"
* Fix latest compatibility issues in speech client
- handle urllib
- handle encoding before calling md5

* Make Api.build_json() python 2/3 compatible
2017-12-18 17:24:21 -06:00
Åke Forslund 6083cbce07 Handle ConnectionError when retrieving user id
If the machine is not connected to the network getting the user uuid in MutableMic.__init__ will fail, raising ConnectionError. This caused the speech client to crash.

Adding handler for ConnectionError resolves this issue.
2017-11-24 10:54:36 +01:00
Matthew D. Scholefield 168a2b660f Improve accuracy of metrics naming
- md5 is consistent across architectures
 - Account ID is now consistent per user. Previously was using the device id
2017-11-15 19:35:53 -06:00
Matthew D. Scholefield ec223dcec9 Add wake word module hash to filename 2017-11-09 13:58:44 -06:00