Spaces:
Runtime error
Runtime error
matias
commited on
Commit
•
6134fc9
1
Parent(s):
955abc0
fixed translation
Browse files- app.py +14 -8
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
from diffusers import AudioLDMPipeline
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
-
from
|
|
|
5 |
import os
|
6 |
-
|
|
|
|
|
7 |
if torch.cuda.is_available():
|
8 |
device = "cuda"
|
9 |
torch_dtype = torch.float16
|
@@ -20,21 +23,24 @@ pipe = pipe.to(device)
|
|
20 |
def generate_sound(text):
|
21 |
print(text)
|
22 |
# text=translate_text(text)
|
23 |
-
|
24 |
-
|
|
|
25 |
print(text)
|
26 |
waveforms = pipe(text,
|
27 |
-
num_inference_steps=
|
28 |
audio_length_in_s=5,
|
29 |
negative_prompt = "low quality, average quality").audios
|
30 |
rate =16000
|
31 |
return rate, waveforms[0]
|
32 |
#return gr.make_waveform((rate, waveforms[0]))
|
33 |
|
|
|
|
|
|
|
34 |
def translate_text(text):
|
35 |
-
|
36 |
-
|
37 |
-
return translated_text.text
|
38 |
|
39 |
demo = gr.Blocks()
|
40 |
with demo:
|
|
|
1 |
from diffusers import AudioLDMPipeline
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
+
from transformers import pipeline
|
5 |
+
#from googletrans import Translator
|
6 |
import os
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
if torch.cuda.is_available():
|
11 |
device = "cuda"
|
12 |
torch_dtype = torch.float16
|
|
|
23 |
def generate_sound(text):
|
24 |
print(text)
|
25 |
# text=translate_text(text)
|
26 |
+
text = translate_text(text)
|
27 |
+
#translator = Translator()
|
28 |
+
#text=translator.translate(text, src='es',dest="en").text
|
29 |
print(text)
|
30 |
waveforms = pipe(text,
|
31 |
+
num_inference_steps=25,
|
32 |
audio_length_in_s=5,
|
33 |
negative_prompt = "low quality, average quality").audios
|
34 |
rate =16000
|
35 |
return rate, waveforms[0]
|
36 |
#return gr.make_waveform((rate, waveforms[0]))
|
37 |
|
38 |
+
es_en_translator = pipeline("translation",model = "Helsinki-NLP/opus-mt-es-en")
|
39 |
+
|
40 |
+
|
41 |
def translate_text(text):
|
42 |
+
text = es_en_translator(text)[0].get("translation_text")
|
43 |
+
return text
|
|
|
44 |
|
45 |
demo = gr.Blocks()
|
46 |
with demo:
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
googletrans==3.1.0a0
|
2 |
torch
|
3 |
transformers
|
4 |
diffusers
|
|
|
1 |
+
#googletrans==3.1.0a0
|
2 |
torch
|
3 |
transformers
|
4 |
diffusers
|