Skip to content

Commit

Permalink
FIx
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Dec 16, 2023
1 parent a47e305 commit 7c3600a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]
},
"security": {
"csp": "default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'"
"csp": null
},
"systemTray": {
"iconPath": "icons/icon.png",
Expand Down
9 changes: 8 additions & 1 deletion src/lib/audioRecorder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { error } from "tauri-plugin-log-api";
import { error, info } from "tauri-plugin-log-api";

export class AudioRecorder {
private _active = false;
Expand Down Expand Up @@ -73,14 +73,20 @@ export class AudioRecorder {
private async _createContext() {
// @ts-ignore-next-line
this._context = new (window.AudioContext || window.webkitAudioContext)();
info("Created audio context");
this._stream = await navigator.mediaDevices.getUserMedia({ audio: true });
info("Created stream");

info(`url: ${import.meta.url}`);
await this._context.audioWorklet.addModule(
new URL("./recorder.worklet.js", import.meta.url)
);
info("Added worklet");

this._source = this._context.createMediaStreamSource(this._stream);
info("Created source");
this._recorder = new AudioWorkletNode(this._context, "recorder.worklet");
info("Created recorder");

this._recorder.port.onmessage = (e) => {
if (!this._active) {
Expand All @@ -90,5 +96,6 @@ export class AudioRecorder {
};
this._active = true;
this._source.connect(this._recorder);
info("Connected source to recorder");
}
}

0 comments on commit 7c3600a

Please sign in to comment.