From 47f55138b9d9280e91a9bcdf9d6d2ca5d634481f Mon Sep 17 00:00:00 2001 From: riqo Date: Thu, 4 Mar 2021 10:56:08 -0600 Subject: [PATCH] major improvements to audio transcription --- src/background/audio.ts | 8 ++++++-- tests/audio.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/background/audio.ts b/src/background/audio.ts index eba16ca..124811d 100644 --- a/src/background/audio.ts +++ b/src/background/audio.ts @@ -22,7 +22,12 @@ const audioOptions = { } // callback run on space bar key up and down. -const updateRecorder = (_event, payload: boolean): void => { record = payload }; +const updateRecorder = (_event, payload: boolean): void => { + record = payload; + if (!record) { + sendAudio(Buffer.from(audioContainer.input, 'base64')); + } +}; // listen for space key up/down event. ipcMain.removeAllListeners('update-recorder'); @@ -50,7 +55,6 @@ export function initAudioIO(): void { ai.on('data', (chunk: string) => { if (record) { - console.log('recording data') audioContainer.input += chunk; } else { if (audioContainer.input.length) audioContainer.input = ""; diff --git a/tests/audio.js b/tests/audio.js index 31acfca..b3008ff 100644 --- a/tests/audio.js +++ b/tests/audio.js @@ -80,7 +80,7 @@ const ao = new portAudio.AudioIO({ ao.start(); let counter = 0; -let tests = []; +const tests = []; function testCallback() { tests.forEach(t => console.log(t)) -- 2.43.0