diff --git a/beatrice/sound_manager/bot.py b/beatrice/sound_manager/bot.py index 48cb488..7806b74 100644 --- a/beatrice/sound_manager/bot.py +++ b/beatrice/sound_manager/bot.py @@ -1,6 +1,16 @@ import asyncio import multiprocessing.connection +import os import traceback +# We need to bootstrap this before the bot loads Nextcord +# Some platforms (Alpine) need to provide a path because +# find_library will fail on them (musl). +# https://github.com/python/cpython/pull/18380 +from nextcord import opus +opus_path = os.getenv("OPUS_PATH", None) +if opus_path: + opus.load_opus(opus_path) + from nextcord.ext import commands from beatrice.util.background_tasks import BackgroundTasks try: diff --git a/beatrice/sound_manager/source.py b/beatrice/sound_manager/source.py index 544a8c6..ff95800 100644 --- a/beatrice/sound_manager/source.py +++ b/beatrice/sound_manager/source.py @@ -191,17 +191,6 @@ async def send_audio_packet(self, data: bytes, *, encode: bool = True) -> None: class AsyncEncoder(Encoder): def __init__(self, executor, loop: asyncio.AbstractEventLoop): - # Some platforms (Alpine) need to provide a path because - # find_library will fail on them (musl). - # https://github.com/python/cpython/pull/18380 - try: - _OpusStruct.get_opus_version() - except OpusNotLoaded as e: - opus_path = os.getenv("OPUS_PATH", None) - if opus_path: - opus.load_opus(opus_path) - else: - raise e super().__init__() self.executor = executor self.loop = loop