add speech recorder + ws
This commit is contained in:
parent
b669c99df0
commit
abbfe42093
7 changed files with 125 additions and 75 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue