i have an arraybuffer how can i trasform it to use in createAudioResource()?
help
34 Replies
- What are your intents?
GuildVoiceStates
is required to receive voice data!
- Show what dependencies you are using -- generateDependencyReport()
is exported from @discordjs/voice
.
- Try looking at common examples: https://github.com/discordjs/voice-examples.
- 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!where are you getting an arraybuffer from anyways
turn it into a Readable
and after that i can push it in the method?
do u have the example code ? i never worked on audio so im very dumb at that
yes
no
ty i'll try now
❤️
is it possible to play the audio instantaneously, like a normal user, I enclose the code from which I have to take the buffers
what are you working with? what is frame
im thinking its better to just create a Readable and push your buffer into it and play the readable outside of this loop
im trying to do something like voice call
with an ia
but what is
ev.frame
@luomo what package/website/whatever are you getting the data fromfrom another api
which is?
🫠
okay nevermind, just do this
i thought to do an intervall
no
what i said is the best option
because the way you have it now (and with interval) you are re-creating a different stream every time you receive an audio buffer
it is bad
i want make an intervall out of the event , because i have to create the readable again if i want do it automatically
but u only need to do make the readable once if you keep pushing the buffer data to it
or are you telling me that by writing it out, the readable is automatically updated once created and also plays the new buffers?
if you push yes thats how streams work
tysm i'll test it
is this what you mean?
@pat
try
it saves the data but if i play i can't play it if its null
since it runs it once and the readable is empty at that time it will not play the audio
put infinity as option for silence frames
what do u mean?
when the stream fully consumes the buffer you gave it, the stream will be empty (and end), not playing audio is correct
so you need to put silence frame inbetween
in createAudioResource theres an option
name?
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
five is ok?
or i need to increment it?
:interface: CreateAudioResourceOptions
@0.17.0
Options that are set when creating a new audio resource.
@pat i tried but not works
how i create it help pls
😭
:node:
fs.createReadStream(path[, options])
Unlike the 16 KiB default highWaterMark for a <stream.Readable>, the stream returned by this method has a default highWaterMark of 64 KiB.options can include start and end values to read a range of bytes from the file instead of the entire file.i have to write the push in it?
🫠
ok, and for the method read()?
right now? @Qjuh
like that "readable = createReadStream(Buffer.from(ev.frame.data.buffer));"
?
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes.
@Qjuh
i think i can't use it in the way u told me