
Recherche avancée
Autres articles (32)
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Automated installation script of MediaSPIP
25 avril 2011, parTo overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
The documentation of the use of this installation script is available here.
The code of this (...)
Sur d’autres sites (5185)
-
How do I loop audio files in discord.py ?
25 septembre 2021, par Jonah AlexanderI cannot for the life of me find or figure out a solution that works anymore. here is both the bit of code that is actually important, and the whole file if you would like to see that too


async def play(self, ctx: commands.Context, url, lp):
 channel = ctx.author.voice.channel

 if lp == 'loop':
 await channel.connect()

 async with ctx.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 await ctx.send('Now playing: {}'.format(player.title))
 while True:
 if not ctx.voice_client.is_playing():
 async with ctx.typing():
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 time.sleep(0.5)
 else:
 async with ctx.typing():
 await channel.connect()
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 await ctx.send('Now playing: {}'.format(player.title))



from discord.ext import commands
import ffmpeg
import youtube_dl.YoutubeDL
import asyncio
import time


ytdl_format_options = {
 'format': 'bestaudio/best',
 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
 'restrictfilenames': True,
 'noplaylist': True,
 'nocheckcertificate': True,
 'ignoreerrors': False,
 'logtostderr': False,
 'quiet': True,
 'no_warnings': True,
 'default_search': 'auto',
 'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
}

ffmpeg_options = {
 'options': '-vn'
}


ytdl = youtube_dl.YoutubeDL(ytdl_format_options)


class YTDLSource(discord.PCMVolumeTransformer):
 def __init__(self, source, *, data, volume=0.5):
 super().__init__(source, volume)

 self.data = data

 self.title = data.get('title')
 self.url = data.get('url')

 @classmethod
 async def from_url(cls, url, *, loop=None, stream=False):
 loop = loop or asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

 if 'entries' in data:
 # take first item from a playlist
 data = data['entries'][0]

 filename = data['url'] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)


class MyBoi(commands.Cog):
 def __init__(self, bot: commands.Bot):
 self.bot = bot
 self.voice_states = {}

 @commands.command(name='leave')
 async def leave(self, ctx: commands.Context):
 await ctx.voice_client.disconnect()

 @commands.command(name='play')
 async def play(self, ctx: commands.Context, url, lp):
 channel = ctx.author.voice.channel

 if lp == 'loop':
 await channel.connect()

 async with ctx.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 await ctx.send('Now playing: {}'.format(player.title))
 while True:
 if not ctx.voice_client.is_playing():
 async with ctx.typing():
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 time.sleep(0.5)
 else:
 async with ctx.typing():
 await channel.connect()
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 await ctx.send('Now playing: {}'.format(player.title))


intents = discord.Intents.all()

clnt = commands.Bot(command_prefix='#', intents=intents)
clnt.add_cog(MyBoi(clnt))

lop = {0: False}
plr = {}


@clnt.event
async def on_ready():
 print("ready")


clnt.run("the actual key normally")



is the code poorly made and/or badly organized ? probably. but this is a personal project and did not expect to be sharing this with anyone. If you need clarification on anything lmk.


with the code here, the issue im getting is when I do the looped version, the bot disconnects for a frame and reconnects, then I get this error




discord.ext.commands.errors.CommandInvokeError : Command raised an exception : ClientException : Not connected to voice.




the bot does not disconnect immediately when not using the looped version, and trying to manually reconnect it at the start of the loop gives me an error saying it's already connected.


also sidenote I did not write the YTDLSource class or the ytdl_format_options.


-
discord.py nextcord.py It cant read mp3 audio files
23 février 2023, par hihihi hihihiI'm trying to make my discord bot speak some text, but I can't make it stream the generated mp3 audio file. I'm using Nextcord and FFmpeg.


This is the code I run :


@bot.command(name="bottalk")
async def bottalk(ctx, *args):
 text = " ".join(args)
 user = ctx.message.author
 if user.voice != None:
 try:
 vc = await user.voice.channel.connect()

 except:
 vc = ctx.voice_client 

 sound = gTTS(text=text, lang="en", slow=False) 
 sound.save("please read this.mp3")

 if vc.is_playing():
 vc.stop()

 source = await nextcord.FFmpegOpusAudio.from_probe("please read this.mp3", method="fallback")
 vc.play(source)
 else:
 await ctx.send("join vc") 



When I run the code it generates the mp3 audio file but cannot play the audio file. I get this error :


Ignoring exception in command bottalk:
Traceback (most recent call last):
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\core.py", line 165, in wrapped
 ret = await coro(*args, **kwargs)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "c:\Users\gmmz5\OneDrive\เดสก์ท็อป\python\qweqwewqeqewqe\hi.py", line 4
5, in tts
 source = await nextcord.FFmpegOpusAudio.from_probe("please read this.mp3", method="fallback")
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 496, in from_probe
 return cls(source, bitrate=bitrate, codec=codec, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 426, in __init__
 super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 165, in __init__
 self._process: subprocess.Popen = self._spawn_process(args, **kwargs) 
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 184, in _spawn_process
 raise ClientException(executable + " was not found.") from None
nextcord.errors.ClientException: ffmpeg was not found.

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

Traceback (most recent call last):
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\bot.py", line 1381, in invoke
 await ctx.command.invoke(ctx)
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\core.py", line 948, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\core.py", line 174, in wrapped
 raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: 
ClientException: ffmpeg was not found.
Exception ignored in: <function at="at" 0x0000022c43a47ba0="0x0000022c43a47ba0"> 
Traceback (most recent call last):
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 116, in __del__
 self.cleanup()
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 235, in cleanup
 self._kill_process()
 File "C:\Users\gmmz5\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\player.py", line 191, in _kill_process
 proc = self._process
 ^^^^^^^^^^^^^
AttributeError: 'FFmpegOpusAudio' object has no attribute '_process'
</function>


-
How to grab voice and video in ffmpeg/mplayer/mencoder ? [closed]
4 février 2013, par Kill KillMy target is to grab voice and video via webcamera.
There are three ways to do :1.ffmpeg
ffmpeg -f oss -i /dev/dsp -f video4linux2 -r 25 -b 500000 -s 320x240 -i /dev/video0 out.mpg
WARNING: gnome-keyring:: couldn't connect to: /home/debian/.cache/keyring-4Hzs4r/pkcs11: No such file or directory
ffmpeg version 0.8.5-6:0.8.5-1, Copyright (c) 2000-2012 the Libav developers
built on Jan 13 2013 16:02:15 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[oss @ 0x9d63c60] /dev/dsp: No such file or directory
/dev/dsp: Input/output errorin my computer how to revise it ?
2.mplayer :
mplayer tv:// -tv driver=v4l2:input=0:width=640:height=480:fps=25 -vo x11
I can see the video when the command run, how can I save the output into a file and grab the voice ?
3.mencoder :
mencoder tv:// -tv driver=v4l2:width=800:height=600:device=/dev/video0:fps=30:outfmt=yuy2:forceaudio:alsa:adevice=hw.2,0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1800 -ffourcc xvid -oac mp3lame -lameopts cbr=128 -o output.avi
MEncoder svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer Team
success: format: 9 data: 0x0 - 0x0
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski
comment: first try, more to come
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: PC Camera
Capabilities: video capture read/write streaming
supported norms:
inputs: 0 = zc3xx;
Current input: 0
Current format: unknown (0x4745504a)
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Inappropriate ioctl for device
Error: Cannot set norm!
Selected input hasn't got a tuner!
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
Error opening audio: No such file or directory
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
Error opening audio: No such file or directory
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
Error opening audio: No such file or directory
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
============ Sorry, this file format is not recognized/supported =============
=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===
Cannot open demuxer.
Exiting...