
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (28)
-
Les vidéos
21 avril 2011, parComme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)
Sur d’autres sites (3627)
-
How to setup a virtual mic and pipe audio to it from node.js
28 octobre 2018, par NielllesSummary of what I am trying to achieve :
I’m currently doing some work on a Discord bot. I’m trying to join a voice channel, which is the easy part, and then use the combined audio of the speakers in that voice channel as input for a webpage in a web browser. It doesn’t really matter which browser it is as long as it can be controlled with Selenium.
What I’ve tried/looked into so far
My bot so far is written up in Python using the discord.py API wrapper. Unfortunately listening to, as opposed to putting in, audio hasn’t been exactly implemented great − let alone documented − with discord.py. This made me decide to switch to node.js (i.e. discord.js) for the voice channel stuff of my bot.
After switching to discord.js it was pretty easy to determine who’s talking and create an audio stream (PCM stream) for that user. For the next part I though I’d just pipe the audio stream to a virtual microphone and select that as the audio input on the browser. You can even use FFMPEG from within node.js 1, to get something that looks like this :
const Discord = require("discord.js");
const client = new Discord.Client();
client.on('ready', () => {
voiceChannel = client.channels.get('SOME_CHANNEL_ID');
voiceChannel.join()
.then(conn => {
console.log('Connected')
const receiver = conn.createReceiver();
conn.on('speaking', (user, speaking) => {
if (speaking) {
const audioStream = receiver.createPCMStream(user);
ffmpeg(stream)
.inputFormat('s32le')
.audioFrequency(16000)
.audioChannels(1)
.audioCodec('pcm_s16le')
.format('s16le')
.pipe(someVirtualMic);
}
});
})
.catch(console.log);
});
client.login('SOME_TOKEN');This last part, creating and streaming to a virtual microphone, has proven to be rather complicated. I’ve read a ton of SO posts and documentation on both The Advanced Linux Sound Architecture (ALSA) and the JACK Audio Connection Kit, but I simply can’t figure out how to setup a virtual microphone that will show up as a mic in my browser, or how to pipe audio to it.
Any help or pointers to a solution would be greatly appreciated !
Addendum
For the past couple of days I’ve kept on looking into to this issue. I’ve now learned about ALSA loopback devices and feel that the solution must be there.
I’ve pretty much followed a post that talks about loopback devices and aims to achieve the following :
Simply imagine that you have a physical link between one OUT and one
IN of the same device.I’ve set up the devices as described in the post and now two new audio devices show up when selecting a microphone in Firefox. I’d expect one, but I that may be because I don’t entirely understand the loopback devices (yet).
The loop back devices are created and I think that they’re linked (if I understood the aforementioned article correctly). Assuming that’s the case the only problem I have to tackle is streaming the audio via FFMPEG from within node.js.
-
heroku-22 stack discord.py bot doesn't play music
30 août 2022, par bon hoI'm making music bot with discord.py and using heroku. bot is playing music my localhost but heroku host is not playing music.


I found what cause a bug.
It working nicely in heroku-20, but not working in heroku-22 stack.


How can I use heroku-22 stack without error ?
What can I do ?


I'm sorry my english is bad.


my code :


import youtube_dl
import discord
from discord import app_commands,Interaction
import asyncio
import os

class MyClient(discord.Client):
 async def on_ready(self):
 await self.wait_until_ready()
 await tree.sync()
 print(f"login at {self.user}")
 
intents= discord.Intents.all()
client = MyClient(intents=intents)
tree = app_commands.CommandTree(client)

youtube_dl.utils.bug_reports_message = lambda: ''
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=True):
 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)
queue={}
@tree.command(name="play", description="play music")
async def playmusic(interaction:Interaction,url_title:str,playfirst:bool=False):
 await interaction.response.send_message("I'm looking for music!!")
 guild=str(interaction.guild.id)
 try:
 queue[guild]
 except KeyError:
 queue[guild]=[]
 if interaction.user.voice is None:
 await interaction.edit_original_response(content="you must join any voice channel")
 else:
 voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
 if voice_client == None:
 await interaction.user.voice.channel.connect()
 voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
 player = await YTDLSource.from_url(url_title, loop=None)
 if playfirst and len(queue[guild])>1:
 queue[guild].insert(1,player)
 else:
 queue[guild].append(player)
 if not voice_client.is_playing():
 voice_client.play(player,after=None)
 await interaction.edit_original_response(content=f"{player.title} playing!!")
 else:
 await interaction.edit_original_response(content=f"{player.title} enqueued!")
 await asyncio.sleep(7)
 await interaction.delete_original_response()

client.run(token)



-
heroku discord.py bot doesn't play music
30 août 2022, par bon hoI'm making music bot with discord.py and using heroku. bot is playing music my localhost but heroku host is not playing music.


I found what cause a bug.
It working nicely in heroku-20, but not working in heroku-22 stack.


How can I use heroku-22 stack without error ?
What can I do ?


I'm sorry my english is bad.


my code :


import youtube_dl
import discord
from discord import app_commands,Interaction
import asyncio
import os

class MyClient(discord.Client):
 async def on_ready(self):
 await self.wait_until_ready()
 await tree.sync()
 print(f"login at {self.user}")
 
intents= discord.Intents.all()
client = MyClient(intents=intents)
tree = app_commands.CommandTree(client)

youtube_dl.utils.bug_reports_message = lambda: ''
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=True):
 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)
queue={}
@tree.command(name="play", description="play music")
async def playmusic(interaction:Interaction,url_title:str,playfirst:bool=False):
 await interaction.response.send_message("I'm looking for music!!")
 guild=str(interaction.guild.id)
 try:
 queue[guild]
 except KeyError:
 queue[guild]=[]
 if interaction.user.voice is None:
 await interaction.edit_original_response(content="you must join any voice channel")
 else:
 voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
 if voice_client == None:
 await interaction.user.voice.channel.connect()
 voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
 player = await YTDLSource.from_url(url_title, loop=None)
 if playfirst and len(queue[guild])>1:
 queue[guild].insert(1,player)
 else:
 queue[guild].append(player)
 if not voice_client.is_playing():
 voice_client.play(player,after=None)
 await interaction.edit_original_response(content=f"{player.title} playing!!")
 else:
 await interaction.edit_original_response(content=f"{player.title} enqueued!")
 await asyncio.sleep(7)
 await interaction.delete_original_response()

client.run(token)