Created
May 26, 2020 20:31
-
-
Save yamamushi/58efed34a704c6f0e84a239d1725ddba to your computer and use it in GitHub Desktop.
Youtube to Spleeter Wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while getopts o:y:s:q: option | |
do | |
case "${option}" | |
in | |
o) OUTPUT=${OPTARG};; | |
y) YOUTUBE=${OPTARG};; | |
s) STEMS=${OPTARG};; | |
q) QUALITY=${OPTARG};; | |
*) ;; | |
esac | |
done | |
if [ -z "$OUTPUT" ]; then | |
echo "missing output option" | |
exit 1 | |
fi | |
echo $YOUTUBE | |
if [ -z "$YOUTUBE" ]; then | |
echo "missing youtube link" | |
exit 1 | |
fi | |
if [ -z "$STEMS" ]; then | |
STEMS="2" | |
fi | |
STEMOPT="${STEMS}stems" | |
#if [ "$QUALITY" = "16" ]; then | |
# STEMOPT="${STEMOPT}-16kHz" | |
#fi | |
youtube-dl --extract-audio --audio-format mp3 "$YOUTUBE" -o "$OUTPUT.%(ext)s" | |
export AUDIO_IN="$(pwd)/" | |
export AUDIO_OUT="$(pwd)/output" | |
export MODEL_DIRECTORY="${HOME}/spleeter/pretrained_models" | |
docker run --rm \ | |
-v $AUDIO_IN:/input \ | |
-v $AUDIO_OUT:/output \ | |
-v $MODEL_DIRECTORY:/model \ | |
-e MODEL_PATH=/model \ | |
researchdeezer/spleeter separate -i /input/"$OUTPUT".mp3 -p spleeter:"$STEMOPT" -c mp3 -o output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment