diff --git a/src/background.ts b/src/background.ts
index 9204046..e08bc2a 100644
--- a/src/background.ts
+++ b/src/background.ts
@@ -6,7 +6,9 @@ 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";
+
+// TODO: connect To Crimata-BE
+// import WebSocket from "ws";
// const ws = new WebSocket("ws://localhost:8080");
// ws.on("open", function open() {
@@ -16,18 +18,8 @@ import WebSocket from "ws";
// 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);
-// }
-// });
+
+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.
@@ -42,7 +34,7 @@ function createWindow() {
// Create the browser window.
win = new BrowserWindow({
width: 800,
- height: 600,
+ height: 1200,
webPreferences: {
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
@@ -62,6 +54,25 @@ function createWindow() {
win.loadURL("app://./index.html");
}
+ win.webContents.on('did-finish-load', () => {
+ if (win) {
+ recorder.start({
+ onAudio: (audio: object, speech: boolean) => {
+ if (win) {
+ win.webContents.send('render-audio', {
+ audio: audio,
+ speech: speech
+ })
+ }
+ if (speech) {
+ // TODO: send audio to crimata BE
+ // ws.send(audio);
+ }
+ }
+ });
+ }
+ })
+
win.on("closed", () => {
win = null;
});
diff --git a/src/components/AI/index.vue b/src/components/AI/index.vue
index 9139461..a4b36ed 100644
--- a/src/components/AI/index.vue
+++ b/src/components/AI/index.vue
@@ -3,13 +3,13 @@
-
+
@@ -19,6 +19,7 @@
+
diff --git a/src/components/UI/UIDetails/messageRenderer.vue b/src/components/UI/UIDetails/messageRenderer.vue
index c3f7795..0b9cce3 100644
--- a/src/components/UI/UIDetails/messageRenderer.vue
+++ b/src/components/UI/UIDetails/messageRenderer.vue
@@ -1,4 +1,10 @@
+