#!/bin/bash mkdir -p /data/output /data/ingest /data/models /data/temp /data/cache rm -rf /data/temp/* # For each video file in the ingest directory for f in /data/ingest/*; do # Move file to temp directory mv "$f" /data/temp/ # Get file name without extension filename="$(basename "${f%.*}")" # Extract audio from video file ffmpeg -loglevel warning -y -i /data/temp/"${f##*/}" -f wav /data/temp/"$filename".wav # Split voice and music from audio file python3 /vocal-remover/inference.py -i /data/temp/"$filename".wav -o /data/temp/ --tta --pretrained_model /vocal-remover/models/baseline.pth # Clone the voice svc infer -o /data/temp/"$filename"_"$SPEAKER".wav -m "$MODEL_PATH" -c "$MODEL_CONFIG_PATH" -s "$SPEAKER" -na -t "$TRANSPOSE" /data/temp/"$filename"_Vocals.wav # Combine voice and music into one mp3 file ffmpeg -loglevel warning -y -i /data/temp/"$filename"_"$SPEAKER".wav -i /data/temp/"$filename"_Instruments.wav \ -filter_complex "[0:a]volume=$VOCALS_VOLUME[a0];[a0][1:a]amix=inputs=2:duration=longest" /data/temp/"$filename"_"$SPEAKER"_combined.wav # Combine audio and video into one file ffmpeg -loglevel warning -y -i /data/temp/"${f##*/}" -i /data/temp/"$filename"_"$SPEAKER"_combined.wav -c:v copy -map 0:v:0 -map 1:a:0 /data/output/"$filename"_"$SPEAKER".mp4 done