|
import torchaudio |
|
from audiocraft.models import AudioGen |
|
from audiocraft.data.audio import audio_write |
|
import gradio as gr |
|
|
|
model = AudioGen.get_pretrained('facebook/audiogen-medium') |
|
model.set_generation_params(duration=8) |
|
wav = model.generate_unconditional(1) |
|
|
|
def AudioGenie(Prompt): |
|
descriptions = [Prompt] |
|
wav = model.generate(descriptions) |
|
for idx, one_wav in enumerate(wav): |
|
|
|
audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True) |
|
return wav |
|
|
|
gr.Interface(fn=AudioGenie, inputs= 'text', outputs= 'audio').launch(debug=True) |
|
|