Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,25 @@ import os
|
|
14 |
import io
|
15 |
from pydub import AudioSegment
|
16 |
from dataclasses import dataclass
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Define AppState dataclass for managing the application's state
|
20 |
@dataclass
|
|
|
14 |
import io
|
15 |
from pydub import AudioSegment
|
16 |
from dataclasses import dataclass
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
def determine_pause(audio: np.ndarray, sampling_rate: int, state: AppState) -> bool:
|
21 |
+
"""Take in the stream, determine if a pause happened"""
|
22 |
+
|
23 |
+
temp_audio = audio
|
24 |
+
|
25 |
+
dur_vad, _, time_vad = run_vad(temp_audio, sampling_rate)
|
26 |
+
duration = len(audio) / sampling_rate
|
27 |
+
|
28 |
+
if dur_vad > 0.5 and not state.started_talking:
|
29 |
+
print("started talking")
|
30 |
+
state.started_talking = True
|
31 |
+
return False
|
32 |
+
|
33 |
+
print(f"duration_after_vad: {dur_vad:.3f} s, time_vad: {time_vad:.3f} s")
|
34 |
+
|
35 |
+
return (duration - dur_vad) > 1
|
36 |
|
37 |
# Define AppState dataclass for managing the application's state
|
38 |
@dataclass
|