Add voice messages

This commit is contained in:
d.klimov
2026-04-12 15:59:25 +03:00
parent 7ca8268b78
commit 128cc70ab9
5 changed files with 38 additions and 10 deletions

View File

@@ -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()