#๐Ÿ”’ Voice recording extremely slowed down?

16 messages ยท Page 1 of 1 (latest)

random thorn
#

I'm trying to record audio from a channel with my bot, but I don't know if it's a discordpy voice issue or FFMPEG, but the audio is extemely distorted and slowed down.

mental tangleBOT
#

@random thorn

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

random thorn
#

I've used WaveSink and BasicSink, BasicSink "works" but does the weird audio file, WaveSink just errors out.

#

This is the audio it recorded

#

pls ping on response i be forgetting Gekko_Wingman_Sad

languid matrix
#
 def combine_pcm_files(self):
        output_file = "recording.wav"
        input_files = [os.path.join(self.tempdir, f) for f in os.listdir(self.tempdir)]

        if not input_files:
            return None
        
        n_channels = 1
        sampwidth = 2
        framerate = 48000

        with wave.open(output_file, 'wb') as wf:
            wf.setnchannels(n_channels)
            wf.setsampwidth(sampwidth)
            wf.setframerate(framerate)

            for input_file in input_files:
                with open(input_file, 'rb') as pcm_file:
                    data = pcm_file.read()
                    wf.writeframes(data)

        return output_file

#

The effect you're getting implies your sample rate is too high

#

you should be adjusting your sample rate to fit what discord is sending you (which iirc is a voice channel property)

#

yeah

#

this is what's used in the wavsink code:

#
        with wave.open(data, "wb") as f:
            f.setnchannels(self.vc.decoder.CHANNELS)
            f.setsampwidth(self.vc.decoder.SAMPLE_SIZE // self.vc.decoder.CHANNELS)
            f.setframerate(self.vc.decoder.SAMPLING_RATE)
mental tangleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.