Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,12 +4,7 @@ import io
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
from gtts import gTTS
|
6 |
import speech_recognition as sr
|
7 |
-
from
|
8 |
-
|
9 |
-
class AudioTransformer(VideoTransformerBase):
|
10 |
-
def transform(self, frame):
|
11 |
-
audio_data = frame.to_ndarray(format="int16")
|
12 |
-
return audio_data
|
13 |
|
14 |
def recognize_speech(audio_data, show_messages=True):
|
15 |
recognizer = sr.Recognizer()
|
@@ -72,17 +67,10 @@ def main():
|
|
72 |
if "history" not in st.session_state:
|
73 |
st.session_state.history = []
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
webrtc_ctx = webrtc_streamer(
|
78 |
-
key="audio-recorder",
|
79 |
-
audio_transformer_factory=audio_transformer,
|
80 |
-
async_transform=True,
|
81 |
-
)
|
82 |
|
83 |
-
if
|
84 |
-
|
85 |
-
audio_text = recognize_speech(audio_data)
|
86 |
|
87 |
if not st.session_state.history:
|
88 |
pre_prompt = "Te Llamarás Chaman 4.0 y tus respuestas serán sumamente breves."
|
@@ -104,4 +92,4 @@ def main():
|
|
104 |
)
|
105 |
|
106 |
if __name__ == "__main__":
|
107 |
-
main()
|
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
from gtts import gTTS
|
6 |
import speech_recognition as sr
|
7 |
+
from streamlit_audiorecorder import st_audiorecorder
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def recognize_speech(audio_data, show_messages=True):
|
10 |
recognizer = sr.Recognizer()
|
|
|
67 |
if "history" not in st.session_state:
|
68 |
st.session_state.history = []
|
69 |
|
70 |
+
audio_bytes = st_audiorecorder()
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
if audio_bytes is not None:
|
73 |
+
st.audio(audio_bytes, format="audio/wav")
|
|
|
74 |
|
75 |
if not st.session_state.history:
|
76 |
pre_prompt = "Te Llamarás Chaman 4.0 y tus respuestas serán sumamente breves."
|
|
|
92 |
)
|
93 |
|
94 |
if __name__ == "__main__":
|
95 |
+
main()
|