Question
#28
by
Chelik
- opened
Is there any way to set duration in the Inference api?
from audiocraft.models import MusicGen
from audiocraft.data.audio import audio_write
model_new = MusicGen.get_pretrained("large")
#---------------------------------------------------------------
generate 40 second sound
model_new.set_generation_params(duration=40)
#---------------------------------------------------------------
descriptions = [f"{BasicPrompt}"]
wav = model_new.generate(descriptions) # generates 2 samples.
for idx, one_wav in enumerate(wav):
# Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
audio_write(f'{idx}', one_wav.cpu(), model_new.sample_rate, strategy="loudness")