Spaces:
Sleeping
Sleeping
Commit
·
ab840dc
1
Parent(s):
eef0040
Minor refactoring
Browse files- api/audio.py +0 -5
- app.py +4 -12
- utils/ui.py +8 -0
api/audio.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import io
|
| 2 |
-
import os
|
| 3 |
import wave
|
| 4 |
|
| 5 |
import numpy as np
|
|
@@ -126,10 +125,6 @@ class STTManager:
|
|
| 126 |
except:
|
| 127 |
return False
|
| 128 |
|
| 129 |
-
def add_user_message(self, message, chat_display):
|
| 130 |
-
chat_display.append([message, None])
|
| 131 |
-
return chat_display
|
| 132 |
-
|
| 133 |
|
| 134 |
class TTSManager:
|
| 135 |
def test_tts(self):
|
|
|
|
| 1 |
import io
|
|
|
|
| 2 |
import wave
|
| 3 |
|
| 4 |
import numpy as np
|
|
|
|
| 125 |
except:
|
| 126 |
return False
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
class TTSManager:
|
| 130 |
def test_tts(self):
|
app.py
CHANGED
|
@@ -9,23 +9,13 @@ from config import config
|
|
| 9 |
from docs.instruction import instruction
|
| 10 |
from resources.data import fixed_messages, topics_list
|
| 11 |
from resources.prompts import prompts
|
| 12 |
-
from utils.ui import add_interviewer_message
|
| 13 |
|
| 14 |
llm = LLMManager(config, prompts)
|
| 15 |
tts = TTSManager(config)
|
| 16 |
stt = STTManager(config)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
def get_status_color(obj):
|
| 20 |
-
if obj.status:
|
| 21 |
-
if obj.streaming:
|
| 22 |
-
return "🟢"
|
| 23 |
-
return "🟡"
|
| 24 |
-
return "🔴"
|
| 25 |
-
|
| 26 |
-
|
| 27 |
# Interface
|
| 28 |
-
|
| 29 |
with gr.Blocks(title="AI Interviewer") as demo:
|
| 30 |
if os.getenv("IS_DEMO"):
|
| 31 |
gr.Markdown(instruction["demo"])
|
|
@@ -54,6 +44,7 @@ with gr.Blocks(title="AI Interviewer") as demo:
|
|
| 54 |
gr.Markdown(instruction["interface"])
|
| 55 |
with gr.Column(scale=1):
|
| 56 |
gr.Markdown("Bot interaction area will look like this. Use Record button to record your answer.")
|
|
|
|
| 57 |
chat_example = gr.Chatbot(
|
| 58 |
label="Chat", show_label=False, show_share_button=False, value=[["Candidate message", "Interviewer message"]]
|
| 59 |
)
|
|
@@ -67,6 +58,7 @@ with gr.Blocks(title="AI Interviewer") as demo:
|
|
| 67 |
"show_share_button": False,
|
| 68 |
"streaming": stt.streaming,
|
| 69 |
}
|
|
|
|
| 70 |
audio_input_example = gr.Audio(interactive=True, **default_audio_params)
|
| 71 |
gr.Markdown(instruction["models"])
|
| 72 |
gr.Markdown(instruction["acknowledgements"])
|
|
@@ -159,7 +151,7 @@ with gr.Blocks(title="AI Interviewer") as demo:
|
|
| 159 |
fn=llm.end_interview, inputs=[description, chat_history], outputs=[feedback]
|
| 160 |
)
|
| 161 |
|
| 162 |
-
send_btn.click(fn=
|
| 163 |
fn=llm.send_request,
|
| 164 |
inputs=[code, previous_code, chat_history, chat],
|
| 165 |
outputs=[chat_history, chat, previous_code],
|
|
|
|
| 9 |
from docs.instruction import instruction
|
| 10 |
from resources.data import fixed_messages, topics_list
|
| 11 |
from resources.prompts import prompts
|
| 12 |
+
from utils.ui import add_candidate_message, add_interviewer_message, get_status_color
|
| 13 |
|
| 14 |
llm = LLMManager(config, prompts)
|
| 15 |
tts = TTSManager(config)
|
| 16 |
stt = STTManager(config)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# Interface
|
|
|
|
| 19 |
with gr.Blocks(title="AI Interviewer") as demo:
|
| 20 |
if os.getenv("IS_DEMO"):
|
| 21 |
gr.Markdown(instruction["demo"])
|
|
|
|
| 44 |
gr.Markdown(instruction["interface"])
|
| 45 |
with gr.Column(scale=1):
|
| 46 |
gr.Markdown("Bot interaction area will look like this. Use Record button to record your answer.")
|
| 47 |
+
gr.Markdown("Click 'Send' to send you answer and get a reply.")
|
| 48 |
chat_example = gr.Chatbot(
|
| 49 |
label="Chat", show_label=False, show_share_button=False, value=[["Candidate message", "Interviewer message"]]
|
| 50 |
)
|
|
|
|
| 58 |
"show_share_button": False,
|
| 59 |
"streaming": stt.streaming,
|
| 60 |
}
|
| 61 |
+
send_btn_example = gr.Button("Send", interactive=False)
|
| 62 |
audio_input_example = gr.Audio(interactive=True, **default_audio_params)
|
| 63 |
gr.Markdown(instruction["models"])
|
| 64 |
gr.Markdown(instruction["acknowledgements"])
|
|
|
|
| 151 |
fn=llm.end_interview, inputs=[description, chat_history], outputs=[feedback]
|
| 152 |
)
|
| 153 |
|
| 154 |
+
send_btn.click(fn=add_candidate_message, inputs=[message, chat], outputs=[chat]).success(fn=lambda: None, outputs=[message]).success(
|
| 155 |
fn=llm.send_request,
|
| 156 |
inputs=[code, previous_code, chat_history, chat],
|
| 157 |
outputs=[chat_history, chat, previous_code],
|
utils/ui.py
CHANGED
|
@@ -10,3 +10,11 @@ def add_interviewer_message(message):
|
|
| 10 |
def add_candidate_message(message, chat):
|
| 11 |
chat.append((message, None))
|
| 12 |
return chat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
def add_candidate_message(message, chat):
|
| 11 |
chat.append((message, None))
|
| 12 |
return chat
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def get_status_color(obj):
|
| 16 |
+
if obj.status:
|
| 17 |
+
if obj.streaming:
|
| 18 |
+
return "🟢"
|
| 19 |
+
return "🟡"
|
| 20 |
+
return "🔴"
|