USB Music Skill - testing and feedback

usbmusic USB Music
Play Music from a USB device with


Play local music by inserting a USB drive into your Mycroft device. Upon Inserting a USB Device Mycroft
will scan the device for MP3 music and add it to a temporary library that you can play.


If autoplay is enabled in the websettings then the usb music will begin playing imediatly when inserted.
Unplugging the usb will automatically stop and unmount the device.

Command Examples

  • “play the artist elvis Presley”
  • “play all shook up”
  • “play the song blue suede shoes”
  • “play the album appeal to reason”





#music, #usb,, #python, #skills, #mp3, #CPS


Tested on platform_picroft (others untested)

Other Requirements

Installation Notes


  • Add “next/previous” commands
  • Add “random” selection
  • Add thumbnails for display
  • …?


  • I have only tested this on picroft so feedback on other devices is very much welcome.
  • provide feedback in this Topic
  • provide feedback in github

Nice skill, wondering if it would be possible to make it run from an smb share instead of the usb drive (with a settings to select the path). Mixed with CMDSkill to mount the path it could auto play. I havent looked at the code yet but I am pretty sure this could be done

1 Like

So I got this working as a test… Sort of… be warned it took a bit of time to load the library in my test case, I don’t know how many songs you have but I am going to need to optimize things and clean up the code a bit. If you are adventurous, update to the latest build “msm update” then update your websettings with your smb share and then issue the command “load network music” and be prepared to wait if you have a large library (maybe try a smaller share first)

Great I will give it a try tomorrow. Thumbs up !

Cool skill, I have some questions:

That means it will copy locally the items or it creates an m3u pointing to the right place? (USB, SMB/whatever future path)

What about other formats like flac, ogg, etc?

What about, if you are willing to create a similar skill for videos, to create a meta-skill “USB-load” which scans the USB (or network path, but we’re speaking of USB) and determine how many audio files and video files are present on the device and playing it accordingly? My ideal skill would be one which scans the media and you can tell something like “play 12 monkeys movie on living TV’s Kodi” or “play the artist elvis presley (locally)”

I do not copy the files to a temporary area. Currently my approach for the “library” is to create a mount point then scan the mount point for mp3 data. I then create a dict of the data that I index when a request is made. The dict list consists of the following data for each found item.

info = {
                        "location": song_path,
                        "label": self.song_label,
                        "artist": self.song_artist,
                        "album": self.song_album

it does take some time to index all the items. and I am not sure at this point if this is a blocking event. I will need to do some testing to be sure. I will look into the flac, ogg, as far as the movies I am just about ready to release my revamped kodi skill and it should cover off some of those items.

For those interested, I have updated this skill with the following new features.


Play local music sources (USB, SMB, Local)

  1. Inserting a USB drive into your Mycroft device. Upon Inserting a USB Device Mycroft
    will scan the device for playable music and add it to a temporary library that you can play upon request.
  2. Adding an SMB source will let you play music from that source.
  3. Adding a local path source will let you play music from that source.
  4. Supports the following music formats ‘mp3’, ‘m4a’, ‘flac’, ‘wav’, ‘wma’,‘aac’


If AutoPlay is enabled in the websettings then the USB music will begin playing immediately when inserted.
Unplugging the usb will automatically stop and unmount the USB device.
AutoPlay only functions with USB sources, not SMB or Local Path.

1 Like

I have made another small update to this skill.
This change lets you add a command that will automatically be pushed to the messagebus (invoking another skill) when the USB has been inserted.

Automatic Insert Command Request

If enabled the skill will automatically send a command to the messagebus
when the USB is inserted.
Why not?
This will let you do all sorts of things with this skill by invoking other skills when the USB is inserted.

  • You have a running playlist that is stored on a USB stick.
  • You insert the USB before you jump on the treadmill.
  • The insertion automatically issues the following command to the messagebus
  • “set a timer for 20 minutes”
  • Now you have workout music and a timer to notify you when your workout is complete.

As always feedback / bug reports can be added to this thread.

Thank you very much for developing this skill! I finally got it to work on an RPi 3B+ while also running MagicMirror, and it is exactly what I was hoping for. One of the major challenges was getting those two to work together, particularly python modules pyudev and mutagen going where they belong. This was solved using the command sudo ./mycroft-pip install pyudev within the /mycroft-core/bin directory to install pyudev into the correct location, sudo ./mycroft-pip install mutagen for mutagen, and ./mycroft-msm install to install the main skill. No, I am not using mycroft in an virtual environment - it would not play nice with the MagicMirror code.
I would like to make a few minor tweaks to the code so that when playing albums, they are played in track order. I know that it is possible to sort the array of music files before sending them to VLC to play, but I cannot locate where you invoke that call to VLC. Can you please point out where you call VLC and what the array of songs are?
Again, thank you very much for your efforts!!!
Very respectully,

I think the command is executed by myCroft itself. It is parameterized, like with your sound settings. The command to play an audio file is somewhere easy in the python code for usbMusic player. I dug through it long ago, didnt take me long to figure it out.

I have not had much personal development time on mycroft over the past while so things have been somewhat stagnate. I will see if I can have a look at the code later today and provide you what you are requesting. I recall I had randomized the the list at some point.

I think this is what are looking for.
Just remove random.shuffle(tracklist) and it should play based on the order of the album list.

It may be possible to add this as an option in the web configuration, if I can find the time.
enable / disable album shuffling

Thank you very much for the suggestion. That is spot on what I was looking for!

As you suggested, I first commented out the line random.shuffle(tracklist). After rebooting, I noticed that it still did not have the desired effect of playing the album tracks in order. Then I added a line to explicitly sort the files tracklist.sort() in place of the line random.shuffle(tracklist), and it all works as desired.

Of course, this assumes that the album files are named “01 - song 1 title.mp3”, “02 - song 2 title.mp3”, and so on, which makes the sorting very easy. In some cases, I don’t need to make any changes to the file names. In other cases, I will have to manually (or using a software tool like MediaMonkey) to change the files names. That said, I am currently investigating importing the track number tag from the ID3 metadata and then sorting the tracklist array based on that. eyeD3 appears to be the correct python module for that, however mutagen appears to support similar reading of the ID3 tags. Any suggestions would again be most appreciated.

Again, thank you very, very much for your help and your development!

With utmost respect,

Glad you got it working. If you make some modifications and want issue a pull request on Github, feel free to do that as well and I will get it merged.

Hi all,
I have installed Mycroft on a Linux Mint VM. Now I’m trying to install your USB Music skill, but I got this error message:

19:28:43.234 | ERROR    |  3229 | mycroft.skills.skill_loader:_load_skill_source:278 | Failed to load skill: usb-music.pcwii (RuntimeError('dictionary keys changed during iteration'))
Traceback (most recent call last):
  File "/home/michael/mycroft-core/mycroft/skills/", line 276, in _load_skill_source
    skill_module = load_skill_module(main_file_path, self.skill_id)
  File "/home/michael/mycroft-core/mycroft/skills/", line 72, in load_skill_module
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/mycroft/skills/usb-music.pcwii/", line 32, in <module>
    for each_module in sys.modules:
RuntimeError: dictionary keys changed during iteration
 19:28:43.245 | ERROR    |  3229 | mycroft.skills.skill_loader:_communicate_load_status:351 | Skill usb-music.pcwii failed to load

I hope you can help me, @pcwii

Greetings form Austria :slight_smile:

It would be a good idea to change the requirements’ installation guide on your GitHub page to:

mycroft-pip install pyudev
mycroft-pip install mutagen
sudo apt-get install vlc
sudo reboot
mycroft-msm remove
mycroft-msm install

Otherwise, you get some error messages saying that mutagen and pyudev are not installed.