PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
785 stars 163 forks source link

Sounds setters #395

Closed sockheadrps closed 2 months ago

sockheadrps commented 1 year ago

edit: Added TinyTag as a dependency to detect audio file meta data for channels and rate to auto set those values. TinyTag is MIT and has no external dependencies of its own

Pull request summary

This could be a solution to #358

The sample rate of audio for Sound is hard coded (it might have something to do with YTDL, Im not sure), however if you create a sound using a local file

Sound(source="my_audio.mp3")

it's possible and likely to have files with different sample rates. Ive personally run into this issue and have seen others run into it as well, and the only solution right now is to hack at the library code to change the sample rate manually.

This PR just gives Sound.rate and Sound.channels a setter on each class property. Maybe in the future I can look at pulling sample meta data from the suppled audio file, but sometimes that can even be wrong so those class properties kind of need to be able to be set.

Checklist

IAmTomahawkx commented 1 year ago

@sockheadrps sorry for the late response, I kind of forgot to check prs. Currently this pr is failing lints, please fix that by running black twitchio -l120. Additionally, due to the new dependency the docs fail to build. Please add the dependency to both setup.py under the sounds extra and the docs requirements.txt. Beyond that it looks fine to merge