RikiBorders / Goose

A responsive multi-purpose Discord Bot
0 stars 0 forks source link

[feature] radio stations #15

Closed RikiBorders closed 9 months ago

RikiBorders commented 10 months ago

finally get to work on this fun one.

radio stations are accessed by the command .radio, which will prompt the user with a radio selection embed. Once a radio station is selected, provided the bot is not playing audio currently, the audio files from the radio station will begin playing (radio station should be instantiated in GooseBot beforehand).

Radio station is reset/turned off by the clear command, stop command, or by using the 'stop' button in the radio station embed.

radio station embed should include a selection of radio stations names, with a corresponding button to select each station. There should also be a 'stop' button (or equivalent) that stops any currently playing radio stations from playing more audio immediately.

RikiBorders commented 9 months ago

songs are being loaded on bot bootup, but its slow. This can be sped up ALOT by parallelizing the process. Gonna go back and do that once the radio is fully functional

RikiBorders commented 9 months ago

The GREAT news: The functionality for crossfading audio works. We can seamlessly add commentary, ads, etc without an issue.

The AWFUL news: I now have a serious optimization problem on my hands. The radio class' generate_playlist() method uses over a gigabyte of memory (this has been confirmed by tracing memory allocation). Jesus Christ! This needs to be optimized to somehow be under 100 mb.

RikiBorders commented 9 months ago

Addressing the AWFUL news:

I think it's a futile effort to reduce memory usage when generating playlists. There aren't any other audio mixing packages that are quite as easy to use out-of-the-box as pydub, and within pydub the only alternative to processing the audio is overlaying using the mixer class. I suspect the mixer class won't provide much of a boost in memory efficiency due to the fact that the audio likely undergoes a very similar under the hood procedure as the appending of AudioSegement(s). This is overall a costly endeavor, and while optimizations can (and should) be made, I don't think it can be reduced under 200 mb - atleast without some seriously large efforts.

Here is my proposed solution:

Instead of generating a new playlist everytime the bot starts, a new playlist will be generated before the bot is even launched. We can change the playlist via a separate script, so the generate_playlist function is not called on bot bootup. This also allows for the newly generated playlist to be uploaded to the bot separately.

In order to ensure the playlsit is unique, we can use the playlist generation script to generate a new playlist automatically on time intervals, and upload the file to github. This can be done weekly, daily, etc.

A note: 1 hour of audio is approximately 50mb

RikiBorders commented 9 months ago

Feature was implemented so this can be closed. The discussion on memory issues has been moved to:

https://github.com/RikiBorders/Goose/issues/18#issue-2040247742