dx0_
dx0_
DIAdiscord.js - Imagine an app
Created by dx0_ on 6/22/2023 in #djs-voice
Have speaking's data
connection.receiver.speaking.on('start', async (userId) => {
const receiverOptions = {
mode: 'mp3',
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 500
}
};

connection.receiver.subscribe(userId, receiverOptions);

})
connection.receiver.speaking.on("end", async (data, data2) => {
console.log(data)
})
connection.receiver.speaking.on('start', async (userId) => {
const receiverOptions = {
mode: 'mp3',
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 500
}
};

connection.receiver.subscribe(userId, receiverOptions);

})
connection.receiver.speaking.on("end", async (data, data2) => {
console.log(data)
})
please how to have the data collected ?
16 replies
DIAdiscord.js - Imagine an app
Created by dx0_ on 6/4/2023 in #djs-voice
subscribe a connection and convert pcm buffer response to mp3
Hi ! I want to convert this result :
const receiver = connection.receiver.subscribe(userId, {
mode: 'pcm'
});
const receiver = connection.receiver.subscribe(userId, {
mode: 'pcm'
});
to mp3. Please help me thanks !
30 replies
DIAdiscord.js - Imagine an app
Created by dx0_ on 5/7/2023 in #djs-voice
Say smthing in vocal to text.
Hi I want to keep the text that i said in vocale with this code :
joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
})
const connection = client.voice.connections.get(message.guild.id);
if (!connection) return; // bot is not connected to the voice channel

const receiver = connection.receiver;
const readable = new Readable();

const audioStream = receiver.createStream(message.member, {
mode: 'pcm'
});

audioStream.on('error', console.error);
audioStream.on('end', () => {
console.log('Audio stream ended');
});

readable._read = () => {};
readable.pipe(audioStream);

// handle audio data as you wish
// for example, you could use a speech-to-text API to transcribe the audio
readable.on('data', (chunk) => {
console.log('Received audio data:', chunk);
});
}
joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
})
const connection = client.voice.connections.get(message.guild.id);
if (!connection) return; // bot is not connected to the voice channel

const receiver = connection.receiver;
const readable = new Readable();

const audioStream = receiver.createStream(message.member, {
mode: 'pcm'
});

audioStream.on('error', console.error);
audioStream.on('end', () => {
console.log('Audio stream ended');
});

readable._read = () => {};
readable.pipe(audioStream);

// handle audio data as you wish
// for example, you could use a speech-to-text API to transcribe the audio
readable.on('data', (chunk) => {
console.log('Received audio data:', chunk);
});
}
but I have this error :
node:events:368
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'get')
at Client.<anonymous> (C:\Users\manou\OneDrive\Bureau\hahaha\index.js:103:49)
node:events:368
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'get')
at Client.<anonymous> (C:\Users\manou\OneDrive\Bureau\hahaha\index.js:103:49)
please help me thanks
11 replies