Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,14 +83,13 @@ def evaluate_response(text):
|
|
| 83 |
)
|
| 84 |
return completion.choices[0].text.strip()
|
| 85 |
|
| 86 |
-
# Custom audio processor for handling the audio stream
|
| 87 |
class SpeechToTextProcessor(AudioProcessorBase):
|
| 88 |
def __init__(self):
|
| 89 |
self.result_queue = queue.Queue()
|
| 90 |
|
| 91 |
def recv(self, frame):
|
| 92 |
audio_data = np.frombuffer(frame.to_ndarray(), np.float32)
|
| 93 |
-
audio_data = whisper.pad_or_trim(audio_data)
|
| 94 |
result = whisper_model.transcribe(audio_data)
|
| 95 |
text = result["text"]
|
| 96 |
self.result_queue.put(text)
|
|
@@ -157,4 +156,4 @@ if st.button("Start Interview"):
|
|
| 157 |
|
| 158 |
# Evaluate the response
|
| 159 |
score = evaluate_response(st.session_state["transcribed_text"])
|
| 160 |
-
st.write(f"Evaluation Score: {score}
|
|
|
|
| 83 |
)
|
| 84 |
return completion.choices[0].text.strip()
|
| 85 |
|
| 86 |
+
# Custom audio processor for handling the audio stream with Whisper
|
| 87 |
class SpeechToTextProcessor(AudioProcessorBase):
|
| 88 |
def __init__(self):
|
| 89 |
self.result_queue = queue.Queue()
|
| 90 |
|
| 91 |
def recv(self, frame):
|
| 92 |
audio_data = np.frombuffer(frame.to_ndarray(), np.float32)
|
|
|
|
| 93 |
result = whisper_model.transcribe(audio_data)
|
| 94 |
text = result["text"]
|
| 95 |
self.result_queue.put(text)
|
|
|
|
| 156 |
|
| 157 |
# Evaluate the response
|
| 158 |
score = evaluate_response(st.session_state["transcribed_text"])
|
| 159 |
+
st.write(f"Evaluation Score: {score}")
|