run.sh 1.3 KB

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. mkdir -p /data/output /data/ingest /data/models /data/temp /data/cache
  3. rm -rf /data/temp/*
  4. # For each video file in the ingest directory
  5. for f in /data/ingest/*; do
  6. # Move file to temp directory
  7. mv "$f" /data/temp/
  8. # Get file name without extension
  9. filename="$(basename "${f%.*}")"
  10. # Extract audio from video file
  11. ffmpeg -loglevel warning -y -i /data/temp/"${f##*/}" -f wav /data/temp/"$filename".wav
  12. # Split voice and music from audio file
  13. python3 /vocal-remover/inference.py -i /data/temp/"$filename".wav -o /data/temp/ --tta --pretrained_model /vocal-remover/models/baseline.pth
  14. # Clone the voice
  15. 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
  16. # Combine voice and music into one mp3 file
  17. ffmpeg -loglevel warning -y -i /data/temp/"$filename"_"$SPEAKER".wav -i /data/temp/"$filename"_Instruments.wav \
  18. -filter_complex "[0:a]volume=$VOCALS_VOLUME[a0];[a0][1:a]amix=inputs=2:duration=longest" /data/temp/"$filename"_"$SPEAKER"_combined.wav
  19. # Combine audio and video into one file
  20. 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
  21. done