Spaces:
Runtime error
Runtime error
Mi proyecto Machine Learning
Browse files- requirements.py +30 -0
- requirements.txt +2 -0
requirements.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import speech_recognition as sr
|
3 |
+
|
4 |
+
# Funci贸n para convertir audio en texto
|
5 |
+
def audio_to_text(audio):
|
6 |
+
recognizer = sr.Recognizer()
|
7 |
+
with sr.AudioFile(audio) as source:
|
8 |
+
audio_data = recognizer.record(source)
|
9 |
+
try:
|
10 |
+
# Reconocimiento de voz utilizando Google Web Speech API
|
11 |
+
text = recognizer.recognize_google(audio_data, language="es-ES")
|
12 |
+
except sr.UnknownValueError:
|
13 |
+
text = "No se pudo entender el audio."
|
14 |
+
except sr.RequestError:
|
15 |
+
text = "No se pudo conectar al servicio de reconocimiento."
|
16 |
+
return text
|
17 |
+
|
18 |
+
# Interfaz de Gradio
|
19 |
+
interface = gr.Interface(
|
20 |
+
fn=audio_to_text,
|
21 |
+
inputs=gr.Audio(sources="microphone", type="filepath"),
|
22 |
+
outputs="text",
|
23 |
+
title="Conversi贸n de Audio a Texto",
|
24 |
+
description="Convierte audio capturado por el micr贸fono en texto utilizando reconocimiento de voz.",
|
25 |
+
live=True
|
26 |
+
)
|
27 |
+
|
28 |
+
# Iniciar la aplicaci贸n
|
29 |
+
if __name__ == "__main__":
|
30 |
+
interface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
speechrecognition
|