ljcortesr
commited on
Commit
·
f2a983a
1
Parent(s):
6904a18
Front and back launch ok
Browse files
app.py
CHANGED
|
@@ -16,23 +16,20 @@ def generate_audio(descriptions: str):
|
|
| 16 |
if model is None:
|
| 17 |
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
| 18 |
model.set_generation_params(duration=10)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
wav = model.generate([descriptions])
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
loudness_compressor=True,
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
print(f"Generated audio for '{descriptions}' -> {final_path}")
|
| 35 |
-
return final_path
|
| 36 |
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
gr.Markdown("# AudioGen Demo")
|
|
|
|
| 16 |
if model is None:
|
| 17 |
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
| 18 |
model.set_generation_params(duration=10)
|
| 19 |
+
if not os.path.exists('audio_files'):
|
| 20 |
+
os.makedirs('audio_files')
|
| 21 |
+
|
|
|
|
| 22 |
wav = model.generate([descriptions])
|
| 23 |
+
results = []
|
| 24 |
+
|
| 25 |
+
for idx, 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)
|
| 29 |
+
print(f"Generated audio for '{descriptions}'")
|
| 30 |
+
results.append(file_path)
|
| 31 |
+
|
| 32 |
+
return results[0]
|
|
|
|
|
|
|
| 33 |
|
| 34 |
with gr.Blocks() as demo:
|
| 35 |
gr.Markdown("# AudioGen Demo")
|