From 81f7647c811768de2e95b16489ce17a11a001ca3 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 2 May 2022 19:39:59 +0300 Subject: [PATCH] js : fix test and example --- examples/ggwave-js/index-tmpl.html | 2 ++ tests/test-ggwave.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/ggwave-js/index-tmpl.html b/examples/ggwave-js/index-tmpl.html index 2b4d9b4..440f142 100644 --- a/examples/ggwave-js/index-tmpl.html +++ b/examples/ggwave-js/index-tmpl.html @@ -137,7 +137,9 @@ recorder.onaudioprocess = function (e) { var source = e.inputBuffer; var res = ggwave.decode(instance, convertTypedArray(new Float32Array(source.getChannelData(0)), Int8Array)); + if (res && res.length > 0) { + res = new TextDecoder("utf-8").decode(res); rxData.value = res; } diff --git a/tests/test-ggwave.js b/tests/test-ggwave.js index 48e40ec..19876c0 100644 --- a/tests/test-ggwave.js +++ b/tests/test-ggwave.js @@ -13,7 +13,7 @@ factory().then(function(ggwave) { // decode the audio waveform back to text var res = ggwave.decode(instance, waveform); - if (res != payload) { + if (new TextDecoder("utf-8").decode(res) != payload) { process.exit(1); } });