Spaces:
Build error
Build error
updating audio gen starter code in app.py
Browse files
app.py
CHANGED
@@ -3,19 +3,18 @@ import torchaudio
|
|
3 |
from audiocraft.models import AudioGen
|
4 |
from audiocraft.data.audio import audio_write
|
5 |
|
6 |
-
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
7 |
-
model.set_generation_params(duration=5) # generate 8 seconds.
|
8 |
-
wav = model.generate_unconditional(4) # generates 4 unconditional audio samples
|
9 |
-
descriptions = ['dog barking', 'sirenes of an emergency vehicule', 'footsteps in a corridor']
|
10 |
-
wav = model.generate(descriptions) # generates 3 samples.
|
11 |
|
12 |
-
|
13 |
-
# Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
|
14 |
-
audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True)
|
15 |
-
|
16 |
-
|
17 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
18 |
iface.launch()
|
19 |
|
20 |
-
def
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from audiocraft.models import AudioGen
|
4 |
from audiocraft.data.audio import audio_write
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
iface = gr.Interface(fn=audioGen, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
8 |
iface.launch()
|
9 |
|
10 |
+
def audioGen(audioPrompt):
|
11 |
+
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
12 |
+
model.set_generation_params(duration=5) # generate 8 seconds.
|
13 |
+
wav = model.generate_unconditional(4) # generates 4 unconditional audio samples
|
14 |
+
descriptions = ['dog barking', 'sirenes of an emergency vehicule', 'footsteps in a corridor']
|
15 |
+
wav = model.generate(descriptions) # generates 3 samples.
|
16 |
+
|
17 |
+
for idx, one_wav in enumerate(wav):
|
18 |
+
# Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
|
19 |
+
audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True)
|
20 |
+
return "Hello " + audioPrompt + "!!"
|