|
import sys |
|
import torchaudio |
|
from audiocraft.models import AudioGen |
|
from audiocraft.data.audio import audio_write |
|
|
|
model = AudioGen.get_pretrained('facebook/audiogen-medium') |
|
model.set_generation_params(duration=5) |
|
descriptions = sys.argv[1:] |
|
if not descriptions: |
|
print('At least one prompt should be provided') |
|
sys.exit(1) |
|
wav = model.generate(descriptions) |
|
|
|
for one_wav, description in zip(wav, descriptions): |
|
file_name = description.replace(' ', '_') |
|
|
|
audio_write(file_name, one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True) |
|
|
|
|