Closed seven54 closed 1 year ago
as i understand rn torch audio is not supporting mp3?? (even if you using format="mp3") you should convert mp3 to wav and then use torch audio
i also meet this problem, and after i convert mp3 to wav and then use torch audio to load wav file ,it works
Yes, converting to wav works.
The apt-get install ffmpeg command is installed. implement import torchaudio from audiocraft.models import MusicGen from audiocraft.data.audio import audio_write
model = MusicGen. get_pretrained('melody') model.set_generation_params(duration=8) # generate 8 seconds. wav = model.generate_unconditional(4) # generates 4 unconditional audio samples descriptions = ['happy rock', 'energetic EDM', 'sad jazz'] wav = model. generate(descriptions) # generates 3 samples.
melody, sr = torchaudio.load('./assets/bach.mp3')
generates using the melody from the given audio and the provided descriptions.
wav = model.generate_with_chroma(descriptions, melody[None].expand(3, -1, -1), sr)
for idx, one_wav in enumerate(wav):
Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
An error occurred RuntimeError: Failed to load audio from ./assets/bach.mp3