stream path animation v4
update input items styling add ipc event handler for message add send-message ipc handler add audio to send-message ipc remove extra JSON stringify statement for audio message add render bug fix for add contacts
This commit is contained in:
parent
52f6893c50
commit
1627e07964
23 changed files with 450 additions and 295 deletions
|
|
@ -8,22 +8,15 @@ import * as path from "path";
|
|||
import { SpeechRecorder } from "speech-recorder";
|
||||
|
||||
// TODO: connect To Crimata-BE
|
||||
// import WebSocket from "ws";
|
||||
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({ sampleRate: 16000, framesPerBuffer: 320 });
|
||||
|
||||
// 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.
|
||||
let win: BrowserWindow | null;
|
||||
let ws: any;
|
||||
|
||||
// Scheme must be registered before the app is ready
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
|
|
@ -56,44 +49,35 @@ function createWindow() {
|
|||
win.loadURL("app://./index.html");
|
||||
}
|
||||
|
||||
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
// ipcMain.on('audio-stream', (Event: any, Payload: any) => {
|
||||
// if (Payload.stream) {
|
||||
// console.log('begin streaming');
|
||||
// recorder.start({
|
||||
// onAudio: (audio: object, speech: boolean) => {
|
||||
// console.log(audio)
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// recorder.stop();
|
||||
// console.log('stop streaming')
|
||||
// }
|
||||
// })
|
||||
|
||||
// if (win) {
|
||||
// recorder.start({
|
||||
// onAudio: (audio: object, speech: boolean) => {
|
||||
// if (win) {
|
||||
// win.setTitle("Listening...");
|
||||
// // win.webContents.send('render-audio', {
|
||||
// // audio: audio,
|
||||
// // speech: speech
|
||||
// // })
|
||||
// if (speech) {
|
||||
// win.setTitle("Recording...");
|
||||
// // TODO: send audio to crimata BE
|
||||
// // ws.send(audio);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
ws = new WebSocket("ws://localhost:8080");
|
||||
ws.on("open", function open() {
|
||||
ws.send("[email protected]");
|
||||
});
|
||||
ws.on("message", (message: any) => {
|
||||
const parsed = JSON.parse(message);
|
||||
console.log('new message', message)
|
||||
if (win) {
|
||||
win.webContents.send('render-message', {
|
||||
message: parsed
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('send-message', (Event: any, payload: any) => {
|
||||
const stringMessage = JSON.stringify(payload.message)
|
||||
ws.send(stringMessage);
|
||||
})
|
||||
|
||||
ipcMain.on('update-menu-bar', (Event: any, payload: any) => {
|
||||
// win.setTitle("Listening...");
|
||||
})
|
||||
})
|
||||
|
||||
win.on("closed", () => {
|
||||
win = null;
|
||||
ws = null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue