Skip to content

Commit

Permalink
websocket realtime wip(6)
Browse files Browse the repository at this point in the history
  • Loading branch information
davorinrusevljan committed Dec 19, 2024
1 parent 972b53b commit 9d959db
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions notebook/agentchat_realtime_websocket/static/Audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Audio {
const sessionStarted = {
event: "start",
start: {
streamSid:"dsfstreamSidsdf",
streamSid: crypto.randomUUID(),
}
}
this.socket.send(JSON.stringify(sessionStarted))
Expand All @@ -42,8 +42,6 @@ export class Audio {
console.log("Received web socket message")
const message = JSON.parse(event.data)
if (message.event == "media") {
console.log("got media payload..")

const bufferString = atob(message.media.payload); // Decode base64 to binary string
const byteArray = new Uint8Array(bufferString.length);
for (let i = 0; i < bufferString.length; i++) {
Expand All @@ -68,8 +66,6 @@ export class Audio {

const stream = await navigator.mediaDevices.getUserMedia({ audio: { sampleRate:24000} });
this.stream = stream;
console.log("Audio tracks", stream.getAudioTracks())
console.log('Sample rate :', stream.getAudioTracks()[0].getSettings().sampleRate)
this.inAudioContext = new AudioContext({ sampleRate: 24000 });

// Create an AudioNode to capture the microphone stream
Expand Down Expand Up @@ -182,7 +178,6 @@ export class Audio {
}

// Create an audio buffer from the Float32Array
console.log("sample rate is ", this.outAudioContext.sampleRate)
const audioBuffer = this.outAudioContext.createBuffer(1, audioData.length, 24000);
audioBuffer.getChannelData(0).set(audioData);

Expand Down

0 comments on commit 9d959db

Please sign in to comment.