-
Describe the bug I've no experience streaming audio so this entire thing is a bit of a mystery to me, otherwise i'd try to solve this and send a PR. I'm sort of stumbling in the dark. I see some functions included in the voice package that seem to be there to help with streaming audio over UDP, i'm attempting use them. Though, I noticed the examples, and the documentation both do not use these functions. I'm guessing they just haven't been updated. I'm sure there is more a chance that i've made an obvious mistake. Error
To Reproduce func writeAudio(conn voice.Conn) error {
file, err := os.Open("../../audio/file.opus")
if err != nil {
return err
}
r := voice.NewOpusReader(file)
b, err := r.ProvideOpusFrame()
for err != nil {
conn.UDP().Write(b)
}
r.Close()
return nil
} The code panics at r.ProvideOpusFrame() Expected behavior Disgo Version(please complete the following information):
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Unrelated: |
Beta Was this translation helpful? Give feedback.
-
This means you need to split the frames from an opus frame yourself The example uses the You need to call
|
Beta Was this translation helpful? Give feedback.
conn.UDP().Write()
expects you to write exactly one Opus frame.This means you need to split the frames from an opus frame yourself
The example uses the
voice.NewOpusReader
which implements theOpusFrameProvider
interfaceYou need to call
conn.SetOpusFrameProvider()
with thevoice.NewOpusReader()
to make it play the whole opus filevoice.NewOpusReader()
expects the following format of the opus file:Frame length (4 bytes) Opus Frame (x Bytes)
And repeat
You can check the implementation here https://github.com/disgoorg/disgo/blob/master/voice/opus.go#L20