Skip to content
Extraits de code Groupes Projets
Valider 749a7203 rédigé par Sting's avatar Sting
Parcourir les fichiers

Wrap WAV & Vocals extraction in main script

parent 4798e8be
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -4,4 +4,5 @@
!extractWav.sh
!extractAss.sh
!karaUtils.py
!autokara.py
media/
\ No newline at end of file
......@@ -38,6 +38,8 @@ Get a data buffer from an audio file:
- MKVToolnix (at least the CLI utils)
- Python >= 3.8
Having a CUDA-capable GPU is optional, but can greatly reduce processing time.
## Setup
This project requires at least Python 3.8, and using a virtual environment is strongly recommended.
......@@ -55,9 +57,15 @@ $ deactivate
# Use
To extract .wav audio from all MKVs in a folder :
To execute AutoKara on a MKV video file :
```bash
$ python autokara.py video.mkv
```
To extract .wav audio from a MKV file :
```bash
$ ./extractWav.sh source_folder output_folder
$ ./extractWav.sh source_video output_audio
```
To separate vocals from instruments in an audio file :
......
import sys
import demucs.separate
import subprocess
import shlex
from pathlib import Path
try:
video_file = sys.argv[1]
except IndexError:
print("usage : %s video_file" % sys.argv[0])
sys.exit("Invalid Arguments")
Path("./media/audio").mkdir(parents=True, exist_ok=True)
basename = Path(video_file).stem
audio_file = "media/audio/%s.wav" % basename
subprocess.call(shlex.split('./extractWav.sh "%s" "%s"' % (video_file, audio_file)))
Path("./media/vocals").mkdir(parents=True, exist_ok=True)
output_folder = "./media/vocals"
# Not working, don't know why
# demucs.separate.main(shlex.split('--two-stems vocals -o "%s" "%s"' % (output_folder, audio_file)))
subprocess.call(shlex.split('demucs --two-stems vocals -o "%s" "%s"' % (output_folder, audio_file)))
vocals_file = "./media/vocals/htdemucs/%s/vocals.wav" % basename
......@@ -28,8 +28,11 @@ fi
filename=$1
dest_file=$2
echo $filename
echo $dest_file
[ -e "$filename" ] || continue
name=${filename##*/}
base=${name%.mkv}
......@@ -84,7 +87,7 @@ ffmpeg -i "$base.$extension" "$base.wav" && \
#sox "$2/$base.stereo.wav" "$2/$base.wav" remix - && \
#rm "$2/$base.stereo.wav" && \
rm "$base.$extension"
mv "$base.wav" $2
mv "$base.wav" "$2"
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter