The SUSI smart speaker supports playing local music from any USB device connected to the smart speaker. To play your favourite music directly from files, just put them in a thumb drive and plug it into any one of the four USB ports on the smart speaker. SUSI can either play all songs from the USB device or songs from a specific artist, genre or album.
The first thing that needs to be done is to automount the thumb drive in the smart speaker, for this the usbmount package is used. Further, after the mount is done local skills are created which are then used by the SUSI server to interpret voice commands related to offline music playback.
The code which enables the above functionality is :
- Add dependency – https://github.com/fossasia/susi_installer/blob/1a2950b0eb1f88d4ecbd5b3c348d9b67ac2f4705/install.sh#L287
|# usbmount is needed to automount usb drives on susibian(raspbian lite)|
if [ $targetSystem = raspi ] ; then
DEBDEPS=”$DEBDEPS hostapd dnsmasq usbmount”
USB mount is added to the dependency list if the installer is running on a Raspberry
- Enable offline skills – https://github.com/fossasia/susi_installer/blob/1a2950b0eb1f88d4ecbd5b3c348d9b67ac2f4705/install.sh#L881
|mkdir -p $WORKDIR/susi_server_data/generic_skills/media_discovery|
mkdir -p $WORKDIR/susi_server_data/settings
echo “local.mode = true” > $WORKDIR/susi_server_data/settings/customized_config.properties
Enable the server to work with offline skills stored on the device. The new skills related to offline music playback are stored in /susi_server_data/generic_skills/media_discovery in a file named custom_skill.txt.
- Creating on the fly skills – https://github.com/fossasia/susi_installer/blob/1a2950b0eb1f88d4ecbd5b3c348d9b67ac2f4705/install.sh#L758
|echo “Preparing USB automount”|
# systemd-udevd creates its own filesystem namespace, so mount is done, but it is not visible in the principal namespace.
sudo mkdir /etc/systemd/system/systemd-udevd.service.d/
echo -e “[Service]\nPrivateMounts=no” | sudo tee /etc/systemd/system/systemd-udevd.service.d/udev-service-override.conf
# readonly mount for external USB drives
sudo sed -i -e ‘/^MOUNTOPTIONS/ s/sync/ro/’ /etc/usbmount/usbmount.conf
sudo cp $INSTALLERDIR/raspi/media_daemon/01_create_skill /etc/usbmount/mount.d/
sudo cp $INSTALLERDIR/raspi/media_daemon/01_remove_auto_skill /etc/usbmount/umount.d/
First an override rule is added, which changes `PrivateMounts` rule’s value to `no` in /lib/systemd/system/systemd-udevd.service. PrivateMounts if set to yes, the processes of this unit will be run in their own private file system (mount) namespace with all mount propagation from the processes towards the host’s main file system namespace turned off. This means any file system mount points established or removed by the unit’s processes will be private to them and not be visible to the host. To learn more about mount namespaces read –
Next, whenever a device is mounted the 01_create_skill file is executed which contains the following instruction:
|python3 /home/pi/SUSI.AI/susi_installer/raspi/media_daemon/auto_skills.py “$UM_MOUNTPOINT”|
This calls the auto_skills.py file with the mount point of the storage device.
The auto_skills.py file is used to generate audio skills for the USB drive. It scans for all the files in the USB thumb drive and creates relevant skills.
Whenever the thumb drive is removed it calls out the 01_remove_auto_skill script which has the following instruction –
|echo -n > /home/pi/SUSI.AI/susi_server_data/generic_skills/media_discovery/custom_skill.txt|
This cleans out the custom_skills.txt file i.e. all the offline skills that were created for music playback are removed and the server no longer responds those skills.
Play all music on the USB device
Usage: SUSI, Play Audio
This will play all audio from the USB device connected to the speaker. SUSI Smart speaker currently supports the following audio formats:
Play All Songs From an Artist
Usage : SUSI, play <artist_name> from USB
Example : SUSI, play Linkin Park from USB
This will play and queue all songs from the given artist if found on the USB device.
Play a Specific Music Genre
Usage : SUSI, play <Genre> from USB
Example : SUSI, play Hard Rock from USB
This will play and queue songs from the USB device that matches the given genre.
Play an Album
Usage : SUSI, play <album_name> from USB
Example : SUSI, play Hybrid Thoery from USB
This will play and queue songs from a specific Album Name.
Note: The above three skills depend on the metadata of the file. The file should have relevant metadata for these skills to work.
Usage : SUSI, <control_keyword>
Example : SUSI, pause or SUSI, resume
Available Music Playback Control keywords
- Pause : Pause the currently playing music
- Resume : Resume the currently playing music if paused
- Restart : Restart the currently playing Music
- Next : Go to the next song in the current playlist
- Previous : Plays the previous song in the current playlist
- Shuffle : Shuffles all songs in the current playlist and play again
Note : Playlist is made for offline Music skills such as play audio or play album from USB.
SUSI Smart Speaker, SUSI.AI, FOSSASIA, GSoC19
You must log in to post a comment.