salomonsky commited on
Commit
0173625
verified
1 Parent(s): 1bb42fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -6,15 +6,14 @@ from gtts import gTTS
6
  from audio_recorder_streamlit import audio_recorder
7
  import speech_recognition as sr
8
 
9
- gatherUsageStats = "false"
10
-
11
  if "history" not in st.session_state:
12
  st.session_state.history = []
13
 
14
  if "pre_prompt_sent" not in st.session_state:
15
  st.session_state.pre_prompt_sent = False
16
 
17
- pre_prompt_text = "Eres una IA conductual, tu nombre es chaman 3.0, tus respuestas ser谩n breves."
 
18
 
19
  def recognize_speech(audio_data, show_messages=True):
20
  recognizer = sr.Recognizer()
@@ -30,18 +29,18 @@ def recognize_speech(audio_data, show_messages=True):
30
  st.write(audio_text)
31
  st.success("Reconocimiento de voz completado.")
32
  except sr.UnknownValueError:
33
- st.warning("Habla mas claro, cerca del micr贸fono.")
34
  audio_text = ""
35
  except sr.RequestError:
36
- st.error("Presiona el boton y habla!")
37
  audio_text = ""
38
 
39
  return audio_text
40
 
41
- def format_prompt(message, history, pre_prompt_sent):
42
  prompt = "<s>"
43
 
44
- if not pre_prompt_sent:
45
  prompt += f"[INST]{pre_prompt_text}[/INST]"
46
 
47
  for user_prompt, bot_response in history:
@@ -100,8 +99,9 @@ def display_recognition_result(audio_text, output, audio_file):
100
  def main():
101
  if not st.session_state.pre_prompt_sent:
102
  st.session_state.pre_prompt_sent = True
 
103
 
104
- audio_bytes = audio_recorder(text="", recording_color="#A52A2A", neutral_color="#FFFFFF", energy_threshold=(-1.0, 1.0), pause_threshold=5.0)
105
 
106
  if audio_bytes:
107
  st.audio(audio_bytes, format="audio/wav")
 
6
  from audio_recorder_streamlit import audio_recorder
7
  import speech_recognition as sr
8
 
 
 
9
  if "history" not in st.session_state:
10
  st.session_state.history = []
11
 
12
  if "pre_prompt_sent" not in st.session_state:
13
  st.session_state.pre_prompt_sent = False
14
 
15
+ # Texto predeterminado para el pre_prompt
16
+ pre_prompt_text = "eres una IA conductual, tus respuestas ser谩n breves."
17
 
18
  def recognize_speech(audio_data, show_messages=True):
19
  recognizer = sr.Recognizer()
 
29
  st.write(audio_text)
30
  st.success("Reconocimiento de voz completado.")
31
  except sr.UnknownValueError:
32
+ st.warning("No se pudo reconocer el audio. 驴Intentaste grabar algo?")
33
  audio_text = ""
34
  except sr.RequestError:
35
+ st.error("Hablame para comenzar!")
36
  audio_text = ""
37
 
38
  return audio_text
39
 
40
+ def format_prompt(message, history):
41
  prompt = "<s>"
42
 
43
+ if not st.session_state.pre_prompt_sent:
44
  prompt += f"[INST]{pre_prompt_text}[/INST]"
45
 
46
  for user_prompt, bot_response in history:
 
99
  def main():
100
  if not st.session_state.pre_prompt_sent:
101
  st.session_state.pre_prompt_sent = True
102
+ st.text("Env铆o de pre_prompt realizado. Puede continuar.")
103
 
104
+ audio_bytes = audio_recorder(text="", recording_color="#A52A2A", neutral_color="#FFFFFF",)
105
 
106
  if audio_bytes:
107
  st.audio(audio_bytes, format="audio/wav")