Spaces:
Build error
Build error
File size: 610 Bytes
3d13b69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from audiocraft.models import musicgen
import torchaudio
import soundfile as sf
print("Loading model...")
# model = musicgen.MusicGen.get_pretrained("melody")
model = musicgen.MusicGen.get_pretrained("small")
model.set_generation_params(duration=8)
descriptions = ["Film score epic moment"]
melody, sr = torchaudio.load("./asitwas_vocals.wav")
print("Running inference...")
# wav = model.generate_with_chroma(descriptions, melody[None].expand(1, -1, -1), sr)
wav = model.generate(descriptions) # generates 3 samples.
model_sampling_rate = 32000
sf.write("output.wav", wav[0].numpy().T, model_sampling_rate)
|