aboutsummaryrefslogtreecommitdiffstats
path: root/test_llamachat.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_llamachat.py')
-rwxr-xr-xtest_llamachat.py26
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()