add speechrecorder to background

This commit is contained in:
riqo 2020-12-30 11:55:27 -05:00
commit 3f52457956
3 changed files with 43 additions and 4 deletions

View file

@ -36,7 +36,11 @@ export default function useInputController() {
function keyupHandler(e: any) {
if (e.key === " " && visualizeStream.value) {
console.log("stop recording");
recorder.stop();
// recorder.stop();
window.postMessage({
myTypeField: 'update-recorder',
record: false
}, '*')
visualizeStream.value = false;
paths.value = []
audioBubbleWidth.value = 10;
@ -55,7 +59,6 @@ export default function useInputController() {
recorder = initRecorder(stream);
})
// determine whether to render text or audio based one the keyboard input
watch(input, (input, prevInput) => {
if (prevInput !== "" || prevInput.length > 0) {
@ -67,7 +70,12 @@ export default function useInputController() {
if (input === " " && visualizeStream.value === false) {
console.log("record MediaStream");
visualizeStream.value = true;
recorder.start();
// recorder.start();
window.postMessage({
myTypeField: 'update-recorder',
record: true
}, '*')
expandBubble(audioBubbleWidth);
visualizeStreamAsPaths(stream, paths, audioBubbleWidth);
return;