mrolando commited on
Commit
fd7a397
1 Parent(s): 660042b
Files changed (2) hide show
  1. app.py +44 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import AudioLDMPipeline
2
+ import torch
3
+ import gradio as gr
4
+ from googletrans import Translator
5
+
6
+ if torch.cuda.is_available():
7
+ device = "cuda"
8
+ torch_dtype = torch.float16
9
+ else:
10
+ device = "cpu"
11
+ torch_dtype = torch.float32
12
+ repo_id = "cvssp/audioldm-m-full"
13
+ pipe = AudioLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
14
+ #pipe = pipe.to("cuda")
15
+
16
+ prompt = "Techno music with a strong, upbeat tempo and high melodic riffs"
17
+
18
+
19
+ def generate_sound(text):
20
+ print(text)
21
+ text=translate_text(text)
22
+ print(text)
23
+ audio = pipe(text, num_inference_steps=10, audio_length_in_s=5.0).audios[0]
24
+ rate =160000
25
+ return rate, audio
26
+ def translate_text(text):
27
+ translator = Translator()
28
+ translated_text=translator.translate(text, src='es',dest="en")
29
+ return translated_text.text
30
+
31
+ demo = gr.Blocks()
32
+ with demo:
33
+ with gr.Row():
34
+ with gr.Column():
35
+
36
+ text = gr.Textbox(value="Ingrese el texto:")
37
+ button = gr.Button(value="Generar")
38
+
39
+ with gr.Column():
40
+ output = gr.Audio()
41
+ button.click(generate_sound,text,output)
42
+
43
+
44
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ googletrans==3.1.0a0
2
+ torch
3
+ transformers
4
+ diffusers
5
+ gradio