Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Conversation

@forslund
Copy link
Collaborator

In late November @penrods led a discussion about how an audio service in Mycroft could work. This is a simple implementation of what was discussed. This is a quick implementation of the system as I understood it and I think this can be used to continue the discussion. Ideas and suggestions on improvements are very welcome.

The PR adds support for commands like

"Hey Mycroft, play the news in the livingroom"

Backends

The current system includes support for the following "backends"

  • Mpg123, very limited implementation
  • VLC
  • Mopidy

"backends" currently in the works:

  • Chromecast
  • Kodi

Backends are quite easy to add and an existing baseclass can be extended to add new ones.

AudioService

Skill creators will use an audio service interface to communicate with the audio service / playback control. the AudioService interface uses the standard message bus.

from mycroft.skills.audioservice import AudioService
[...]
  as = AudioService()
[...]
  as.play(file_or_uri) # handles both lists and single uris

See the npr_news skill for basic usage.

The AudioService currently only support play and track_info requests but this will probably be expanded for increased usefulness.

Playback control skill

Features:

  • backend/location selection from utterance ("...in kitchen" etc.)
  • lowering volume while Mycroft speaks
  • playback control (Pausing/Resuming, skipping, Stopping)

The backend/location selection is currently done using basic string parsing and should probably be done using adapt instead.

This skill removes much of the basic functions that needs to be implemented for an audio playback skill and the skill creator can focus on the trickier parts.

Currently most of the audio logic is implemented in the playback control skill and should maybe be moved but this was a good starting point.

Configuration

A Configuration the audio services:

{
  "Audio": {
    "backends": {
      "local": {
        "type": "mpg123",
        "active": true
      },
      "kitchen": {
        "type": "mopidy",
        "url": "http://localhost:6680",
        "active": true
      },
      "livingroom": {
        "type": "mopidy",
        "url": "http://192.168.10.232:6680",
        "active": false
      },
      "vlc": {
        "type": "vlc",
        "active": true
      }
    },
    "default-backend": "local"
  }
}

If you try it I suggest you install vlc and pyvlc and use the vlc backend since mpg123 only has basic functionallity.

I've tested this mainly with the mopidy skill and the npr_news skill.

Todo

  • more backends, Kodi and chromecast is a minimum
  • possibly separate the backends from the playback control skill
  • populate the AudioService interface with more functions so skill creators can do more interesting things with the audio (A music quiz-skill should be able to skip ahead in the playlist when a correct answer is provided)
  • More configuration options
  • Maybe some way to send credentials from a skill to the backend to access some music services
  • Better utterance parsing when starting playback, along with more keywords (like half volume)

@forslund
Copy link
Collaborator Author

Major refactoring done after discussion with @ethanaward. The audio backends now runs separately from the skills. The loading of backends is now done using a method similar to how the skills work and should be easy to extend to include thirdparty backends.

@forslund
Copy link
Collaborator Author

Skills using the audio service interface
NPR news:
https://github.com/forslund/skill-npr-news/tree/audio-service
Ethan's demo skill:
https://github.com/forslund/demo_skill/tree/audio_service/
play all using vlc to enque all tracks and play using vlc for example

most important, the playback control skill:
https://github.com/forslund/playback_control_skill

The playback control skills implement the common commands for skills using the audio service. like skipping tracks, pausing and resuming. The idea is that the skill creator only needs to implement the finding of audio files and the command that starts playback. (The other commands are of course available to the skill creator if they wish to use them)

@augustnmonteiro augustnmonteiro added Status: To be reviewed Concept accepted and PR has sufficient information for full review status: waiting for conflict fix labels Apr 26, 2017
@augustnmonteiro augustnmonteiro self-requested a review April 26, 2017 17:10
@coveralls
Copy link

Coverage Status

Coverage decreased (-4.6%) to 30.071% when pulling c981119 on forslund:audio-service into 52af555 on MycroftAI:dev.

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.6%) to 31.641% when pulling 104621e on forslund:audio-service into d68b1dd on MycroftAI:dev.

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.6%) to 31.622% when pulling 306bbf5 on forslund:audio-service into 60867fc on MycroftAI:dev.

@forslund
Copy link
Collaborator Author

Finally rebased, phew

logger.info('no default found')
logger.info('Default:' + str(default))

ws.on('MycroftAudioServicePlay', _play)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change to mycroft.audio.service.play like the others mycroft events

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.6%) to 31.622% when pulling 5df592e on forslund:audio-service into 60867fc on MycroftAI:dev.

forslund added 23 commits July 31, 2017 13:37
Pause, resume, next and previous added to the interface.
The play method was updated to add 'file://' to uri's lacking uri type.
As requested by Augusto Monteiro
Removes the cases where the process keeps playing in the background
when a new track is started.
* import Message to allow audio service to reply info
* Add default message to audio service class
when the audio configuration option "pulseaudio" is set to mute running
audio streams will be muted while mycroft is speaking and while mycroft
is listening.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 41.367% when pulling 9c49f97 on forslund:audio-service into edbd8ed on MycroftAI:dev.

@penrods
Copy link
Contributor

penrods commented Aug 1, 2017

So why isn't this merged yet! Reviewed by Augusto, merge away!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 41.385% when pulling df18f42 on forslund:audio-service into edbd8ed on MycroftAI:dev.

@forslund forslund merged commit e1a1751 into MycroftAI:dev Aug 1, 2017
@augustnmonteiro
Copy link
Contributor

@penrods I reviewed before the last release and didn't merged to that release and forgot to merge after the release is done, Sorry @forslund

@forslund forslund deleted the audio-service branch January 31, 2018 07:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants