QiCuiHub / discord-audio-pipe

Route computer audio into a discord bot
MIT License
152 stars 17 forks source link

Support request: sample rate #31

Closed scooper4711 closed 3 years ago

scooper4711 commented 3 years ago

The default sample rate appears to be 48khz.

Discord offers 96kbps and I have boosted to 128kbps. I know that kHz and bps are two different measures, but I would have expected 128kbps to support a higher sample rate.

I'm using (blackhole)[https://existential.audio/blackhole/] so this may end up bouncing over to them. But I've set Blackhole to be at 192kHz. If I change the sample rate in sound.py to anything higher than 48000 the sound is awful. I have increased the audio chat to maximum bitrate in discord settings.

Where can I look, what can I tweak?

scooper4711 commented 3 years ago

The best lead I have so far is this from the (Discord API)[https://discordpy.readthedocs.io/en/latest/api.html#voiceprotocol]:

The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.

So I think that the audio stream is not opus encoded (even though I have opus installed) since anything other than int16, 48000 gets me either no or very choppy audio.

QiCuiHub commented 3 years ago

I don't think there is any wiggle room to modify the sample rate because the Discord API will only accept 48khz opus encoded data. Changing the defaults in sound.py means that audio with the wrong specifications will be sent to discord, which is why the audio disappears or becomes choppy.