aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_assistant.py11
-rw-r--r--tests/test_wav.mjs4
2 files changed, 8 insertions, 7 deletions
diff --git a/tests/test_assistant.py b/tests/test_assistant.py
index 7ea782b..0280e0c 100644
--- a/tests/test_assistant.py
+++ b/tests/test_assistant.py
@@ -199,19 +199,18 @@ class Client(Base):
self.assertTrue(until(lambda: {"type": "models"} in self.d.got))
self.assertEqual(self.m.state()["model"], "m1")
- def test_ask_carries_the_picked_model(self):
+ def test_voice_carries_the_picked_model(self):
self.d.push({"type": "models", "items": [{"id": "ears", "status": "loaded", "cloud": False,
"inputs": ["audio"]}]})
self.assertTrue(until(lambda: self.m.state()["models"]))
self.m.actions["model"]({"id": "ears"})
- self.m.actions["ask"]({"text": "hi"})
- self.assertTrue(until(lambda: {"type": "ask", "text": "hi", "model": "ears"} in self.d.got))
+ self.m.actions["voice"](b"RIFF\x24\x00\x00\x00WAVE" + b"\x00" * 32)
+ self.assertTrue(until(lambda: {"type": "ask", "text": "", "audio": str(a.VOICE),
+ "model": "ears"} in self.d.got))
self.assertTrue(self.m.state()["hears"])
def test_bad_input_is_refused(self):
- for bad in ({}, {"text": ""}, {"text": 3}):
- with self.assertRaises(a.ModuleError):
- self.m.actions["ask"](bad)
+ self.assertNotIn("ask", self.m.actions) # no keyboard on the tablet
with self.assertRaises(a.ModuleError):
self.m.actions["model"]({"id": "nope"})
diff --git a/tests/test_wav.mjs b/tests/test_wav.mjs
index 68f97d0..e28be9a 100644
--- a/tests/test_wav.mjs
+++ b/tests/test_wav.mjs
@@ -15,7 +15,7 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import assert from "node:assert/strict";
-import { encodeWav } from "../static/wav.js";
+import { encodeWav, peak } from "../static/wav.js";
const buf = encodeWav(new Float32Array([0, 1, -1]), 16000);
const v = new DataView(buf);
@@ -29,4 +29,6 @@ assert.equal(v.getUint32(24, true), 16000);
assert.equal(v.getUint16(34, true), 16);
assert.equal(v.getUint32(40, true), 6);
assert.deepEqual([v.getInt16(44, true), v.getInt16(46, true), v.getInt16(48, true)], [0, 32767, -32768]);
+assert.equal(peak(buf), 32768);
+assert.equal(peak(encodeWav(new Float32Array([0.001, -0.002]), 16000)), 65);
console.log("wav ok");