Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,9 @@ system_prompt_text = (
|
|
21 |
|
22 |
# Function to transcribe audio input
|
23 |
def transcribe(audio):
|
|
|
|
|
|
|
24 |
sr, y = audio
|
25 |
# Convert to mono if stereo
|
26 |
if y.ndim > 1:
|
@@ -72,7 +75,7 @@ def check_rand(inp, val):
|
|
72 |
else:
|
73 |
return gr.Slider(label="Seed", minimum=1, maximum=1111111111111111, value=int(val))
|
74 |
|
75 |
-
with gr.Blocks() as app:
|
76 |
gr.HTML("""<center><h1 style='font-size:xx-large;'>PTT Chatbot</h1><br><h3>running on Huggingface Inference</h3><br><h7>EXPERIMENTAL</center>""")
|
77 |
|
78 |
with gr.Row():
|
@@ -98,11 +101,9 @@ with gr.Blocks() as app: # Add auth here
|
|
98 |
top_p = gr.Slider(label="Top-P", step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
99 |
rep_p = gr.Slider(label="Repetition Penalty", step=0.1, minimum=0.1, maximum=2.0, value=1.0)
|
100 |
|
101 |
-
hid1 = gr.Number(value=1, visible=False)
|
102 |
-
|
103 |
def handle_chat(audio_input, chat_history, seed, temp, tokens, top_p, rep_p):
|
104 |
user_message = transcribe(audio_input) # Transcribe audio to text
|
105 |
-
if
|
106 |
return chat_history, "Sorry, I couldn't understand that."
|
107 |
|
108 |
response_gen = chat_inf(user_message, chat_history, seed, temp, tokens, top_p, rep_p)
|
|
|
21 |
|
22 |
# Function to transcribe audio input
|
23 |
def transcribe(audio):
|
24 |
+
if audio is None:
|
25 |
+
return None # Handle case where audio input is None
|
26 |
+
|
27 |
sr, y = audio
|
28 |
# Convert to mono if stereo
|
29 |
if y.ndim > 1:
|
|
|
75 |
else:
|
76 |
return gr.Slider(label="Seed", minimum=1, maximum=1111111111111111, value=int(val))
|
77 |
|
78 |
+
with gr.Blocks() as app:
|
79 |
gr.HTML("""<center><h1 style='font-size:xx-large;'>PTT Chatbot</h1><br><h3>running on Huggingface Inference</h3><br><h7>EXPERIMENTAL</center>""")
|
80 |
|
81 |
with gr.Row():
|
|
|
101 |
top_p = gr.Slider(label="Top-P", step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
102 |
rep_p = gr.Slider(label="Repetition Penalty", step=0.1, minimum=0.1, maximum=2.0, value=1.0)
|
103 |
|
|
|
|
|
104 |
def handle_chat(audio_input, chat_history, seed, temp, tokens, top_p, rep_p):
|
105 |
user_message = transcribe(audio_input) # Transcribe audio to text
|
106 |
+
if user_message is None or user_message == "": # Check for empty or error in recognition
|
107 |
return chat_history, "Sorry, I couldn't understand that."
|
108 |
|
109 |
response_gen = chat_inf(user_message, chat_history, seed, temp, tokens, top_p, rep_p)
|