
Recherche avancée
Autres articles (62)
-
L’agrémenter visuellement
10 avril 2011MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté. -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)
Sur d’autres sites (12667)
-
How do I send pydub audio segment raw data using discord.py to a voice channel ? I get error, hear nothing or gibberish noise depending on parameters
8 mai 2021, par HielloAs the title says, I've been trying to send chunks audio data using discord.py to a voice channel. So using pydub I basically load an mp3 file (and playback works so file is ok), make chunks, send them as packages.
And then I tried to convert the mp3 file to opus file. It's playing too. Both files are ok.


There are a few stuff :


So the issue is, after I make the raw audio chunks list and try to send each element in it :


a) With Encode=True, I get an error about NoneType object not having encode attribute.


b) With Encode=False, it actually sends the data but I don't hear anything at all.


c) With Encode=False, but when loading the mp3 file with additional codec="opus" parameter, I hear gibberish noise. So it's not for conversion i guess okay...


d) With Encode=False, but when loading the opus file with additional codec="opus" parameter (without that codec="opus" i cant play the audio anyway), it's still the NoneType error.


-I have all the 3 executables (ffmpeg.exe, ffplay.exe and ffprobe.exe) in the same directory as the script. But not in PATH. (Didn't tell me anything about it and playback worked, plus i heard the gibberish noise too at least so no problem here)


-I also have m1.mp3 and m1.opus in the same directory as the script. It's ok.


-There are no subdirectories or anything else.


-I have PyNaCl and discord.py[audio] installed.


I don't know where I'm doing wrong. What kind of data was i supposed to send if not this ? Can I encode the raw audio myself to opus without too much work and definitely not saving a file even if it is temp ?
I don't want to just load the mp3 file all at once and play, I need to be able to make chunks. I don't want to save these chunks anywhere either.


Here is the code :


import discord
import pydub
import os
from pydub.utils import make_chunks
import asyncio

TOKEN = ":("


base_path = os.getcwd()
pydub.AudioSegment.ffmpeg = os.path.join(base_path, "ffmpeg.exe")
pydub.AudioSegment.ffprobe = os.path.join(base_path, "ffprobe.exe")
pydub.AudioSegment.ffplay = os.path.join(base_path, "ffplay.exe")
pydub.AudioSegment.converter = os.path.join(base_path, "ffmpeg.exe")

#audio = pydub.AudioSegment.from_file(os.path.join(base_path, "m1.mp3"), format="mp3")#, codec="opus")
audio = pydub.AudioSegment.from_file(os.path.join(base_path, "m1.opus"), codec="opus") #dont add format="opus". format isnt extension ig. https://github.com/jiaaro/pydub/issues/257
#audio = pydub.AudioSegment.from_file(os.path.join(base_path, "m1.opus")) #didnt hear anything at all evn with play(audio) below.

audio = audio[:9*1000] #first 9 seconds

#let me be sure that it actually plays.
from pydub.playback import play #needs simpleaudio to work idk...
play(audio)

chunks = make_chunks(audio, (1/20)*1000)

client = discord.Client()

@client.event
async def on_ready():
 print("Ready.")

@client.event
async def on_message(message):
 if message.content.startswith(",test"):

 #connect to vc
 vp = await message.author.voice.channel.connect()

 #i tried with chunk._data as well. they are same anyway. 
 chunks_raw = [chunk.raw_data for chunk in chunks]
 #print(chunks_raw == [chunk._data for chunk in chunks]) #it's True
 
 print("Sending?")
 for i, chunk in enumerate(chunks_raw, start=1):
 vp.send_audio_packet(chunk, encode=True) #false --> not heard, true --> weird error (that occurs no matter if i have codec="opus" or not)
 print("Sent", i, "out of", len(chunks), "chunks.")
 await asyncio.sleep(1/20)

 vp.cleanup()
 await vp.disconnect()

 await message.channel.send("Playback is over.")
 
client.run(TOKEN)



so if encode=True i get this (and i have no idea why) :


Ignoring exception in on_message
Traceback (most recent call last):
 File "C:\Users\h\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
 await coro(*args, **kwargs)
 File "C:\Users\h\Desktop\randomly lying pys\bas\broken_audio_showcase.py", line 38, in on_message
 vp.send_audio_packet(chunk, encode=True) #false --> not heard, true --> weird error
 File "C:\Users\h\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 633, in send_audio_packet
 encoded_data = self.encoder.encode(data, self.encoder.SAMPLES_PER_FRAME)
AttributeError: 'NoneType' object has no attribute 'encode'



and if encode=False i can see "Sent i out of len(chunks) chunks" in console, yet i cant hear anything. I also see "Playback is over" message when it ends so it actually sends something...
if i go ahead and change the voice_client.py myself to add this to the first line of
send_audio_packet
function :

self.encoder = opus.Encoder() #manually added


and then i set encode to True, then it actually sends a hearable voice. of course its gibberish again, but at least i hear something from discord voice chat.


can anyone actually help me with this ?


Well I knew sound would be confusing, but never expected it to be this hard. I have no idea what counts as opus if not an opus file itself that's been converted via ffmpeg, not by literally changing the extension or anything.


-
How do i fix library issues while compiling static ffmpeg for android ?
25 mars 2022, par TheRandomGuyNamedJoe12Output from terminal :
`android-build-tools/bin/arm-linux-androideabi-clang is unable to create an executable file.
C compiler test failed.


If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
What the problems are (from the log):
ld : error : unable to find library -lgnustl_static
ld : error : unable to find library -lpng
ld : error : unable to find library -lpthread
clang120 : error : linker command failed with exit code 1 (use -v to see invocation)
C compiler test failed.`
Even tho the library is installed

I have tried to change clang to gcc it didn't fix the problem.


-
Python musical bot
14 juin 2022, par Лагуш ЛюбомирI was working on bot for my discord server for 2 hours but still it doesnt work and not even connecting to voice chat


import discord
from discord.ext import commands
from youtube_dl import YoutubeDL
YDL_OPTIONS = {'format': 'worstaudio/best', 'noplaylist': 'False', 'simulate': 'True',
 'preferredquality': '192', 'preferredcodec': 'mp3', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
client = commands.Bot ( command_prefix='>')
@client.event
async def on_ready():
 print("Meepo connected")
@client.command(pass_context = True )
async def hello( ctx ):
 author = ctx.message.author
 await ctx.send(f"{ author.mention }///Добрий день шановне панство, Я пан Міпарний!")
@client.command()
async def play(ctx, *, arg):
 vc = await ctx.message.author.voice.channel.connect()

 with YoutubeDL(YDL_OPTIONS) as ydl:
 if 'https://' in arg:
 info = ydl.extract_info(arg, download=False)
 else:
 info = ydl.extract_info(f"ytsearch:{arg}", download=False)['entries'][0]

 url = info['formats'][0]['url']

 vc.play(discord.FFmpegPCMAudio(executable="ffmpeg\\bin\\ffmpeg.exe", source=url, **FFMPEG_OPTIONS))
token = open("token.txt", "r").readline()
client.run(token)



in my server console i was getting this message
M


eepo connected
Ignoring exception in command play:
Traceback (most recent call last):
 File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "C:\Users\orest\Desktop\server\bot.py", line 17, in play
 vc = await ctx.message.author.voice.channel.connect()
 File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\abc.py", line 1277, in connect
 voice = cls(client, self)
 File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\voice_client.py", line 199, in __init__
 raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 939, in invoke
 await ctx.command.invoke(ctx)
 File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 863, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 94, in wrapped
 raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice



i cant really understand whats wrong, is there something with my code or i need more Python packages ?