add splash screen on load

This commit is contained in:
riqo 2021-02-28 14:27:51 -06:00
commit 346bfcba01
9 changed files with 218 additions and 243 deletions

View file

@ -52,68 +52,21 @@ const ia = new portAudio.AudioIO({
closeOnError: false,
},
});
// ia.setEncoding('base64');
ia.setEncoding('base64');
ia.start();
ia.on('error', (e) => {
console.log('error recording audio', + e);
});
ia.on('data', (chunk) => {
audioInput.push(chunk);
const buf = Buffer.from(chunk, 'base64');
audioInput.push(buf);
});
const ao = new portAudio.AudioIO({
outOptions: {
channelCount: 1,
sampleFormat: portAudio.SampleFormat16Bit,
sampleRate: 16000,
deviceId: -1, // Use -1 or omit the deviceId to select the default device
closeOnError: true // Close the stream if an audio error is detected, if set false then just log the error
}
});
ao.start();
const callback = () => {
console.log('yayayay')
}
const play = (audio) => {
console.log('audio length', audio.length);
let i = 0;
write();
function write() {
let ok = true;
do {
const chunk = audio[i]
console.log(chunk, i)
i++;
if (i === audio.length - 1) {
// Last time!
ao.write(chunk, null, callback);
} else {
// See if we should continue, or wait.
// Don't pass the callback, because we're not done yet.
ok = ao.write(chunk, null);
}
} while (i < audio.length - 1 && ok);
if (i < audio.length - 1) {
// Had to stop early!
// Write some more once it drains.
ao.on('drain', write);
}
}
}
async function processAudio() {
const buf = Buffer.concat(audioInput);
play(audioInput);
audioInput = [];
transcribeSpeech({