xuancong84 / pikaraoke

The World's best open-source Home Karaoke system (support searching/downloading from Youtube and DNN-AI-based vocal/nonvocal sound separation), multilingual and cross-platform
GNU General Public License v3.0
47 stars 6 forks source link
karaoke karaoke-application karaoke-player

Disclaimer: This repository has been deprecated and migrated to https://github.com/xuancong84/OpenHomeKaraoke for futher updates and enhancements.

PiKaraoke (The World's best open-source Python-based YouTube Karaoke system)

This is the world's best open-source Python-based YouTube Karaoke system up to today (2022.4), forked from @vicwomg's repo (thanks) and thoroughly revamped and incorporated @tsurumeso's DNN-based (deep neural network) vocal splitter (thanks to https://github.com/tsurumeso/vocal-remover). PiKaraoke is a "KTV"-style Karaoke song search and queueing system. It connects to your TV either via an HDMI cable, or screen sharing, or using TV's web-browser (backend KTV player is screen-captured and streamed to HTTP), and shows a QR code for computers and smartphones to connect to a web interface. From there, multiple users can seamlessly search your local track library, queue up songs, add an endless selection of new Karaoke tracks from YouTube, and more. Works on Raspberry Pi, OSX, Windows, and Linux! See a demo on YouTube: Img alt text

Key Features

Screenshots

TV

pikaraoke-tv1 pikaraoke-tv1 pikaraoke-tv2 pikaraoke-sc1

Web interface

pikaraoke-nowplaying pikaraoke-queue pikaraoke-download
pikaraoke-browse pikaraoke-search1 pikaraoke-language

Supported Devices

This should work on Windows, Linux machines and all Raspberry Pi devices (multi-core models recommended). @vicwomg did most development on a Pi Zero W and did as much optimization as he could handle, while I did all the revamp work on Ubuntu/Linux, Mac OS and Windows. However, certain things like concurrent downloads and browsing big song libraries might suffer. All this runs excellently on Windows, Linux and RPi (3 and above).

Installation

Pre-built Raspberry Pi image

If you're on a Raspberry Pi, you might want to just use the pre-built image to save time installing dependencies:

Manual install

Firstly, for all OS:

Raspberry pi

Run the setup script:

./setup-pi.sh

You will then probably need to reboot since this changes a boot setting (gpu_mem=128). This is to prevent certain videos from showing visual artifacts (green pixel distortion)

sudo reboot

Linux / OSX

Windows

Note: if you have trouble installing pygame, there's apparently an incompatibility with Python 3.8. Try upgrading to the latest python version or downgrading to 3.7.

Launch

On Linux/Mac-OS, run:

cd into the pikaraoke directory and run: PATH=~/anaconda3/bin:$PATH ./run.sh

On Raspberry Pi:

sudo env PATH=<anaconda3-bin>:$PATH python3 app.py

You must run as sudo on pi devices if you are running directly from the console since PiKaraoke uses pygame to control the screen buffer. You can probably run as non-sudo from the Raspbian desktop environment, but may need to specify a different download directory than the default with the -d option.

On Windows:

In Anaconda3's prompt/powershell, cd to the pikaraoke directory and run:

python3 app.py -d <your-song-download-folder>

The app should launch and show the PiKaraoke splash screen and a QR code and a URL. Using a device connected to the same wifi network as the Pi, scan this QR code or enter the URL into a browser. You are now connected! You can start exploring the UI and adding/queuing new songs directly from YouTube.

Usage

Here is the full list of command line arguments on OSX as an example (may not be up to date, run python3 app.py --help for the latest):

usage: app.py [-h] [-u NONROOT_USER] [-p PORT] [-d DOWNLOAD_PATH] [-o OMXPLAYER_PATH] [-y YOUTUBEDL_PATH] [-v VOLUME] [-V] [-nv] [-s SPLASH_DELAY] [-L LANG]
              [-l LOG_LEVEL] [--hide-ip] [--hide-raspiwifi-instructions] [--hide-splash-screen] [--adev ADEV] [--dual-screen] [--high-quality]
              [--use-omxplayer] [--use-vlc] [--vlc-path VLC_PATH] [--vlc-port VLC_PORT] [--logo-path LOGO_PATH] [--show-overlay] [-w] [-c BROWSER_COOKIES]
              [--admin-password ADMIN_PASSWORD] [--developer-mode]

optional arguments:
  -h, --help            show this help message and exit
  -u NONROOT_USER, --nonroot-user NONROOT_USER
                        Since tmux must be launched by a non-root user (to run pacmd to select recording source), this is required for sending keys to tmux.
  -p PORT, --port PORT  Desired http port (default: 5000)
  -d DOWNLOAD_PATH, --download-path DOWNLOAD_PATH
                        Desired path for downloaded songs. (default: /home/xuancong/pikaraoke-songs)
  -o OMXPLAYER_PATH, --omxplayer-path OMXPLAYER_PATH
                        Path of omxplayer. Only important to raspberry pi hardware. (default: /usr/bin/omxplayer)
  -y YOUTUBEDL_PATH, --youtubedl-path YOUTUBEDL_PATH
                        Path of youtube-dl. (default: /home/xuancong/anaconda3/bin/yt-dlp)
  -v VOLUME, --volume VOLUME
                        If using omxplayer, the initial player volume is specified in millibels. Negative values ok. (default: 0 , Note: 100 millibels = 1
                        decibel).
  -V, --run-vocal       Explicitly run vocal-splitter process from the main program (by default, it only run explicitly in Windows)
  -nv, --normalize-vol  Enable volume normalization
  -s SPLASH_DELAY, --splash-delay SPLASH_DELAY
                        Delay during splash screen between songs (in secs). (default: 3 )
  -L LANG, --lang LANG  Set display language (default: None, set according to the current system locale en_US)
  -l LOG_LEVEL, --log-level LOG_LEVEL
                        Logging level int value (DEBUG: 10, INFO: 20, WARNING: 30, ERROR: 40, CRITICAL: 50). (default: 20 )
  --hide-ip             Hide IP address from the screen.
  --hide-raspiwifi-instructions
                        Hide RaspiWiFi setup instructions from the splash screen.
  --hide-splash-screen  Hide splash screen before/between songs.
  --adev ADEV           Pass the audio output device argument to omxplayer. Possible values: hdmi/local/both/alsa[:device]. If you are using a rpi USB
                        soundcard or Hifi audio hat, try: 'alsa:hw:0,0' Default: 'both'
  --dual-screen         Output video to both HDMI ports (raspberry pi 4 only)
  --high-quality, -hq   Download higher quality video. Note: requires ffmpeg and may cause CPU, download speed, and other performance issues
  --use-omxplayer       Use OMX Player to play video instead of the default VLC Player. This may be better-performing on older raspberry pi devices. Certain
                        features like key change and cdg support wont be available. Note: if you want to play audio to the headphone jack on a rpi, you'll
                        need to configure this in raspi-config: 'Advanced Options > Audio > Force 3.5mm (headphone)'
  --use-vlc             Use VLC Player to play video. Enabled by default. Note: if you want to play audio to the headphone jack on a rpi, see
                        troubleshooting steps in README.md
  --vlc-path VLC_PATH   Full path to VLC (Default: /usr/bin/cvlc)
  --vlc-port VLC_PORT   HTTP port for VLC remote control api (Default: 5002)
  --logo-path LOGO_PATH
                        Path to a custom logo image file for the splash screen. Recommended dimensions ~ 500x500px
  --show-overlay        Show overlay on top of video with pikaraoke QR code and IP
  -w, --windowed        Start PiKaraoke in windowed mode
  -c BROWSER_COOKIES, --browser-cookies BROWSER_COOKIES
                        YouTube downloader can use browser cookies from the specified path (see the --cookies-from-browser option of yt-dlp), it can also be
                        auto (default): automatically determine based on OS; none: do not use any browser cookies
  --admin-password ADMIN_PASSWORD
                        Administrator password, for locking down certain features of the web UI such as queue editing, player controls, song editing, and
                        system shutdown. If unspecified, everyone is an admin.
  --developer-mode      Run in flask developer mode. Only useful for tweaking the web UI in real time. Will disable the splash screen due to pygame main
                        thread conflicts and may require FLASK_ENV=development env variable for full dev mode features.

Screen UI

Upon launch, the connected monitor/TV should show a splash screen with the IP of PiKaraoke along with a QR code.

If there's a keyboard attached, you can exit pikaraoke by pressing "esc". You can toggle fullscreen mode by pressing "f"

Make sure you are connected to the same network/wifi. You can then enter the shown IP or scan the QR code on your smartphone/tablet/computer to open it in a browser. From there you should see the PiKaraoke web interface. It is hopefully pretty self-explanatory, but if you really need some help:

Web UI

Home

Queue

Songs

Info

Troubleshooting

I'm not hearing audio out of the headphone jack

By default the raspbian outputs to HDMI audio when it's available. Pikaraoke tries to output to both HDMI and headphone, but if it doesn't work you may need to to force it to the headphone jack. This is definitely the case when using VLC. To do so, change following setting on the pi: sudo raspi-config Advanced Options > Audio > Force 3.5mm (headphone)

See: https://www.raspberrypi.org/documentation/configuration/audio-config.md

If you're still having issues with hearing audio, it has been reported this helps on raspberry pi 4 devices:

sudo nano /usr/share/alsa/alsa.conf

Scroll down and change defaults.ctl.card and defaults.pcm.card to "1"

defaults.ctl.card 1
defaults.pcm.card 1

Note this value might be different in older versions of Raspbian or if you have external audio hardware. See source article for details: https://raspberrypi.stackexchange.com/a/39942

I'm still having audio issues with the headphone jack, external sound card, or other audio device with omxplayer

If using omxplayer with --use-omxplayer, it tends to have some inconsistent results across different hardware combinations. Try experimenting with the --adev option, which specifies the audio device to omxplayer. Defaults to 'both' which is hdmi and headphone out. Other possible values are: hdmi/local/both/alsa[:device].

If you're hearing distorted audio output, try '--adev alsa' with omxplauer.

If you're using an external USB sound card or hifi audio hat like the hifiberry, you'll need to add the argument '--adev alsa:hw:0,0' when you launch pikaraoke

Songs aren't downloading!

Make sure youtube-dl is up to date, old versions have higher failure rates due to security changes in Youtube. You can see your current version installed by navigating to Info > System Info > Youtube-dl version. The version number is usually the date it was released. If this is older than a couple of months, chances are it will need an update.

You can update youtube-dl directly from the web UI. Go to Info > Update Youtube-dl (depending on how you installed, you may need to be running pikaraoke as sudo for this to work)

Or, from the CLI (path may vary): yt-dlp -U or pip install yt-dlp -U

I brought my pikaraoke to a friend's house and it can't connect to their network. How do I change wifi connection without ssh?

These are my preferred ways to do it, but they might require either a USB keyboard or a computer with an SD Card reader.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Your 2-letter country code, ex. US>
network={
  ssid="<the wifi ap ssid name>"
  psk="<the wifi password>"
  key_mgmt=WPA-PSK
}

Add the SD card back to the pi and start it up. On boot, Raspbian should automatically add the wpa_supplicant.conf file to the correct location and connect to wifi.

Can I run PiKaraoke without a wifi/network connection?

Actually, yes! But you can only access your existing library and won't be able to search or download new songs from the Internet, obviously.

If you run your Pi as a Wifi access point, your browser can connect to that access point, and it should work. See: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

Or an even easier approach, if you install this: https://github.com/jasbur/RaspiWiFi (used for configuring wifi connections headless, see above). While it's in AP mode, you can connect to the pi as an AP and connect directly to it at http://10.0.0.1:5000

Where do I plug in a microphone?

Ideally, you'd have a mixer and amplifier that you could run the line out of the pi to, as well as the microphones. I used this affordable wireless microphone set from amazon: https://amzn.to/2OXKXdc (affiliate link) It has a line-in so you can also run PiKaraoke into the mix, and output to an amplifier.

The pi doesn't have a hardware audio input. Technically, you should be able to run a microphone through it with a USB sound card attached to the pi, but I personally wouldn't bother due to latency and audio quality issues.

How do I change song pitch/key?

While a song is playing, the home screen of the web interface will show a transpose slider. Slide it up or down based on your preference.

If you don't see this option, you may be running the --use-omxplayer option. Omxplayer does not support key change.

How do I add cdg or mp3+cdg zip files?

You'll need to add them manually by copying them to the root of your download folder. Run python app.py --help and look under DOWNLOAD_PATH to find out what the default folder is, or specify your own. Only cdg/mp3 pairs and .zip files are supported.

My mp3/cdg file is not playing

CDG files must have an mp3 file with an exact matching file name. They can also be bundled together in a single zip file, but the filenames in the zip must still match. They must also be placed in the root of the download directory and not stashed away in sub-directories.

If you only hear audio, you may be running the --use-omxplayer option. Omxplayer does not support cdg.

I'm on a laptop, how do I output just pikaraoke to an external monitor/screen?

You might be able to just drag the windows to the target screen (press 'f' to toggle fullscreen). But in my experience there can be issues figuring out which monitor to use once videos start playing. For now you'd probably have the most consistent experience using single-screen mirrored mode.

For developers

How to refresh Google translation?

Pip install py-googletrans: pip install googletrans==3.1.0a0

You must manually edit lang/en_US and lang/zh_CN, and then run ./translate-all.sh -c to re-generate Google translations for the rest. If you just want to add a new language from Google translate, omit the -c option.