receiver.speaking.on start and opusStream not in sync

Hey there! So my issue is that the start speaking event and opusStream are not in sync with each other. So for example, the opusStream can still be going when the person has stopped talking and has emitted the start speaking event again. So then the issue is that I get double recordings where portions of audio are the same in each recording. Another summary example: - User Starts speaking (1) - opusStream subscription happens - User stops speaking (1) - For some reason the opusStream doesn't stop when the user stops talking (this doesn't happen all the time, but it happens) - User starts speaking again (2) - opusStream subscription happens again - User stops speaking (2) - Both opusStream subscriptions end. - I get a recording that has the speaking from User Start speaking 1 all the way to User Stop Speaking 2 and a second recording that has from User start speaking 2 to User stop speaking 2. So essentially, I want to make sure that the opusStream stops before the user emits the start speaking event again. Here's my simple example code:
receiver.speaking.on("start", async userId => {
const user = await client.users.fetch(userId).catch(e => console.log(e));
if (user.bot) return;
const opusStream = voice_Connection.receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 100
}
});
});
receiver.speaking.on("start", async userId => {
const user = await client.users.fetch(userId).catch(e => console.log(e));
if (user.bot) return;
const opusStream = voice_Connection.receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 100
}
});
});
Let me know if anything is confusing or you need more clarification to help me resolve this issue shibaheart
13 Replies
d.js docs
d.js docs3y 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.
dzlandis
dzlandisOP3y ago
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.8.0
- opusscript: not found

Encryption Libraries
- sodium-native: 3.3.0
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found

FFmpeg
- version: 5.0.1-essentials_build-www.gyan.dev
- libopus: yes
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.8.0
- opusscript: not found

Encryption Libraries
- sodium-native: 3.3.0
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found

FFmpeg
- version: 5.0.1-essentials_build-www.gyan.dev
- libopus: yes
And I'm using Discord.js v13.9.2 and node v16.6.1 if it matters. Still awaiting an answer :)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
dzlandis
dzlandisOP3y ago
Can you provide an example of how to do this? Specifically, how to "section the stream"
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
dzlandis
dzlandisOP3y ago
By doing it this way, how am I supposed to determine whether to unpipe the stream or not HmmSip specifically, in my case, I want bits of data to be sent somewhere else when the user stops talking. So I don't want like a long recording. I want little bits of places where they started and stopped talking yus
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
dzlandis
dzlandisOP3y ago
Correct. But how would I get the opusStream in that new event?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
dzlandis
dzlandisOP3y ago
What's the difference between doing that and what I showed in the example with EndBehavior HmmSip
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
dzlandis
dzlandisOP3y ago
I'm worried that I will simply run into the same issue when using receiver.speaking.on("end") I'd also need an example to properly execute this. Again, still waiting for a more clear answer on this. Should I wait for them to fix EndBehavior? Is it known that it doesn't work correctly?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server