Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
|
4 |
-
import IPython.display as ipd
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
# texto to audio
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
def image_to_audio(input_image):
|
24 |
-
# Convertir la imagen a texto
|
25 |
-
text_output = image_to_texto(input_image)[0]['label']
|
26 |
-
print('text_output is :'+text_output)
|
27 |
-
# Generar audio a partir del texto
|
28 |
-
audio_output = text_to_audio_model(text_output)[0]['audio']
|
29 |
-
print('audio_output is :'+audio_output)
|
30 |
-
return audio_output
|
31 |
-
|
32 |
-
# Interfaz Gradio
|
33 |
-
iface = gr.Interface(
|
34 |
-
fn=image_to_audio,
|
35 |
-
inputs=gr.Image(type='pil'),
|
36 |
-
outputs=[gr.Textbox(), gr.Audio()],
|
37 |
-
live=True,
|
38 |
-
interpretation="default",
|
39 |
-
capture_session=True
|
40 |
-
)
|
41 |
|
42 |
-
|
43 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
import speech_recognition as sr
|
|
|
4 |
|
5 |
+
def transcribe_speech():
|
6 |
+
r = sr.Recognizer()
|
|
|
7 |
|
8 |
+
# Record Audio
|
9 |
+
with sr.Microphone() as source:
|
10 |
+
print("Habla ahora:")
|
11 |
+
audio = r.listen(source)
|
12 |
|
13 |
+
# Speech recognition using Google Speech Recognition
|
14 |
+
try:
|
15 |
+
text = r.recognize_google(audio, language='es-ES')
|
16 |
+
print("Creo que dijiste: " + text)
|
17 |
+
except sr.UnknownValueError:
|
18 |
+
print("Google Speech Recognition no pudo entender el audio")
|
19 |
+
except sr.RequestError as e:
|
20 |
+
print("No se pudo solicitar resultados del servicio de Google Speech Recognition; {0}".format(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
transcribe_speech()
|
|