jaemil
jaemil
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by jaemil on 3/22/2024 in #djs-voice
Problem saving audioBuffer to file - whisper api
Thank you so much, it did work. now i only need to double the sample rate from 48000 to 96000. idk why the recorded audio is in slowmo..
8 replies
DIAdiscord.js - Imagine an app
Created by jaemil on 3/22/2024 in #djs-voice
Problem saving audioBuffer to file - whisper api
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 300,
},
});

const bufferData: Uint8Array[] = [];
opusStream
.pipe(new OpusDecodingStream())
.on("data", (data: Uint8Array) => {
bufferData.push(data);
});

opusStream.on("end", async () => {
const voiceMessage = await createVoiceMessage({
client,
bufferData,
user,
connection,
speechOptions,
});

if (voiceMessage) client.emit(SpeechEvents.speech, voiceMessage);
});
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 300,
},
});

const bufferData: Uint8Array[] = [];
opusStream
.pipe(new OpusDecodingStream())
.on("data", (data: Uint8Array) => {
bufferData.push(data);
});

opusStream.on("end", async () => {
const voiceMessage = await createVoiceMessage({
client,
bufferData,
user,
connection,
speechOptions,
});

if (voiceMessage) client.emit(SpeechEvents.speech, voiceMessage);
});
this is how audioBuffer is created https://github.com/Rei-x/discord-speech-recognition/blob/main/src/bot/events/speech.ts
8 replies
DIAdiscord.js - Imagine an app
Created by jaemil on 3/22/2024 in #djs-voice
Problem saving audioBuffer to file - whisper api
8 replies
DIAdiscord.js - Imagine an app
Created by jaemil on 3/22/2024 in #djs-voice
Problem saving audioBuffer to file - whisper api
const client = new Client({
intents: [
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
],
});
addSpeechEvent(client, {
speechRecognition: resolveSpeechWithWhisper,
ignoreBots: true,
});
const client = new Client({
intents: [
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
],
});
addSpeechEvent(client, {
speechRecognition: resolveSpeechWithWhisper,
ignoreBots: true,
});
8 replies
DIAdiscord.js - Imagine an app
Created by jaemil on 3/22/2024 in #djs-voice
Problem saving audioBuffer to file - whisper api
im using the SpeechEvents.speech event.
client.on(SpeechEvents.speech, async (msg) => {
// If bot didn't recognize speech, content will be empty
// if (!msg.content) return;

console.log("msg", msg);

console.log("audioBuffer type:", typeof msg.audioBuffer);
console.log("audioBuffer:", msg.audioBuffer);
}
client.on(SpeechEvents.speech, async (msg) => {
// If bot didn't recognize speech, content will be empty
// if (!msg.content) return;

console.log("msg", msg);

console.log("audioBuffer type:", typeof msg.audioBuffer);
console.log("audioBuffer:", msg.audioBuffer);
}
8 replies
DIAdiscord.js - Imagine an app
Created by jaemil on 3/22/2024 in #djs-voice
Problem saving audioBuffer to file - whisper api
node: v20.11.0
8 replies