salomonsky commited on
Commit
24dca16
verified
1 Parent(s): d841a1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -32,14 +32,13 @@ def recognize_speech(audio_data, show_messages=True):
32
  return audio_text
33
 
34
  def format_prompt(message, history):
35
- prompt = "<s>"
36
 
37
  for user_prompt, bot_response in history:
38
- prompt += f"[INST] {user_prompt} [/INST]"
39
- prompt += f" {bot_response}</s> "
40
 
41
- prompt += f"[INST] {message} [/INST]"
42
- return prompt
43
 
44
  def generate(audio_text, history, temperature=None, max_new_tokens=512, top_p=0.95, repetition_penalty=1.0):
45
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
@@ -83,7 +82,7 @@ def text_to_speech(text, speed=1.3):
83
 
84
  def main():
85
  st.title("Chatbot de Voz a Voz")
86
- audio_data = audiorecorder("Habla para grabar", "Deteniendo la grabaci贸n...")
87
 
88
  if not audio_data.empty():
89
  st.audio(audio_data.export().read(), format="audio/wav")
 
32
  return audio_text
33
 
34
  def format_prompt(message, history):
35
+ prompt_list = ["<s>"]
36
 
37
  for user_prompt, bot_response in history:
38
+ prompt_list.extend([f"[INST] {user_prompt} [/INST]", f" {bot_response}</s> "])
 
39
 
40
+ prompt_list.append(f"[INST] {message} [/INST]")
41
+ return ''.join(prompt_list)
42
 
43
  def generate(audio_text, history, temperature=None, max_new_tokens=512, top_p=0.95, repetition_penalty=1.0):
44
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
 
82
 
83
  def main():
84
  st.title("Chatbot de Voz a Voz")
85
+ mic = sr.Microphone(device_index=1)
86
 
87
  if not audio_data.empty():
88
  st.audio(audio_data.export().read(), format="audio/wav")