Sing-For-Me / vocal_isolation /vocal_isolation.py
Jarod Castillo
init
bb70eb3
raw
history blame
890 Bytes
# Third Party
import soundfile
import numpy
# Local
from vocal_isolation.loader import Loader
from vocal_isolation.models.kimvocal import KimVocal
# Constants
from vocal_isolation.constants import INPUT_FOLDER, OUTPUT_FOLDER
def isolate_vocals_kim_vocals(input_file_name="audio"):
loader = Loader(INPUT_FOLDER, OUTPUT_FOLDER)
music_numpy_array, sample_rate = loader.load_wav(input_file_name)
kimvocal = KimVocal()
instrumentals_tensor, vocals_tensor = kimvocal.demix_both(music_tensor=music_numpy_array, sample_rate=sample_rate)
instrumentals_numpy = instrumentals_tensor.numpy().T
vocals_numpy = vocals_tensor.numpy().T
soundfile.write(file=OUTPUT_FOLDER + "/no_vocals.wav", data=instrumentals_numpy, samplerate=sample_rate)
soundfile.write(file=OUTPUT_FOLDER + "/vocals.wav", data=vocals_numpy, samplerate=sample_rate)
return True