Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
36 |
|
37 |
for user_prompt, bot_response in history:
|
38 |
-
|
39 |
-
prompt += f" {bot_response}</s> "
|
40 |
|
41 |
-
|
42 |
-
return
|
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 |
-
|
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")
|