Spaces:
Runtime error
Runtime error
Commit
·
556b4ae
1
Parent(s):
41d06ba
pause
Browse files
app.py
CHANGED
|
@@ -78,34 +78,27 @@ def warm_up():
|
|
| 78 |
|
| 79 |
warm_up()
|
| 80 |
|
| 81 |
-
def determine_pause():
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
if start_talking:
|
| 103 |
-
st.session_state.frames.append(temp_audio)
|
| 104 |
-
if dur_vad < 0.1 and start_talking:
|
| 105 |
-
st.session_state.recording = False
|
| 106 |
-
print(f"speech end detected. excit")
|
| 107 |
-
last_temp_audio = temp_audio
|
| 108 |
-
temp_audio = b""
|
| 109 |
|
| 110 |
|
| 111 |
def process_audio(audio):
|
|
|
|
| 78 |
|
| 79 |
warm_up()
|
| 80 |
|
| 81 |
+
def determine_pause(stream: bytes, start_talking: bool) -> tuple[bytes, bool]:
|
| 82 |
+
"""Take in the stream, determine if a pause happened"""
|
| 83 |
+
|
| 84 |
+
temp_audio = stream
|
| 85 |
+
|
| 86 |
+
if len(temp_audio) > IN_SAMPLE_WIDTH * IN_RATE * IN_CHANNELS * VAD_STRIDE:
|
| 87 |
+
dur_vad, vad_audio_bytes, time_vad = run_vad(temp_audio, IN_RATE)
|
| 88 |
+
|
| 89 |
+
print(f"duration_after_vad: {dur_vad:.3f} s, time_vad: {time_vad:.3f} s")
|
| 90 |
+
|
| 91 |
+
if dur_vad > 0.2 and not start_talking:
|
| 92 |
+
if last_temp_audio is not None:
|
| 93 |
+
st.session_state.frames.append(last_temp_audio)
|
| 94 |
+
start_talking = True
|
| 95 |
+
if start_talking:
|
| 96 |
+
st.session_state.frames.append(temp_audio)
|
| 97 |
+
if dur_vad < 0.1 and start_talking:
|
| 98 |
+
st.session_state.recording = False
|
| 99 |
+
print(f"speech end detected. excit")
|
| 100 |
+
last_temp_audio = temp_audio
|
| 101 |
+
temp_audio = b""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
def process_audio(audio):
|