Spaces:
Runtime error
Runtime error
audio
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ def load_chat():
|
|
42 |
st.markdown("---", unsafe_allow_html=True)
|
43 |
st.write('Realiza una pregunta por texto o por audio sobre el capitulo')
|
44 |
audio = audiorecorder("Grabar audio", "Stop")
|
45 |
-
user_audio =
|
46 |
if len(audio) > 0:
|
47 |
st.audio(audio.tobytes())
|
48 |
# To save audio to a file:
|
@@ -50,12 +50,13 @@ def load_chat():
|
|
50 |
wav_file.write(audio.tobytes())
|
51 |
with st.form(key='my_form', clear_on_submit=True):
|
52 |
# Whisper
|
53 |
-
|
54 |
-
|
|
|
55 |
user_input = st.text_area("", key='input', height=100)
|
56 |
submit_button = st.form_submit_button(label='Enviar pregunta')
|
57 |
|
58 |
-
if submit_button and (user_input or user_audio):
|
59 |
if os.path.exists("audio.mp3"):
|
60 |
os.remove("audio.mp3")
|
61 |
output, total_tokens, prompt_tokens, completion_tokens = generate_response(agent_id_cap_7, user_input, user_audio)
|
|
|
42 |
st.markdown("---", unsafe_allow_html=True)
|
43 |
st.write('Realiza una pregunta por texto o por audio sobre el capitulo')
|
44 |
audio = audiorecorder("Grabar audio", "Stop")
|
45 |
+
user_audio = ''
|
46 |
if len(audio) > 0:
|
47 |
st.audio(audio.tobytes())
|
48 |
# To save audio to a file:
|
|
|
50 |
wav_file.write(audio.tobytes())
|
51 |
with st.form(key='my_form', clear_on_submit=True):
|
52 |
# Whisper
|
53 |
+
if os.path.exists("audio.mp3"):
|
54 |
+
output = model.transcribe("audio.mp3")
|
55 |
+
user_audio = output['text']
|
56 |
user_input = st.text_area("", key='input', height=100)
|
57 |
submit_button = st.form_submit_button(label='Enviar pregunta')
|
58 |
|
59 |
+
if submit_button and (user_input or user_audio != ''):
|
60 |
if os.path.exists("audio.mp3"):
|
61 |
os.remove("audio.mp3")
|
62 |
output, total_tokens, prompt_tokens, completion_tokens = generate_response(agent_id_cap_7, user_input, user_audio)
|