ljcortesr commited on
Commit ·
7efc3d5
1
Parent(s): f2a983a
Front and back launch ok
Browse files
app.py
CHANGED
|
@@ -15,14 +15,14 @@ def generate_audio(descriptions: str):
|
|
| 15 |
global model
|
| 16 |
if model is None:
|
| 17 |
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
| 18 |
-
model.set_generation_params(duration=
|
| 19 |
if not os.path.exists('audio_files'):
|
| 20 |
os.makedirs('audio_files')
|
| 21 |
|
| 22 |
wav = model.generate([descriptions])
|
| 23 |
results = []
|
| 24 |
|
| 25 |
-
for
|
| 26 |
filename = f'{descriptions}.wav'
|
| 27 |
file_path = os.path.join('audio_files', filename)
|
| 28 |
audio_write(file_path, one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True, add_suffix=False)
|
|
@@ -34,7 +34,7 @@ def generate_audio(descriptions: str):
|
|
| 34 |
with gr.Blocks() as demo:
|
| 35 |
gr.Markdown("# AudioGen Demo")
|
| 36 |
with gr.Row():
|
| 37 |
-
descriptions = gr.Textbox(lines=
|
| 38 |
with gr.Row():
|
| 39 |
generate_button = gr.Button("Generate Audio")
|
| 40 |
with gr.Row():
|
|
@@ -42,4 +42,4 @@ with gr.Blocks() as demo:
|
|
| 42 |
|
| 43 |
generate_button.click(fn=generate_audio, inputs=descriptions, outputs=output)
|
| 44 |
|
| 45 |
-
demo.launch()
|
|
|
|
| 15 |
global model
|
| 16 |
if model is None:
|
| 17 |
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
| 18 |
+
model.set_generation_params(duration=5)
|
| 19 |
if not os.path.exists('audio_files'):
|
| 20 |
os.makedirs('audio_files')
|
| 21 |
|
| 22 |
wav = model.generate([descriptions])
|
| 23 |
results = []
|
| 24 |
|
| 25 |
+
for one_wav in enumerate(wav):
|
| 26 |
filename = f'{descriptions}.wav'
|
| 27 |
file_path = os.path.join('audio_files', filename)
|
| 28 |
audio_write(file_path, one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True, add_suffix=False)
|
|
|
|
| 34 |
with gr.Blocks() as demo:
|
| 35 |
gr.Markdown("# AudioGen Demo")
|
| 36 |
with gr.Row():
|
| 37 |
+
descriptions = gr.Textbox(lines=1, label="Enter a description of the audio ' Duration: 5 seconds'")
|
| 38 |
with gr.Row():
|
| 39 |
generate_button = gr.Button("Generate Audio")
|
| 40 |
with gr.Row():
|
|
|
|
| 42 |
|
| 43 |
generate_button.click(fn=generate_audio, inputs=descriptions, outputs=output)
|
| 44 |
|
| 45 |
+
demo.launch(share=True)
|