#๐Ÿ”’ discord bot: Can't get `send_audio_packet` to play audio.

4 messages ยท Page 1 of 1 (latest)

buoyant plank
#

if self.new_responses:
    if not self.vc.is_playing():
        next_response = self.responses.pop(0)
        self.vc.send_audio_packet(next_response['audio'])
        # source = FFmpegPCMAudio(next_response['path'])
        ## source = FFmpegPCMAudio(next_response['audio']) # Doesnt work either
        # self.vc.play(source)
    
    if len(self.responses) == 0:
        self.new_responses = False

The commented out code where it converts the file to source and plays it, works fine. But saving to wav is only for testing, I do not want to be using processing time on saving anything. Right now I take the audio bytearray directly and save it to wav, only to play it later and delete it. I should be able to take this audio data and play it directly without having to save it as a file first.

The documentation for send_audio_packet says "Sends an audio packet composed of the data."

The wav file I create the source material from, is created from the audio bytearray in next_response['audio'].

send_audio_packet says it accepts byte-like objects, which includes bytearrays. So I don't really understand why this is not working?

I have also tried passing the audio bytearray to the ffmpeg, but that didn't work either.

Help me please, I would really hate to have to save the generated audio when I can work directly with the bytearrays that I would be writing to the files anyway...

runic urchinBOT
#

@buoyant plank

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.

runic urchinBOT
#

@buoyant plank

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.