diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-18 20:19:19 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-18 20:19:19 +0200 |
| commit | a6d4c6daf1c2bd0332ef7eb9f667d46c4a636cf7 (patch) | |
| tree | 40a19fbed7eeea07c605f92ca652b841773d7085 /test_llamachat.py | |
| parent | 446c0d537c60b39200e36f9ebc79242668c08d3e (diff) | |
| download | llamachat-a6d4c6daf1c2bd0332ef7eb9f667d46c4a636cf7.tar.gz llamachat-a6d4c6daf1c2bd0332ef7eb9f667d46c4a636cf7.zip | |
feat: audio capture and WAV encoding
Diffstat (limited to 'test_llamachat.py')
| -rwxr-xr-x | test_llamachat.py | 26 |
1 files changed, 26 insertions, 0 deletions
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() |
