add speech recorder + ws

This commit is contained in:
Enrique Hernandez 2020-10-13 20:19:32 -05:00
commit abbfe42093
7 changed files with 125 additions and 75 deletions

View file

@ -5,6 +5,29 @@ import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
const isDevelopment = process.env.NODE_ENV !== "production";
import * as path from "path";
import { SpeechRecorder } from "speech-recorder";
import WebSocket from "ws";
const ws = new WebSocket("ws://localhost:8080");
ws.on("open", function open() {
ws.send("hello fro client");
});
ws.on("message", (message: any) => {
console.log("received message", message);
});
const recorder = new SpeechRecorder();
recorder.start({
onAudio: (audio: object, speech: boolean) => {
if (speech) {
console.log(audio);
ws.send(audio);
}
console.log("recording");
// writeStream.write(audio);
}
});
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.