Opus shared object file does not exist while making a discord.py music bot

So I recently restarted my bot, and there’s a lot of problems that popped up. One of them was that youtube_dl didn’t work, so I used a fork of it, yt_dlp and did

import yt_dlp as youtube_dl

I’ve created a temporary play music command, but it doesn’t work.

@commands.command()
async def test_play(self, ctx, *, query: str = ""):
	if not query:
		return await ctx.send("Your song request is emptier than your brain")
	ydl_opts = {
		'format': 'm4a/bestaudio/best',
        'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'm4a',}]
	}
	discord.opus.load_opus("opus")
	with youtube_dl.YoutubeDL(ydl_opts) as ydl:
		info = ydl.extract_info(query, download=False)
		url2 = info['webpage_url']
		print(url2)
		source = discord.FFmpegPCMAudio(url2)
		vc = ctx.voice_client
		vc.play(source)

It gives an error: OSError: opus: cannot open shared object file: No such file or directory
I have downloaded opuslib from Packages, and I have tried replacing opus in the load_opus() with opuslib, libopus, libopus.so.0, and none of them work. I have also tried putting ffmpeg there, which does not work either.
Is there any way to download opus, or maybe a workaround to this?

EDIT: I have downloaded libopus using nix-env -iA nixpkgs.libopus, but that did not change anything either. I cannot use apt-get as it requires sudo, and that is not possible in the shell.

Did you consider using another codec instead of Opus?
Like pcm_s16le?

I have not. How do I download it, and what should I write in my code to load this codec?

You don’t need to download it, he’s included in all ffmpeg builds.

When you set preferredcodec to 'wav' in your ydl_opts , the audio gets converted to WAV format, which uses PCM encoding.

Picking up your example:

@commands.command()
async def test_play(self, ctx, *, query: str = ""):
	if not query:
		return await ctx.send("Your song request is emptier than your brain")
	ydl_opts = {
		'format': 'bestaudio/best',
        'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'wav',
        'preferredquality': '192',}]
	}
	with youtube_dl.YoutubeDL(ydl_opts) as ydl:
		info = ydl.extract_info(query, download=False)
		url2 = info['formats'][0]['url']
		print(url2)
		source = discord.FFmpegPCMAudio(url2)
		vc = ctx.voice_client
		vc.play(source)

Tbh I’ve been switching all my Discord Music Bots to use Lavalink because ffmpeg is such a drag to use

It gives this error:

Error in test_play

Command raised an exception: OpusNotLoaded:

Edit: Could you send me a link to a tutorial or a bot that uses lavalink? I do have it imported but I think something went wrong so I just never got back to it.

I’d recommend finding tutorials online…

I’m starting a new “Template” but the project is still on work (I need to do some tinkering). I’ll be releasing in a few weeks but you can use as a guide to give you some directions about the code. There is a “Template” in replit which you can fork to use lavalink too (remember that lavalink is a server that run separetely from your bot). Check wavelink documentation: Wavelink 2.6.0b2 documentation

My replit project:
https://replit.com/@WindLother/Official-Discord-Music-Bot-with-lavalink