31 lines
834 B
Python
31 lines
834 B
Python
"""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()
|