Listen to user vocal input using connection

hey, i couldn't find any reliable form of making the client listen to vocal input when its connected. can i have some guidance about it?
3 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs2y ago
property VoiceReceiver#speaking The speaking map of the receiver.
Aviv
AvivOP2y ago
thanks boss hey, using the speaking map i've set an eventListener like this:
async listenToUser(user: User) {
const listener = voiceConnectionUtilities.getConnection()?.receiver;
listener?.speaking.addListener('start', (userId: string) => {});
}
async listenToUser(user: User) {
const listener = voiceConnectionUtilities.getConnection()?.receiver;
listener?.speaking.addListener('start', (userId: string) => {});
}
I've noticed a lot of people were using the connection.subscribe(userid) option and get data by chunks but i haven't really come around it yet. is there a way to do so without chunks, only using the voicemap? in addition, i tried looking for your advice to take example from the voice-example github repository. I could not find anything of the sort, probably missing it i searched on the main development github repository with no success. thank you very much! do you maybe know why this is happening? 'errored' friend from the stream object: errored: Error [ERR_STREAM_PUSH_AFTER_EOF]: stream.push() after EOF at new NodeError (node:internal/errors:371:5) at readableAddChunk (node:internal/streams/readable:277:30) at AudioReceiveStream.Readable.push (node:internal/streams/readable:228:10) at AudioReceiveStream.push (file:///C:/Users/User/Desktop/Root/Development/Discord%20Bot/ShiraBetzibur/node_modules/@discordjs/voice/dist/index.mjs:1306:18) at VoiceReceiver.onUdpMessage (file:///C:/Users/User/Desktop/Root/Development/Discord%20Bot/ShiraBetzibur/node_modules/@discordjs/voice/dist/index.mjs:1542:16) at VoiceUDPSocket.emit (node:events:526:28) at VoiceUDPSocket.onMessage (file:///C:/Users/User/Desktop/Root/Development/Discord%20Bot/ShiraBetzibur/node_modules/@discordjs/voice/dist/index.mjs:262:10) at Socket.<anonymous> (file:///C:/Users/User/Desktop/Root/Development/Discord%20Bot/ShiraBetzibur/node_modules/@discordjs/voice/dist/index.mjs:249:48) at Socket.emit (node:events:526:28) at UDP.onMessage [as onmessage] (node:dgram:922:8) { code: 'ERR_STREAM_PUSH_AFTER_EOF'
async listenToUser() {
const listener = voiceConnectionUtilities.getConnection()?.receiver;
listener?.speaking.addListener('start', (userId: string) => {
const stream = listener?.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence, duration: 1000 } });
console.log(stream);
});
}
async listenToUser() {
const listener = voiceConnectionUtilities.getConnection()?.receiver;
listener?.speaking.addListener('start', (userId: string) => {
const stream = listener?.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence, duration: 1000 } });
console.log(stream);
});
}
v16.14.2 oh, nice. is there an FAQ channel i can look for questions like this as i don't want to bother you too much 🙂 i think the example is deprecated as prism opus does not have oggLogicalBitStream or Opushead.. const oggStream = new prism.opus.OggLogicalBitstream({ opusHead: new prism.opus.OpusHead({ channelCount: 2, sampleRate: 48000 }), pageSizeControl: { maxPackets: 10 } }); and good morning 🙂 do you know any other FeelsBadMan again. when i tried to use the prism library it stated i need to use node-crc, when i tried to installed it i got these errors:
npm i node-crc
npm ERR! code 1
npm ERR! path C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\node-crc
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c napi build --release --platform --js index.cjs --dts index.d.cts && node build.js
npm ERR! Type Error: Could not parse the Cargo.toml: Error: Command failed: cargo metadata --format-version 1 --manifest-path "C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\node-crc\Cargo.toml"
npm ERR! 'cargo' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR!
npm ERR! 'cargo' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR! at BuildCommand.<anonymous> (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:11300:23)
npm ERR! at Generator.next (<anonymous>)
npm ERR! at C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3512:71
npm ERR! at new Promise (<anonymous>)
npm ERR! at __awaiter$1 (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3508:12)
npm ERR! at BuildCommand.execute (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:11286:16)
npm ERR! at BuildCommand.validateAndExecute (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:2038:37)
npm ERR! at C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3095:53
npm ERR! at noopCaptureActivator (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3353:12)
npm ERR! at Cli.run (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3095:30)

npm ERR! A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2023-06-24T21_36_06_992Z-debug-0.log
npm i node-crc
npm ERR! code 1
npm ERR! path C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\node-crc
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c napi build --release --platform --js index.cjs --dts index.d.cts && node build.js
npm ERR! Type Error: Could not parse the Cargo.toml: Error: Command failed: cargo metadata --format-version 1 --manifest-path "C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\node-crc\Cargo.toml"
npm ERR! 'cargo' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR!
npm ERR! 'cargo' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR! at BuildCommand.<anonymous> (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:11300:23)
npm ERR! at Generator.next (<anonymous>)
npm ERR! at C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3512:71
npm ERR! at new Promise (<anonymous>)
npm ERR! at __awaiter$1 (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3508:12)
npm ERR! at BuildCommand.execute (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:11286:16)
npm ERR! at BuildCommand.validateAndExecute (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:2038:37)
npm ERR! at C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3095:53
npm ERR! at noopCaptureActivator (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3353:12)
npm ERR! at Cli.run (C:\Users\User\Desktop\Root\Development\Discord Bot\ShiraBetzibur\node_modules\@napi-rs\cli\scripts\index.js:3095:30)

npm ERR! A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2023-06-24T21_36_06_992Z-debug-0.log
probably stating i need cargo and rust so i installed them. my question is im using heroku and i haven't really find a way to install rust buildpack for heroku. can i dodge this maybe? have you encountered this issue?
Want results from more Discord servers?
Add your server