Build your own voice-controlled karaoke station.

Sing your heart out with this voice-controlled Karaoke App for Raspberry Pi!

Mennad Yami
Snips Blog
Published in
7 min readNov 23, 2018

--

The Snips console empowers you to create voice assistants that can hear, understand, and react to your demands. Today we’ll explore how to set up and use a karaoke voice assistant on a Raspberry Pi. This karaoke app will be able to scan at your video files, list them back to you, and understand commands such as “let’s sing Billie Jean” or “I want to hear some Eminem”. It will also allow you to control the video playback through voice instructions!

The following walkthrough doesn’t require any technical knowledge beyond accessing your computer terminal and executing commands from there. We’ll explain step by step how to set up the Pi, install the Snips platform, and the karaoke assistant.

📐 Requirements for this project

  • A Raspberry Pi. We’re using a Raspberry Pi 3 for the tutorial that you can find for around $35. You also need a compatible micro-usb charger.
  • A micro SD card of at least 4Gb, with a way to read-write it from your computer.
  • A microphone for your Raspberry. We use the Seed ReSpeaker 2-Mics Pi HAT (~$10), but any Pi-compatible microphone will do the job.

📦 For those who don’t have the necessary equipment and want to get it all at once, Snips sells the Maker Kit, everything you need packaged together 📦.

This tutorial expects you to have a unix-like terminal, and git already installed (if you’re on Mac or Linux, you already have them pre-installed). NodeJs should be installed on your computer. If you’re not sure about it, type node -v in your terminal. This will give your current nodeJs version or an error if it’s not installed.

📖 Walkthrough

First things first, your Pi needs to be correctly set up in order to receive your assistant. You’ll burn an operating system to your micro SD card, then install the Snips Platform.

💾 Install an OS

Raspberry Pis don’t have long-term memory storage by default, so your SD card will play the role of a hard disk and store your operating system. The OS we’ll install is a special version of Debian Linux for Raspberry Pi that is called Raspbian. You just need the lite version of it because we won’t need the Raspbian graphical interface. You also want to download Etcher, a tool that will burn the OS on your memory card.

Let’s now get access to your memory card from your computer’s card reader and launch Etcher. Select the Raspbian image file to burn and hit “Flash”.

Burn your image file on your SD card with Etcher.

Once your card is flashed, remove it and put it back in your computer. Its name should be “boot”. You need to enter inside this volume and create 2 files at its root (its base directory). You’ll call the first file ssh and the second one wpa_supplicant.conf. Or you can just run the following commands from your terminal:

cd /Volumes/boot
touch ssh
touch wpa_supplicant.conf

You’ll need to paste the following content in the wpa_supplicant.conf to set up the Raspberry’s wifi connection. Don’t forget to replace the ssid and the psk with your wifi network’s name and its password, paying attention to spelling mistakes, case sensitivity, etc.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevnetwork={ssid=”<Your wifi network name>”psk=”<Your wifi network password>”}

You can use any text editor to modify this file, but be sure to keep its name and extension. This will make your Pi connect to your wifi network when detected. You’ll then be able to control your device via the ssh protocol if your computer is connected to the same network. You can now put the memory card back in your device and turn it on. By default, your Pi’s hostname is raspberrypi, your default user is pi and your password is raspberry.

In order to run correctly, your karaoke app requires some modules to be installed on your Pi. Copy-paste the following instructions to install the packages that you need. Don’t forget to fill in the gaps with your credentials. Eventually type Y when asked for it. If an ssh connection attempt gets stuck infinitely, you might want to check the wifi credentials you wrote on the memory card.

ssh <user>@<hostname>.local '
sudo apt-get update;
sudo apt-get install nodejs;
sudo apt-get install fim;
sudo apt-get install omxplayer'

Your Pi’s environment is set up, you’re now ready for Snips!

🔉 Install Snips platform

A Snips assistant is the association of two elements. On the one hand, the Snips platform is all you need on your device in order to detect and understand voice queries. So everything that concerns the Snips platform in this tutorial can be generalized to other Snips projects. On the other hand, an assistant is the customized brick that will process and react to your needs in particular. In this project, we’ll install the karaoke assistant.

You could manually install each of these elements but thankfully, the Snips team built a convenient tool called Sam that does most of the work.

First, let’s create your assistant in the Snips console.

Creating a new assistant on the Snips console

Once you’re signed up and you’ve activated your account, you can create your first assistant. Give it a name and choose English as its language. This assistant doesn’t do anything for the moment, so your next step is to strengthen it with one of the pre-built apps from the Snips app store.

Add the Karaoke app to your new assistant.

Look for the Karaoke app by using the search bar. As you can see by looking at the other available apps, you could also turn your Pi into a voice controller for your coffee machine, your TV, or your lights!

Your assistant is ready to go, let’s transfer everything on your Pi. You’ll use Sam, the “Snips Assistant Manager” that saves you the hassle of installing assistants manually on your Pi. Run this terminal command to download it sudo npm install -g snips-sam, and type in your computer’s password if asked to do so. If this doesn’t work, maybe you need to check that npm is installed on your computer by running npm -v. Npm should come with NodeJs.

If everything went well, you can now use Sam from your terminal in the following way:

  • Connect to your Raspberry Pi with sam connect <hostname>.local. Don’t forget to replace your Pi’s hostname, and type its username and password when prompted.
  • Install the latest version of the Snips platform with sam init (this might take a few minutes).
  • Run sam setup audio to select your microphone and your audio output. For the latter, you need to choose the HDMI output (the second one).
  • Log in to your Snips Console account with sam login.
  • Install the assistant that you created earlier with sam install assistant.

Last step! The following command allows your assistant to display images and videos, and to dynamically recognize your songs and artists’ names:

ssh <username>@<hostname>.local '
sudo usermod -a -G video _snips-skills;
FILE=/lib/systemd/system/snips-skill-server.service;
SUB="s/ReadWritePaths.*/&\ \/tmp\//";
sudo grep -q "/tmp/" $FILE || sudo sed -i "$SUB" $FILE;
sudo apt-get install -y snips-injection'

🎙Play Karaoke!

Your karaoke assistant is ready to go, but it doesn’t have any video to play with yet :(

In order to transfer video files to your Pi, you need to know their path. You can just drag a file to your computer’s terminal window to make its path appear. Then type the following command, filling the corresponding gaps with your credentials:

scp <path to your file> <username>@<hostname>.local:/var/lib/snips/skills/karaoke/videos

Your files should respect the following conditions:

  • They should be .mp4 video files
  • Their name should respect the format <name of the artist> — <name of the song>.mp4
  • The total size of your videos should preferably not exceed the total size of your SD card minus 2 Gb!

Plug your Pi to an HDMI screen and reboot, your Karaoke is alive ;).

How to use it?

  • Any instruction that you give should start with “Hey, Snips!”. A feedback sound will be played if this wake word was recognized.
  • You can ask Snips to play any given song by giving the artist name, the song name, or both. This works both at the main menu and while another video is playing. It understands instructions such as “Play me some Michael Jackson”, “I want to listen to the song Beat it”, “Let’s sing Billie Jean”, etc.
  • You can also control the playback through voice instructions to your karaoke. It can jump to the previous or to the next song, or go back to the main menu / songs list.
  • You can also control your karaoke’s volume in that same way. You’re able to ask for a volume increase or decrease and to mute or unmute it.

When you want to turn it off, just unplug your Raspberry Pi. Happy singing!

If you liked this article and want to support Snips, please share it!

Follow us on Twitter: @Snips

If you want to work on AI + Privacy, check our Jobs Page

--

--