Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import scipy
|
3 |
+
import gradio as gr
|
4 |
+
from diffusers import AudioLDMPipeline
|
5 |
+
|
6 |
+
repo_id = "cvssp/audioldm-s-full-v2"
|
7 |
+
pipe = AudioLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
|
8 |
+
pipe = pipe.to("cpu")
|
9 |
+
|
10 |
+
def create_wav(prompt:str, name_file: str):
|
11 |
+
prompt = prompt
|
12 |
+
audio = pipe(prompt, num_inference_steps=10, audio_length_in_s=5.0).audios[0]
|
13 |
+
|
14 |
+
# save the audio sample as a .wav file
|
15 |
+
scipy.io.wavfile.write(f'{name_file}.wav', rate=16000, data=audio)
|
16 |
+
|
17 |
+
# Assuming your file is named 'audio_file.mp3'
|
18 |
+
audio_file = f'{name_file}.wav'
|
19 |
+
|
20 |
+
# Play the audio file
|
21 |
+
return audio_file
|
22 |
+
|
23 |
+
|
24 |
+
gui = gr.Interface(
|
25 |
+
fn=create_wav,
|
26 |
+
inputs=["textbox", "textbox"],
|
27 |
+
outputs="audio"
|
28 |
+
)
|
29 |
+
|
30 |
+
gui.launch(debug=True)
|