Audio duplication issue
I am working on a bot that will do, among other things, voice call recording. Something really strange is happening where I'm getting multiple copies of the same audio in different individual output files (I know this because I transcribe and store the individual files as text in a DB using OpenAI). When mixed together, it creates a weird echo effect.
My question is, when subscribing to the "start" event, should I be checking the SpeakingMap to see if something is already registered for a user? Or is there something else I'm doing wrong here? Code is at the link below:
https://github.com/brad95411/breadbot-public/blob/934fa4d37f62af83ee6e988c05156e8fdb7350b3/breadbot.js#L126
Any help is greatly appreciated!
GitHub
breadbot-public/breadbot.js at 934fa4d37f62af83ee6e988c05156e8fdb73...
Contribute to brad95411/breadbot-public development by creating an account on GitHub.
6 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPpackage.json has all dependency versions
https://github.com/brad95411/breadbot-public/blob/934fa4d37f62af83ee6e988c05156e8fdb7350b3/package.json
Node version: 16.18.1
GitHub
breadbot-public/package.json at 934fa4d37f62af83ee6e988c05156e8fdb7...
Contribute to brad95411/breadbot-public development by creating an account on GitHub.
Sharing an image of all package versions because I didn't realize how many had updated since they were installed
In one guild yes, in the other no. The bot currently lives in a guild I have for testing (which has one Voice Channel), and my fiance's guild (which has several) ,because her guild has much more activity then mine. The bot exhibits the same behavior in both guilds.
Note that at no time during testing has the bot been in a guild that has multiple VC calls going at the same time (because obviously the bot couldn't join more than one VC at a time).
I like suggestion 1 because it may actually be the issue, I've checked my log table and I'm having some weird issues with checking for an existing call ID in the DB it seems. In the midst of a C++ project at the moment, I'll switch over in a little bit and see if I can sort that issue and see if it fixes the problem. Thanks!
Qjuh, I think I've fixed it but I'm confused as to why it's fixed...
The first attempted fix, at line 138 (https://github.com/brad95411/breadbot-public/blob/develop_channel_sight/breadbot.js#L138) is to prevent another "start" listener from being added, this reported nothing in the log (either on the console or in the DB, winston is set up to go to both right now).
The second attempted fix, and the one that worked, at line 140 (https://github.com/brad95411/breadbot-public/blob/develop_channel_sight/breadbot.js#L140) is to prevent another AudioReceiveStream from being created when the user ID already exists in the subscriptions map. This did ultimately log when it was trying to double (or even triple or quadruple) up on the subscriptions, and the audio once coalesced into one single mp3 using my breadmixer Python script didn't have the echo effect like it's had before.
What I don't understand here is why would a map (specifically the subscriptions map in VoiceReceiver) allow more than one of the same key (the user ID) at all, or why the "start" event is being triggered in such close proximity that the old AudioReceiveStream isn't closing before the new one is starting.
Even if you don't have any ideas, I appreciate the help! I'll mark as resolved regardless in a day or two after of done more than one 5 minutes call to make sure everything is ok.
GitHub
breadbot-public/breadbot.js at develop_channel_sight · brad95411/br...
Contribute to brad95411/breadbot-public development by creating an account on GitHub.
Interesting, either way, at least the problem is gone. Thanks again!