Add voice messages
This commit is contained in:
@@ -27,10 +27,13 @@ def record() -> str:
|
||||
speaking_started = False
|
||||
max_chunks = int(16000 / 1024 * MAX_DURATION)
|
||||
silence_chunks_needed = int(16000 / 1024 * SILENCE_DURATION)
|
||||
warmup_chunks = int(16000 / 1024 * 0.3) # 0.3 сек — эхо звука активации
|
||||
|
||||
try:
|
||||
for _ in range(max_chunks):
|
||||
for i in range(max_chunks):
|
||||
data = stream.read(1024, exception_on_overflow=False)
|
||||
if i < warmup_chunks:
|
||||
continue # пропускаем эхо от звука активации
|
||||
frames.append(data)
|
||||
|
||||
amplitude = np.abs(np.frombuffer(data, dtype=np.int16)).mean()
|
||||
|
||||
Reference in New Issue
Block a user