feat: adiciona Silero VAD local com configuração por ambiente
This commit is contained in:
30
tests/test_silero_vad_integration.py
Normal file
30
tests/test_silero_vad_integration.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Run the installed Silero ONNX model locally; no STT/TTS service required."""
|
||||
|
||||
import socket
|
||||
|
||||
import pytest
|
||||
|
||||
from voice_assistant.vad.silero import SileroVADAdapter
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def anyio_backend():
|
||||
return "asyncio"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_real_silero_processes_silence_without_network(monkeypatch):
|
||||
pytest.importorskip("silero_vad")
|
||||
|
||||
def forbid_network(*args, **kwargs):
|
||||
raise AssertionError("VAD runtime must not open network connections")
|
||||
|
||||
monkeypatch.setattr(socket.socket, "connect", forbid_network)
|
||||
detector = SileroVADAdapter()
|
||||
try:
|
||||
assert await detector.process(bytes(2 * 16000 * 2)) == ()
|
||||
assert await detector.flush() == ()
|
||||
await detector.reset()
|
||||
assert await detector.process(bytes(1024)) == ()
|
||||
finally:
|
||||
await detector.aclose()
|
||||
Reference in New Issue
Block a user