Help with audio stream.
Im trying to make a bot which would capture the incoming audio from a voice channel and play it back in realtime, how can i do this?, i tried doing this but it didnt work
12 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!nothing happens, and yes i did pass in selfDeaf as false
i tried to console.log the
opusStream
variable, and yea its working
but its not playing any audio into the vc
and the event does trigger when i speak into the vc
but thats all that happensTo debug your voice connection and player:
- Use
debug: true
when creating your VoiceConnection
and AudioPlayer
- Add an event listener to the <VoiceConnection> and the <AudioPlayer>:
- Add an error
listener to the stream you are passing to the resource:
Note: The <>
represents classes that need to be adapted to their respective name in your code
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of AudioReceiveStream
im guessing opusStream
is a AudioReceiveStream
, so to fix the problem how do i get the buffer from the AudioReceiveStream
?here is the full ss of the error
i tried using
and it still doesnt work.
im getting this error from the
connection.on("debug")
Update:
im trying to make my bot capture the audio coming from a voice channel and then play it back into the same vc in realtime, but i keep getting error AudioPlayerError: capture_pattern is not OggS
from the connection.on("debug", console.log);
here is my code
Another update.
now what im trying to do is to make a bot who will capture audio from one voice channel and play that into another voice channel, its basically cross server call heres the code i have right now
the player status changes to "buffering" everytime i use the player.play but it never changes to "playing"
and the resource is valid
i checked
what could be the problem here.
also debuggers dont throw anything.
here is what i get when i log resource if that may help
anyone coming into this thread please read from hereI suppose while waiting on a response to https://discord.com/channels/222078108977594368/1167109032687968348/1167183879954767883, here's a side note
your latest code seems to be overly complicated
to address this error https://discord.com/channels/222078108977594368/1167132377156419584/1167146956716519534, you'd want to use
StreamType.Opus
for an object mode opus stream
it's unnecessary to use demuxProbe
as there's nothing to demux
it's already an opus streami decided to just send the whole code because i thought it will be better than just sending in parts as i have been facing this error for long i thought i might have overlooked on something
in simple currently the callers array only has 2 instances of a custom class, the class includes the client, connection, and some other variables like connnectionId, etc which the program uses, my main goal is to make something like omegle but for audio and on discord, the bot is simply supposed to listen to the audio in vc1 and then play it in vc2 in realtime (thats why there is a array of players) and as you can see im stuck at the very end of coding this where i just need to take audio from one vc and play it in another in realtime
the documentation about the discord/voice is very vague mostly so i was having a hard time understanding what the problem was when it kept saying object mode is not supported or something so i just simply decided to make it non object mode by using
PassThrough
and demuxProbe
im pretty sure it shouldn't cause any issues right..it kept saying object mode is not supported or somethingyes, that is due to specifying the wrong stream type as documented, the
Opus
type is expected to be in object mode unlike any of the other stream types
https://discord.js.org/docs/packages/voice/main/StreamType:Enum#Opus
the issue of the player being stuck in the buffering
state may have been fixed after you added the GuildVoiceStates
intent, as the connection would need to be ready to actually send audio
but if the issue persists, the issue may be due to improper mutation from piping through a PassThrough
to use demuxProbe
nope it still continued after I added the intent
i will try that first thing in the morning