Commit Graph

839 Commits (sj201r5)

Author SHA1 Message Date
Ken Smith 6ef24c0a09 hack to keep the rev5 board running 2021-01-12 14:26:37 -05:00
Kris Gesling 974be29c57
Merge pull request #2781 from AIIX/fix/network_remove_pages
Fix missing remove page implementation, show idle if all pages removed
2021-01-11 21:58:22 +09:30
Aditya Mehra 7c2ca269e2 use mycroft.device.show.idle 2021-01-11 15:11:16 +05:30
Kris Gesling ad32a7a873 move bus connect method to process_utils 2021-01-11 16:57:25 +09:30
Kris Gesling 0423daeb4c Voice service to use common bus cilent method 2021-01-11 16:57:25 +09:30
Kris Gesling 118c6f73c5 autopep8 2021-01-08 22:47:54 +09:30
Kris Gesling c25e51f0f3 trigger wifi or pairing once all services ready 2021-01-08 22:46:59 +09:30
Kris Gesling 652f3342bc
Merge pull request #2788 from MycroftAI/feature/no-precise-tarball
Do not download Precise if executable already exists
2021-01-08 12:02:53 +09:30
Kris Gesling 54eac52b11 merge dev into mark-2 branch 2021-01-06 22:17:25 +09:30
Aditya Mehra eea66b4376 remove platform check and make the idle emit general 2021-01-06 13:20:17 +05:30
Kris Gesling 81eae60b61
Merge pull request #2758 from MycroftAI/refactor/enclosure-startup
Ensure messagebus is connected before reporting that the service is ready
2021-01-05 20:55:59 +09:30
Åke Forslund 9d450b5890 Unshadow Message class in _handle_pairing_complete
Fixes a small typo making the unmute after first pairing call fail.
2021-01-04 21:38:05 +01:00
Kris Gesling 9ec66ccdd7 Increase timeout for slower hashing on squashfs
The current petact download system hashes the tarball to determine
if a download is required. This is particularly slow on first boot
of Pantacor container as it uses squashfs.
2021-01-04 22:25:23 +09:30
Kris Gesling a358bf672f Do not download Precise if exe already exists
This means that the Precise tarball will no longer need to be
stored on disk for the sake of petact.
2020-12-30 21:19:59 +09:30
Kris Gesling fd5c8bb5e3 Merge branch 'dev' into feature/mark-2 2020-12-29 14:31:09 +09:30
Aditya Mehra 9ed6baef22 fix case indentation 2020-12-18 14:03:08 +05:30
Aditya Mehra 89a07d05ab Add missing remove page implementation and show idle if all pages removed 2020-12-18 12:52:44 +05: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
Åke Forslund 4b1efc7db9 Add deprecation notice 2020-12-13 21:53:01 +01:00
Ken Smith e85c9cdbcb first version of the sj201 rev4 board 2020-12-09 14:30:12 -05:00
Åke Forslund 23cf197eb0 Pylint cleanup of imports and Porcupine class 2020-12-09 12:38:54 +01:00
Åke Forslund cb8c3fe7de Switch to using the pvporcupine pip package
This is the same set of bindings as previously but packaged and
published on pypi

Picovoce library finder functions are used to determine the location of
libraries.
2020-12-09 12:37:31 +01:00
Åke Forslund 32279894f2 Update for latest Porcupine release
- Update the creation of Porcupine object
- Update the detection to accept >= 0 (index of detected hot word)
2020-12-09 12:37:31 +01:00
Ken Smith 08bad71192 extend base enclosure to support new hardware 2020-12-03 21:55:42 +11:00
Kris Gesling ce7331fbbb Ensure messagebus connected before reporting ready
Switch to new standard method to connect to bus client
Ensure exceptions during .run() are raised to the Enclosure service
Add missing .stop() method to base Enclosure Class
Shift call of .stop() to after exit signal
2020-11-12 16:41:37 +09:30
Kris Gesling f2b7b0251b
Merge pull request #2757 from forslund/feature/ready-check
Feature: add Process Status and ensure all services ready
2020-11-12 09:16:43 +09:30
Åke Forslund 50f049032b Add docstrings for Hotword base class 2020-11-04 08:03:15 +01:00
Aditya Mehra 3a33284f62 add missing skill_id parameter for page interaction and focus events 2020-10-23 13:34:01 +05:30
Åke Forslund 0a9de0ab7c Update to pyee 8.1.0
pyee 8.1.0 adds a small change to make the once call to be more safe in
multithreaded environments.

This switches back from the now deprecated BaseEventEmitter to the
standard EventEmitter.
2020-10-22 11:43:06 +02:00
jarbasal 02cb489f63 wake word plugins 2020-10-10 18:03:40 +01:00
Åke Forslund 241adfdda8 Add Todo / comment regarding startup order 2020-09-27 09:58:08 +02:00
Kris Gesling 582faab843 Move ready check to enclosure; use ProcessStatus
Previously Mycroft reported mycroft.ready when Padatious had
finished it's first training run. This check has been shifted
to the enclosure service, and starts checking once the Padatious
training is complete.

Currently checks on readiness of audio, speech and skills services.
2020-09-27 09:58:02 +02:00
Kris Gesling e9add604fd add ProcessStatus to key services 2020-09-25 06:52:27 +02:00
katridi 6e197d0138
Bugfix/issue 2563 (#2692)
* Issue-2563 Added fallback to english model
* Added test case for checking config set up
* Added more descriptive log message
2020-09-22 15:01:01 +09:30
JarbasAI 4d3cd33d4a
Feat/self.gui.connected (#2682)
* expose gui connection status

* gui.status.request.response

Co-authored-by: jarbasal <jarbasai@mailfence.com>
2020-09-16 17:02:46 +09:30
Åke Forslund 1202417f86 Handle ntp syncs during precise Startup
Use MonotonicEvent instead of the builtin Event class
2020-09-10 13:27:21 +02: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 236a2ed594 Add hook for stopping 2020-07-22 11:06:47 +02:00
Å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 09b1deb511 Add possibility for notification hooks for services
- skills
- audio
- speech client
- messagebus service
- enclosure

The main functions now accepts the arguments ready_hook and error_hook
allowing a service or runner script to catch these states and perform
actions accordingly.

This is useful for things like systemd or a desktop launcher.

Fix audio service startup
2020-07-22 10:52:27 +02:00
Åke Forslund 0fc1ba325a Update pyee to v7.0.1
pyee has added ThreadExecutor variant of the EventEmitter which can
replace the home-spun threadpool based emitter
2020-07-07 08:21:42 +02:00
Kris Gesling 83ece0e663
Merge pull request #2591 from forslund/bugfix/mint-skill-listing
Workaround issue with get_wch on older ncurses
2020-06-23 20:01:49 +09:30
Å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 a783da2e03 Workaround issue with get_wch on older ncurses
get_wch can at times throw errors, this creates a function wait_for_any_key()
handling the error and retrying.
2020-05-20 10:54:37 +02:00
Bart Ribbers 531f78c499
Move requirements.txt to a new requirements folder and add optional deps
Some dependencies aren't actually required but can be optionally
installed for extra functionality.

The Chromecast is an optional audio backend
VLC is an optional audio backend
pyalsaaudio is only used by the mark1 enclosure
google-api-python-client is an optional STT backend, by default Mycroft
uses the Mycroft servers
2020-05-11 15:31:10 +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
Åke caa77b33f7
Merge pull request #2538 from forslund/bugfix/enclosure-shutdown
Fix enclosure shutdown
2020-04-18 08:00:07 +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
Åke Forslund 6d13872638 Cleanup of the enclosure entrypoint
- split out enclosure determination code
- Add docstrings
- Increase logging
2020-04-16 10:58:07 +02:00
Åke Forslund 290d950424 Fix shutdown of enclosure process
Previously it would always be killed, now it exits smoothly.
2020-04-16 09:47:53 +02:00
Åke Forslund b7cf8e755e Remove origin check from gui websocket
This allows simple websocket clients to connect as well.
2020-04-04 09:15:47 +02:00
Åke Forslund 4f65591c21 Simplify the GUI websocket code
Use a single websocket but don't send data from clients to other
clients.
2020-04-04 09:13:51 +02:00
jarbasal 9d712a898f Update docstrings 2020-03-30 12:05:58 +02:00
jarbasal efc9af558a Read mark1 eye color 2020-03-30 12:05:49 +02:00
dalgwen 003f2920a3 Enable snowboy to use several wakeword models
Snowboy could use several wakeword models, not only the first one.
2020-03-11 08:34:50 +01:00
Åke 05cae9d319
Merge pull request #2429 from MycroftAI/bug/mark1_faceplate
mark1/fix display big images
2020-03-06 18:10:40 +01:00
Åke Forslund 2070e9aac9 Bump enclosure version 2020-03-02 15:25:22 +01: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
jarbasal 0de7f11c6e execute TTS from debug_cli 2020-02-15 15:35:43 +01:00
jarbasal 75c796a29d add context to all listener messages 2020-02-15 15:35:38 +01:00
jarbasal e57671ebeb capture all in cli 2020-02-15 12:52:23 +01:00
Jarbas-Core d16964c580 bus message targetting 2020-02-15 12:37:25 +01:00
JarbasAI 46af6fcff2
mark1/fix display big images
https://github.com/MycroftAI/enclosure-mark1/blob/master/protocols.txt#L141

according to the spec there is a bug
2019-12-17 01:34:08 +00:00
Åke Forslund 308b0c5111 Fix incorrect porcupine shutdown and Exception
Flagged by flake8 after merge
2019-12-12 17:51:47 +01:00
Åke 3315d98582
Merge pull request #2139 from alumae/feature/issue-1491
Add support for the Porcupine wakeword engine.
2019-12-12 16:59:12 +01:00
Åke 2263fab0b6
Merge pull request #2418 from forslund/bugfix/missing-hotword-parts
Make sure hotword entry has phonemes and threshold
2019-12-09 20:24:58 +01:00
Åke Forslund 2fa81aac52 Disregard DEBUG entry in filter
The DEBUG, has been filtered by default. This will disregard the DEBUG
filter completely since the same effect can be achieved by setting the
debug level using ":log level debug".
2019-12-09 08:27:27 +01:00
Åke Forslund f9585e47ba Clean up of create_wake_word_recognizer
- Proper docstring
- " -> '
2019-12-07 20:22:20 +01:00
Åke Forslund 2c2c933832 Make sure hotword entry has phonemes and threshold
If hotword entry is missing either add from old listener location
2019-12-07 20:18:47 +01:00
Åke 24071cdea0
Merge pull request #2416 from MycroftAI/feature/gui-server-modern-tornado
Workaround for gui connection
2019-12-07 15:08:08 +01:00
Steve Penrod 2f4b2ccf48 Remove signal.SIGINT handler from simple CLI
At some point during refactoring the ability to hit Ctrl+C to exit the basic CLI was lost.

The signal.SIGINT handler is needed by the graphical GUI, but it
interfered with the use of sys.stdin.readline() in the simple CLI.
Rearrange the installation of the handler for only the GUI.

To test, run:
   mycroft-cli-client --simple
Then hit Ctrl+C.  Before this change nothing happens (you just see the "^C" printed out).  After the change it exits as expected.
2019-12-03 20:07:19 +01:00
Åke Forslund 04e9812992 Asyncio updates for gui connections
- Workaround, ensure asyncio event loop is launched on each thread.
2019-11-26 14:21:49 +01:00
Åke Forslund 026f769028 Fix using of hotword structure for custom wakeword
Fixes overriding settings from listener config
2019-11-26 09:07:15 +01:00
Christian Clauss a1ff3fb355 Upgrade from pycodestyle to flake8 2019-11-19 23:07:52 +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 Forslund 8bdeddb965 Catch and log errors starting up the speech client 2019-10-26 09:34:28 +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 bc2bfb6c77 Ignore overflow errors as before 2019-10-20 09:48:52 +02:00
Åke Forslund 3da5dece0c Stop restarting mic after 20 attempts 2019-10-20 09:47:12 +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 b480dda90f Clean up docstrings
Minor cleanup of docstrings in the files affected by the previous commit
2019-10-03 19:13:02 +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 86b6ef16e5 Log IOErrors 2019-09-27 22:25:54 +00:00
David Wagner 4536de7a06 Add Exception logging 2019-09-27 21:50:24 +00:00
David Wagner b0c7d3072c Update text client parsing of mic_level file 2019-09-25 12:23:11 +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
Chris Veilleux c5058a5117 Merge remote-tracking branch 'remotes/origin/dev' into feature/log-merger 2019-08-29 13:57:08 -05: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
David Wagner e5f71cf12a
Merge pull request #2245 from forslund/bugfix/download-precise
Bugfix/download precise
2019-08-20 11:27:35 -05:00
Chris Veilleux cc3ef9b4b0 changed to handle new log message format 2019-08-02 11:16:55 -05:00
Åke Forslund f727c00430 Move pairing check to the relevant stt backends
The pairing trigger should only be triggered by the 401 status for the
Mycroft hosted STT backends. Doing it for other STT's is only confusing.

This creates the decorator 'requires_pairing' that can be applied to the STT modules where it's relevant.

This adds the decorator to the MycroftSTT and the MycroftDeepSpeechSTT
2019-08-02 18:16:29 +02:00
Åke Forslund 6a2451bcbc Retry failed download of precise or use existing
Will retry the download of precise once per minute
2019-08-02 08:06:28 +02:00
Åke Forslund ad49c51ffc Minor cleanup of hotword_factory.py
- Reorder includes
- Add basic docstrings for the available engines
- simplify super()
- remove unneccessary "/" chars
2019-07-26 15:54:37 +02:00
Åke Forslund 9fda4e0670 Check if mic returned data before putting on queue
Mic may return None when aborted due to a reload of wake-word engine
2019-07-26 15:34:16 +02:00
Chris Veilleux 0bde1bc9df Refactor skill service (#2220)
Major refactoring of the skills startup sequence
- Restructure to a less nested structure
- Remove usage of globals by wrapping a lot of state variables into a class this allows for things like caching a negative pairing status throughout the startup process
2019-07-26 08:53:27 +02:00
Chris Veilleux d8f3095d40 Rename the message bus client and abstract config loading
Message bus config loading is now shared by service and client.

messagebus.client.ws file is still available in case skills are using it. It is a backport that inherits from the new MessageBusClient class. Adds depreciation warning.
2019-07-19 08:16:54 +02:00
Åke fc0a253c28 Fetch CLI log path from config if available (#2192)
* Fetch CLI log path from config if available

* Remove the old log locations
2019-07-11 17:40:40 -05:00
Åke Forslund b79bd0e317 Remove unused import of sys 2019-07-09 22:54:24 +02:00
Åke Forslund b0ddb9a74a Only report STT timing if transcription exists
To clean up the metrics log empty transcriptions from false activation
are no longer reported.
2019-07-09 22:54:06 +02:00
Åke Forslund f0e397b32e Do not change process conf when preparing hotwords
A backwards compatibility piece of code creates a hotword from the
listener settings if the listener referes to a non-existing hotword.

This makes sure the generated config doesn't affect the loaded
configuration to avoid extra reloads of precise.
2019-07-01 20:58:22 +02:00
Åke Forslund 3a478c4a4d Update listener reload check
The reload check is now using a more reliable method and only a subset
of the configuration. Currently set to "listener", "hotwords", "opt_in"
and "stt".
2019-07-01 20:58:12 +02:00
Åke Forslund 04c0ebf820 Clean up handling of STT returning None 2019-06-25 11:37:01 +02:00
Åke 2b6c7132b1 Allow setting loglevel for speech / voice service (#2169)
Add create_echo_function line to activate the standard logging options
2019-06-21 13:42:32 -05:00
Åke 3b697519d0 Make sure help section shows everything (#2151)
- Use entire screen height
- Correct page number calculation
- Add constants to improve code readability
2019-06-20 17:04:08 -05:00
David Wagner a5526410c0
audio -> message rename 2019-06-10 20:59:10 -05: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
Åke 6357513970 GUI updates (#2114)
* Catch the new system.gui.user.interaction

This will in turn trigger the gui.page_interaction similar to the page flip but page_number will be None

* Fix issue when adding pages

Seems like appending would fail at times

* Add lock around namespace modifications

* Improve argument description for override_idle
2019-05-31 03:44:09 -05:00
Tanel.Alumae 3fd0092120 Issue-1491 -- PEP8 issue 2019-05-24 23:45:36 +03:00
Tanel.Alumae 1265f9f0d4 Issue-1491 -- Added support for the Porcupine wakeword engine 2019-05-24 23:18:47 +03:00
Åke bf6e363812
Revert "Support chopping old audio via precise upgrade" 2019-05-22 12:52:57 +02:00
Matthew D. Scholefield dd71f24f29 Support chopping old audio via precise upgrade
This supports dropping audio buffers when the cpu falls behind so that the latency doesn't infinitely increase.
2019-05-15 02:38:33 -05:00
Åke 3841d5c13c
Merge pull request #2096 from MycroftAI/commonIoT/acknowledge
CommonIOT/acknowledge
2019-04-16 11:14:27 +02:00
Chris Rogers b975f2f9cf file -> audio_file 2019-04-14 18:36:07 -04:00
Åke 566630d9e3 Fix infinily adding pages to existing namespace (#2093)
Update the local representation with the new pages when appending pages to an existing namespace.
2019-04-11 13:24:43 -05:00
Åke feb82a2bb1 Add the SkillGUI method send_event() (#2057)
* Add the SkillGUI method send_event()

Sends raw mycroft.events.triggered messages to the gui for the skills namespace.

Example usage:
  self.gui.send_event('event_name' {'param1': 12, 'param2': 'abc'})
2019-03-27 01:22:05 -05:00
Matthew D. Scholefield a9fb77a27c Make precise sensitivity configurable 2019-03-21 17:45:38 -05: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
Åke Forslund 3d366013b9 Activate/deactivate visemes on command
When showing text the visemes would overwrite it. This inhibits the visemes when mouth events are turned off and reenables them when activated.
2019-02-28 16:04:43 +01:00
Åke d3e6a10ecc GUI Remove pages/namespaces (#2002)
* Add remove page methods

* Implement SkillGUI.clear()

The method will now remove the namespace entirely from the gui.

This adds the message gui.clear.namespace

* Remove debug prints from SkillGUI

* Correcting docstring

* More docstring changes

* Remove whitespace added by Github webUI
2019-02-28 00:21:08 -06:00
Åke 6c14d7bc36 Refactor/19.02 removes (#2019)
* Remove the deprecated emitter

* Remove channels config key for listener

This has never been used.
2019-02-28 00:09:47 -06:00
Åke b4fc3ab389
Merge pull request #2011 from MycroftAI/feature/logging-control
Improve debug logging
2019-02-22 17:37:32 +01:00
Åke Forslund 5ce4754d94 Cleanup of broken and incorrect code
- Fix pep8 in util/__init__
- Remove half done if statement and fix codacy in text_client.py
- CAPITALIZE the log levels
2019-02-22 14:54:28 +01:00
Steve Penrod fbcfe6c816 Improve debug logging
Several changes to the logging using in all processes:
* Disable logging of bus messages by default (massively cleans up the logs)
* Add "mycroft.debug.log" bus message.  It supports the data={"bus": True/False} as well as
  data={"log": LEVEL}, where level is a Python logging level.

CLI now supports several commands:
* ```:log level XXX``` where XXX is the name of a standard Python level (e.g. 'debug')
* ```:log bus on``` or ```:log bus off```
* Removed the requirement for "log" in ```:clear log```.  ```:clear``` works now.
2019-02-22 05:11:16 -06:00
Steve Penrod ed971ed1a9 Fix bug in the mic-level meter
The mic-level meter that appears in the Mycroft CLI could stop updating in
rare cases when a file I/O operation failed.  It would also fail to show
a meter ever if the mic_level file hadn't been created before the CLI was
started.
2019-02-22 11:54:00 +01: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 a94019a8b8 Use language set in mycroft configuration (#1925)
Slight refactoring to accommodate for this in a nice way. Created
function connect_to_mycroft() handling fetching the config and
connecting to the mycroft messagebus since these are related and the
order is important to maintain for it to work.
2019-01-31 01:38:47 -06:00
Åke 267c7bf571 Single viseme message (#1973)
* Add new api command to send visemes as single list.  This allows more efficient use of the messagebus and gives implementors flexibility in how they handle the visualization.

* Switch mark1 to use viseme_list
2019-01-31 00:37:55 -06:00
Åke 9ef95506d0 GUI update number 6 (#1964)
* Add communication from GUI to skills

- "set" events from Qt will set/update a variable in the skills .gui member
- It's possible to add general event handlers using self.gui.register_handler()
- Moved registration of skill_id to just after skill init

* Ensure that simultaneously writes doesn't occur

Wrap WebSocketHandler.write_message() with a lock in an attempt to handle "buffererror: existing exports of data: object cannot be re-sized."

* Add better logging to help debug disconnect issue

* Allow overriding the idle page

SkillGUI.show_page() and SkillGUI.show_pages() now takes an optional
override_idle parameter. This is used as a hint by the mark-2 skill
and if possible the idle screen will not be shown.

* Improve debugging using Logger

* Raise exception when sending a non-existing gui page

* Restore running state to new connections

When a GUI is connected data and running namespaces are synchronised and
shown.

This refactors the code quite a bit moving the GUI state from the GUIConnection
object to the Enclosure.

The GUIConnection object does the handles the sync in the on_connection_open()
method.

* Add gui.page_interaction message

Currently triggered on page change on the display.

* Handle message when gui changes sessionData

* Check if socket exists on gui before sending data

* Increase port on each failure and retry
2019-01-22 08:45:19 -06:00
Alistair Francis 71afcb9ce5 text_client.py: Don't log stack trace on missing conf (#1957)
If we are missing the ".mycroft_cli.conf" file we print a message to the
user informing them that we are ignoring the missing file along with a stack trace. The stack trace is really not necessary so this removes it.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-01-18 09:59:55 +01:00
Steve Penrod b38668a2ef Fix Ctrl+C handling in CLI
Ctrl+C was not being properly handled by the CLI, resulting in an  unclean
shutdown and other unexpected consequences -- e.g. a
"./start-mycroft.sh debug" would kill the background processes on exit.  The
KeyboardException was never being triggered.

Now the SIGINT is being captured and Ctrl+C behaves (as intended) just like
pressing Ctrl+X.
2019-01-17 09:47:43 +01:00
Åke Forslund 38701a9790 Remove inheritance from object
Inheriting from object isn't necessary in python3.
2019-01-11 09:24:21 +01:00
Åke fa5c9abd78 GUI Cleanup (#1939)
* Try to improve stability

- Remove sync_active
- Update the way variables are sent to the gui

* Do not show full path for pages

The cli now shows the basename of the current page to make it easier to
determine if the correct page is displayed.

* Make elements in loaded list named tuples

This makes the intent of the code a bit cleaner.
2019-01-09 20:09:21 -06:00
Åke Forslund ff04af99c9 Move the device finding code into an util function 2019-01-08 08:05:07 +01:00
Steve Penrod 2557637591 Support selecting microphone by name
Normally Mycroft will use the default PortAudio input device as the
microphone input for the user.  However in some cases there is reason
to specify a different input.

The "device_index" under the "listener" section in mycroft.conf has
always allowed a user to select the microphone explicitly.  But on
some systems the indices can change from reboot to reboot.  So this
adds the "device_name" setting.  If it exists (and the "device_index"
has not been specified explicitly), a regex match will be run against
the PortAudio device names.

When "device_name" is used, the voice.log will contain a listing of
the devices as they are tested.  This can be used to debug if a
name isn't matching as expected.

EXAMPLES:
/etc/mycroft/mycroft.conf
```
{
    "listener": {
        "device_name": "aawsrc"
    }
}
```
Would find a match against "aawsrc" or "aawsrcplug".  To force a specific
match, you can use a regex such as "aawsrc$".

/etc/mycroft/mycroft.conf
```
{
    "listener": {
        "device_index": 2
    }
}
```
The PortAudio device index specified will be used.

Names and indexes for PortAudio are difficult to guess.  The simplest way to
view them is either enter a value for "device_name" and look at the names
which appear in the log when starting Mycroft, or to run a simple program
such as:
```python
import pyaudio

pa = pyaudio.PyAudio()
for i in range(pa.get_device_count()):
    dev = pa.get_device_info_by_index(i)
    print((i, dev['name'], dev['maxInputChannels']))
```
2019-01-08 07:51:41 +01:00
Åke 2e9d764d36 GUI update (#1922)
Several additions to the GUI protocol support

These changes allow switching between pages successfully with the current
mycroft-gui widget:
* Optimized commands to handle the active skill list
* MycroftSkill.gui.show_pages(list, idx) allows multiple-pages to be displayed
  at a time starting with the given index visible.
* Merge SkillGUI.show_page with show_pages
  This limits code duplication and makes things a bit more maintainable.
* Do not reload on changed .qmlc files
* Make EnclosureGeneric derive from Enclosure
* Update show function to match mycroft-gui-app
  - adds internal representation of all loaded skills
  - uses new commands to switch between pages and namespaces
* Add Extra debug output in enclosure
  - Log if starting websocket fails
  - Log the sending of page info in more detail
* Update GUI Debug client in CLI
  - The CLI GUI now handles the new messages for switching pages
  - Handle different data types better by using format instead of string concatenation
* Disable syncing code.
  The sync code at startup outdated and needs to be reworked. Disabling it for now
  to allow better interaction.
* Minor cleanups
  - do not inherit from object
  - use format instead of string concatenations
  - remove duplicated self.loaded
  - correct private member access
* Refactor GUIConnection.show()
   Move the actions into separate methods for better overview of the logic
* Flipped "valid_file" to become "ignored_file"
2018-12-29 21:35:48 -06:00
Steve Penrod 1427992c99 Add basic barge-in functionality
The ability to "barge-in" has been lacking from Mycroft Core.  The Mark 1
microphone was unable to support this due to physical limitations, but the
Mark II and other implementations with more advanced mic tech which can
hear over themselves are able to continuously listen.

To enable this while retaining backwards compatibility with simpler mic.py
systems, there are now two mycroft.conf values:

{
   "listener": {
        "mute_during_output" : true,
        "duck_while_listening" : 0.3
   }
}

The above values are defaults, and implementers will likely override them
using the /etc/mycroft/mycroft.conf file when appropriate.

The duck_while_listening setting is currently handled in Mycroft's
skill-volume.  The mute_during_output is handled within mycroft-core itself.
2018-12-28 18:12:42 -06:00
Åke Forslund 3175baa2eb Stop hotword engines during reload
- Add overridable stop() method to HotwordEngine Class
- Add stop implementation to precise shutting down the runner
- Call wakeword_recognizer.stop() before reloading the listener configuration
2018-12-07 13:28:47 +01:00
Åke Forslund f95ff0a2f3 Remove extra except.
except except Exception -> except Exception
2018-12-05 12:36:53 +01:00
Steve Penrod 1e5ff1392f Feedback from code review
Several small changes based on the code review feedback:
* Drop '_' from classes like Enclosure_Mark1
* Adopt Python 3 style for class definitions and don't explicitly list '(object)'
* Slightly better documentation
* Moved MycroftSkill.show_html() to SkillGUI, resulting in code like self.gui.show_page('Weather.qml')
* Renamed SkillGUI.__dict to SkillGUI.__session_data.  This better reflects the
  how values are accessed in the QML.
2018-12-05 01:40:43 -06:00
Åke Forslund 70655bd9b6 Handle missing "enclosure" section in system config
Default to empty dict instead of None if the "enclosure" section is missing
2018-12-05 07:53:35 +01:00
Steve Penrod 07bd6ef7af Code cleanup
Fixing PEP8 and such before merging into 'dev' branch.
2018-12-03 17:33:26 -06:00
Steve Penrod 0ff744529b * Add tracking of the active namespaces for the GUI. Currently the namespace list
is kept in order, but old namespaces/skills are never culled.
* The active namespace list is synced on a GUIConnection level
* QML display requests now are sent as a list instead of a single entry, i.e.
  with "gui_urls" instead of "gui_url".  Currently a skill can only send a single
  QML, however.
* Change CLI GUI client to handle "gui_urls" instead of "gui_url"
2018-11-30 03:04:53 -06:00
Steve Penrod 685a729994 Enhance CLI GUI client
The GUI client built-in to the CLI now has these features:
* Activate/deactivate via Ctrl+G
* GUI 'window' shows active page title and all namespace variables
* Add fool-proof primitive draw(x,y, msg) that takes care of clipping, and padding
2018-11-23 09:29:16 -06:00
Steve Penrod b9fb463727 Fleshing out GUI mechanisms, CLI "GUI"
Further fleshing out of the GUI mechanisms
* Support for data and page from Mycroft -> GUIConnection
* Add a 'reconnecting' event for the messagebus
* Add MycroftSkill.show_url()
* Plumb MycroftSkill.gui into the messagebus
* Implement MycroftSkill.gui dictionary

CLI extensions for the GUI:
* Can now act as a simple GUIConnection
* Minor revamp of messagebus connection, provides kinder handling when
  messagebus isn't found or ready.
* BUGFIX: An empty filter would filter ALL messages
* BUGFIX: Input wider than the screen would cause a crash
* BUGFIX: "filter" or "find" with no param would filer "filter" or find "find"
2018-11-21 02:05:28 -06:00
Steve Penrod dbd3675156 Fixing a few bugs and adding test code to fire up a weather skill visualization upon GUI connection.
Still very much a work in progress.

For understand and testing, here is the sequence:

STEP 1:  GUI announces itself
* Connect to the main Mycroft messagebus
* Send:  "mycroft.gui.connected" with data { "gui_id": XXX } where XXX is a uniq ID (uuid)

STEP 2:  Mycroft creates GUI socket
* Mycroft extracts the gui_id
* Mycroft prepares a socket and announces its availability on the Mycroft messagebus with:
        self.bus.emit(Message("mycroft.gui.port",
                              {"port": self.GUIs[gui_id].port,
                               "gui_id": gui_id}))

STEP 3:  GUI connects
In python, a very minimal test socket handler on the GUI side would look like this

  from websocket import create_connection

  port = 18181 (from the message above)
     ws = create_connection("ws://0.0.0.0:"+port+"/gui")

  ws.send("Hello, World")
  print("Sent")
  print("Receiving...")
  result =  ws.recv()
  print("Received '%s'" % result)
  ws.close()
2018-11-07 11:06:57 -06:00
Steve Penrod aede71db86 First pass at support for the Qt/QML display:
Enclosures
* Create a mechanism to instantiate unique Enclosure classes, depending on the platform found in the SYSTEM mycroft.conf
* Implement a generic Enclosure, which support the new GUI protocol
* Implement a Mark 1 Enclosure (expects the serial connection to an Arduino)
* Implement the start of a Mark II enclosure
* Implement a generic enclosure (no screen)
* Implement the GUI announcement and protocol basics

MycroftSkill
* Implement the basis of the GUI-controlling interfaces.  Namely:
  - MycroftSkill.show_text()
  - MycroftSkill.show_image()
  - MycroftSkill.show_html()
  - MycroftSkill.show_page()
  - MycroftSkill.gui to set values for page displays.

Configuration
* Add "gui_websocket" to the mycroft.config.py
2018-11-06 01:48:16 -06:00
Steve Penrod 0d64e78d0c Add protection for naive skill authors (#1825)
* Add protection for naive skill authors

It is fairly common for new skill authors to attempt actions in the __init__()
method which are not legal yet, as the Skill has not been fully connected to
the Mycroft system.  This adds an @property protection layer for the two most common
issues:
* Accessing MycroftSkill.bus
* Accessing MycroftSkill.enclosure

Now those are properties instead of variables and provide appropriate warnings
when used before they exist.

Also enhancing the handling of error logs in the CLI to highlight problems such
as this:
* Color "- ERROR -" log messages in red
* Retaining leading characters from log messages, improving readability in formatted messages
2018-10-01 21:41:48 +02:00
Steve Penrod 2efe3eb9ef Fix Ctrl+C and Ctrl+X in CLI (#1826)
* Fix Ctrl+C and Ctrl+X in CLI

There were several quirks in the shutdown of the CLI client:
* Consumed Ctrl+C wasn't being handled cleanly
* main() got called twice, requiring two Ctrl+Cs to exit
2018-09-30 11:14:40 +02:00
Matthew Scholefield a29d00707d Check for a Precise model automatically for custom wake words 2018-09-26 11:14:15 -05:00
Matthew Scholefield c6f9513e9d Allow local model file in precise 2018-09-04 22:59:52 -05:00
Dominik de0bf7d0fd Fix for broken communication with Arduino 2018-09-03 14:50:51 +02:00
Åke Forslund a86359da7f Fix Åkeisms in the code
Updated renamed variables reference everywhere where they were used
2018-08-30 17:10:17 +02:00
Åke 80a37ec46a Move Mark-1 specific image code from api to mark-1 enclosure (#1767)
* Fix removing of the active user

* Move image drawing routines to enclosure client
2018-08-28 14:50:03 -05:00
Åke 85ae69597b Separate enclosure api from enclosure client (#1760)
This is a step towards abstracting the idea of an Enclosure which ties Mycroft to the hardware that is running Mycroft.

- Move the enclosure API to mycroft.enclosure.api (previously was mycroft.client.enclosure.api)
- Move display_manager out of enclosure client to mycroft.enclosure.display_manager
- Merge EnclosureWeather into EnclosureMouth
- Wrap display manager in a class
2018-08-27 13:44:12 -05:00
Åke 0d14e01907 Fix skills listing in CLI (#1759)
Skills list shared the help screen id it was immediately overwritten by
the help.

- Give the skills page a separate page number
- Replace screen id numbers with simple identifiers
- Add simple handling of multiple pages
2018-08-24 00:03:32 -05:00
Åke 64476eb143 Replace emitter/ws with bus (#1757)
Makes the code a bit more understandable
2018-08-21 20:50:50 -05:00
Åke Forslund b41d9edc13 Split text client from __main__
- __main__.py keeps the main setup of hiding stderr/out and argument parsing
- text_client.py contains the actual text client
2018-08-16 20:54:05 +02:00
Åke Forslund a66e23d8ab start processess using python -m
- rename process main.py to __main__.py
- update start-mycroft.sh/stop-mycroft.sh scripts to reflect the change
2018-08-16 15:21:22 +02:00
Åke 13f669d514 Set default encoding in a cleaner way (#1745)
- simplify code setting LC_ALL
- Handle other encodings than utf-8
2018-08-15 17:16:34 -05:00
Steve Penrod 2e873e43bf Change to the supported wait_while_speaking() (#1743)
Code was using the deprecated version from mycroft.util instead of
the mycroft.audio version.
2018-08-15 10:35:50 +02:00
Steve Penrod 46c92e0c36 Fix CLI lockup; simple 'speak' support; help display
Several minor and simple CLI fixes:
* The CLI was locking up with at Lock() deadlock when rebuilding the
  filtered log.
* The simple_cli() wasn't registering handle_speak() on the websocket,
  even though the handler was setup for it.  The utterances are already
  clear from the Input: line or from the logs being printed, so no need
  to have a handle_utterance() registered in the simple_cli() case.
* Help wasn't refreshing the screen, so was invisible.
* An error could be thrown if Ctrl+Z was hit to suspend the 'fg' to
  return to foreground before any key was pressed.
2018-08-14 22:40:08 -05:00
Steve Penrod 1c82945576 Move logs to /var/log/mycroft/ directory
Simplifies permissions and future log-rotations to have all logs
under a single folder instead of having to give permissions to each.
2018-08-02 23:57:13 -05:00
Steve Penrod f329051743 Move logs to /var/log in all cases
Previously, the location of the log files changed depending
on whether you were running on a Mark1/Picroft or under a
"Github" install.  Now they are always under the same directory
at /var/log/mycroft-*.log

This also updates the CLI to pull from that location always.

Additionally:
* Removed the nonfunctional 'wifi' option from start-mycroft.sh
* Made the validation for dev_setup.sh exit instead of just show
  a warning message in start-mycroft.sh
* Added code to allow dev_setup.sh to be run from different
  directories successfully
2018-08-02 21:21:30 -05:00
Steve Penrod 040b64d09d
Fix CLI screen corruption (#1704)
The CLI would often have temporary screen corruption.  This reworks
several things to correct that issue, although it looks like the
ultimate cause was drawing to the screen while in the middle of
waiting on a VT100 ESC keycode sequence.

* Rearchitected all screen drawing to run in a single thread.  Now
  call set_screen_dirty() instead of draw_screen()
* Added a lock on accessing the various Log buffers, preventing
  changes to the buffer in the middle of a redraw
* Modified key reading logic when ESC character is received.  Now
  uses a 1 second timeout if no subsequent keycodes are sent
* Catch several special exceptions.  Curses throws exceptions in some cases during get_wch(), such as
when you Ctrl+Z suspend the CLI the resume the process.  Also moved Ctrl+C processing into this exception handler.
2018-07-30 17:17:48 -05:00
Steve Penrod 223c88b4dd CLI Updates: Restore VT100 support, help, etc. (#1667)
* Restored VT100 function key support
* ESC now clears the entry line
* Spoken commands now become part of the history
* Enhanced help screen with auto word-wrap
* Bugfix: "Show meter" setting didn't persist, now it does
2018-07-12 09:38:29 +02:00
Matthew Scholefield 189e0f10ab Refactor Precise engine and support engine timeouts 2018-07-06 00:05:28 -05:00
Steve Penrod 17aab53fae Enhance the behavior of the Mark 1 button (#1668)
The Mark 1 button press can now be "consumed" when a skill handles
the Stop command.  When this happens, the button press will not
trigger listening mode.  An additional press would be needed to
trigger listening.

This introduces the "mycroft.stop.handled" messagebus message.  It
carries a data field called "by" which identifies who handled it.
Currently the values are "TTS" for when speaking ends or the name
of a skill which implements Stop and returns True from the call.

Also fixed a potential bug when the flag to clear queued visemes
was left set after a button press.
2018-07-05 20:56:54 +02:00
Aditya Mehra 3ae4746099 Feature add query mic status (#1656)
* Feature: Add query mic status

Adds the message bus message `mycroft.mic.get_status` which responds with data on if mic is muted or not.
2018-06-27 15:51:33 +02:00
Åke b1408617bc CLI Feature: skill commands (#1612)
* Update format for skill listing

Now send the skills with id and active status

* Add commands to activate/deactivate skills

* Add "unload all except one" functionallity

* Update after rebasing

- fix identifying skills

* Unload skills if they're removed from disk

* Rename _shutdown to default_shutdown

The method is not intended to be non-public, and this should shut up
codacy bot.

* Handle keep command without argument

* Add new commands to help

- Split help into multiple pages as needed

* Support :activate all
2018-06-22 00:59:51 -05:00
Åke 5d6fd4d871
Merge pull request #1629 from MycroftAI/feature/https-ww-upload
Change wake word upload to https request
2018-06-07 08:58:28 +02:00
Åke b57a0ddb65 Use get_wch() to support unicode input in the CLI (#1609)
The CLI interface should now allow non-ASCII characters, including those used in non-English languages.
2018-06-06 17:02:48 -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 d63a747b9f
Enforce integer for positions in mouth display (#1588)
In python 3 these would default to floats, which trips up the arduino
2018-05-14 11:48:27 +02:00
Åke Forslund 79d183d59f Bump enclosure version to 1.4.0 2018-05-11 14:26:06 +02:00
Åke Forslund bf404b0bbc Fix python3 issues in serial transmission
Added basic conversion between string and bytes for sending data on the serial line.
2018-05-04 11:42:05 +02:00
Matthew D. Scholefield 78a6ec1ceb Fix cli crash with Python 3
This worked in Python 2 because type(4 / 2) == int but in Python 3 type(4 / 2) == float
2018-04-27 08:56:47 -05:00
Åke Forslund a2993e4ba6 Remove backwards compatibility with python 2.7 2018-04-27 08:51:47 -05:00
Åke Forslund d4ba484ad9 Make text client python2/3 compatible
- Make str unicode string
- Use BytesIO for python2 and StringIO for python3
2018-04-27 08:50:46 -05:00
Åke Forslund c6584d603d Make speech client python3 compatible 2018-04-27 08:50:46 -05:00