From a6d4c6daf1c2bd0332ef7eb9f667d46c4a636cf7 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 18 Sep 2026 20:19:19 +0200 Subject: feat: audio capture and WAV encoding --- test_llamachat.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test_llamachat.py') diff --git a/test_llamachat.py b/test_llamachat.py index 8fb7a0e..586be47 100755 --- a/test_llamachat.py +++ b/test_llamachat.py @@ -15,6 +15,7 @@ """Self-checks for the non-GUI logic. Run: ./test_llamachat.py""" import contextlib +import io import json import os import subprocess @@ -378,6 +379,30 @@ def test_user_content(): print("ok user content assembly") +def test_audio_wav(): + """Recorded PCM becomes a readable WAVE file.""" + import wave + + from llamachat import audio + + # Eight bytes: four Int16 samples. + pcm = b"\x01\x00\x02\x00\x03\x00\x04\x00" + wav = audio.to_wav(pcm) + assert wav[:4] == b"RIFF" + assert wav[8:12] == b"WAVE" + + with wave.open(io.BytesIO(wav), "rb") as fh: + assert fh.getnchannels() == 1 + assert fh.getsampwidth() == 2 + assert fh.getframerate() == 16000 + assert fh.getnframes() == 4 + assert fh.readframes(4) == pcm + + # The recorder is optional: AVAILABLE must exist as a bool either way. + assert isinstance(audio.AVAILABLE, bool) + print("ok audio wav encoding") + + def test_markdown_rendering(): """Replies render as markdown; markup inside them stays literal.""" import os @@ -3847,6 +3872,7 @@ if __name__ == "__main__": test_reasoning_storage() test_migration_adds_reasoning() test_user_content() + test_audio_wav() test_prompt_store() test_token_estimate() test_usage_parsing() -- cgit v1.2.3