Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP 0.2

Autres articles (77)

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
    sur le web 2.0 et dans les entreprises qui en vivent.
    Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
    Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
    le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
    Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette 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.

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (10117)

  • pydub.exceptions.CouldntDecodeError : Couldn't find fmt header in wav data

    26 mai 2021, par Jaswanth

    I am trying to make an audiofile into chunks and converting into text but, pydub is refusing to read my wav file.
Here is the code

    


    #from speakerDiarization import main,fmtTime
from pydub import AudioSegment
import os
from speech_to_text import wav_to_text

meet_audio = 'UK.wav'
out_file = r'test.txt'
#spkrs = main(meet_audio)

spkrs = {0: [{'start': 0, 'stop': 6000}, {'start': 15000, 'stop': 15500}], 
1: [{'start': 6000, 'stop': 11000}, {'start': 15500, 'stop': 18500}, {'start':27500, 'stop': 34500}], 
2: [{'start': 11000, 'stop': 15000}, {'start': 18500, 'stop': 27500}, {'start': 34500, 'stop': 41000}]}

new_dict = {}
for spkr in spkrs:
    for i in range(len(spkrs[spkr])):
        new_dict[spkrs[spkr][i]['start']] = [spkr,i]
new_dict = sorted(new_dict)

audio = AudioSegment(meet_audio)

for i in new_dict:
    spkr,ind = new_dict[i][0],new_dict[i][1]
    start,end = spkrs[spkr][ind]['start'],spkrs[spkr][ind]['stop']
    chunk = audio[start:end]
    chunk_file = 'Chunks\chunk'+str(spkr)+str(ind)+'.wav'
    chunk.export(chunk_file,format='.wav')
    wav_to_text(chunk_file,out_file,spkr)


    


    output :

    


    (sprk-diaz) H:\Btech-Proj\Speaker_Diarization>split_audio.py&#xA;H:\Btech-Proj\Speaker_Diarization\sprk-diaz\lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn&#x27;t find ffmpeg or avconv - defaulting to ffmpeg, but may not work&#xA;  warn("Couldn&#x27;t find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)&#xA;Traceback (most recent call last):&#xA;  File "H:\Btech-Proj\Speaker_Diarization\split_audio.py", line 20, in <module>&#xA;    audio = AudioSegment(meet_audio)&#xA;  File "H:\Btech-Proj\Speaker_Diarization\sprk-diaz\lib\site-packages\pydub\audio_segment.py", line 222, in __init__&#xA;    wav_data = read_wav_audio(data)&#xA;  File "H:\Btech-Proj\Speaker_Diarization\sprk-diaz\lib\site-packages\pydub\audio_segment.py", line 114, in read_wav_audio&#xA;    raise CouldntDecodeError("Couldn&#x27;t find fmt header in wav data")&#xA;pydub.exceptions.CouldntDecodeError: Couldn&#x27;t find fmt header in wav data&#xA;</module>

    &#xA;

    I don't know what's wrong, can some solve this please.&#xA;Thank you.

    &#xA;

    My audiofile : around 40sec

    &#xA;

  • Why does my discord bot not able to find the file that is there when I open the folder manually ?

    22 juin 2021, par Toma

    I made a discord bot that should play music using ffmpeg.

    &#xA;

    It's connecting and downloading the youtube webm file after which it should convert and rename it to song.mp3 but it doesn't manage to do so. I check the folder and the error message doesn't match what I see - the file is there and has been renamed.

    &#xA;

      &#xA;
    1. Am I using the replace command correctly to move the file ?
    2. &#xA;

    3. I'd note that I'm using windows10 and that the folders are all read only and that although I'm the admin I can't change that no matter what I do (I guess it's a win10 bug). Does that have anything to do with it ?
    4. &#xA;

    5. Is there another mistake in the code that'd prevent the file from being found by the bot ?
    6. &#xA;

    &#xA;

    My code :

    &#xA;

    import discord&#xA;from discord.ext import commands&#xA;import youtube_dl #for url music command&#xA;import os&#xA;&#xA;client = commands.Bot(command_prefix = &#x27;>&lt;&#x27;)&#xA;&#xA;#connect to voice channel&#xA;@client.command(aliases = [&#x27;c&#x27;])&#xA;async def connect(ctx, vcName):&#xA;    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)&#xA;    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))&#xA;    if voice == None: #if voice is not connected to any channel&#xA;        await voiceChannel.connect()&#xA;    else:&#xA;        if voice.channel == vcName: #if trying to connect to the same channel&#xA;            await ctx.send(&#x27;already connected to this channel&#x27;)&#xA;        else:&#xA;            await voice.move_to(vcName)&#xA;&#xA;@client.command(aliases = [&#x27;d&#x27;])&#xA;async def delFile(ctx):&#xA;    song_there = os.path.exists(os.getcwd()&#x2B;&#x27;/music/current/song.mp3&#x27;) #true when song.mp3 exists in &#x27;current&#x27; folder in &#x27;music&#x27; folder&#xA;    if song_there:&#xA;        await ctx.send(&#x27;song was detected&#x27;)&#xA;        os.remove(&#x27;song.mp3&#x27;)&#xA;        if song_there:&#xA;            await ctx.send(&#x27;song was not deleted&#x27;)&#xA;    else:&#xA;        await ctx.send(&#x27;File is not found. check the name again&#x27;)&#xA;&#xA;#play music from url&#xA;&#xA;@client.command(aliases = [&#x27;p&#x27;])&#xA;async def playMusic(ctx, vcName, url : str): #play music file&#xA;    song_there = os.path.exists(os.path.join(os.getcwd(),&#x27;/music/current/song.mp3&#x27;))&#xA;    try:&#xA;        if song_there:&#xA;            print(&#x27;previous song found&#x27;)&#xA;            os.remove(os.path.join(os.getcwd(),&#x27;/music/current/song.mp3&#x27;)) #removes the song in current to make room for a new song&#xA;            if song_there:&#xA;                print(&#x27;song was not deleted&#x27;)&#xA;            else:&#xA;                print(&#x27;song deleted&#x27;)&#xA;    except PermissionError:&#xA;        await ctx.send(&#x27;A song is currently playing&#x27;)&#xA;        return&#xA;    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))&#xA;    ydl_opts = {&#xA;        &#x27;format&#x27;: &#x27;bestaudio/best&#x27;,&#xA;        &#x27;postprocessors&#x27;: [{&#xA;            &#x27;key&#x27;: &#x27;FFmpegExtractAudio&#x27;,&#xA;            &#x27;preferredcodec&#x27;: &#x27;mp3&#x27;,&#xA;            &#x27;preferredquality&#x27;: &#x27;192&#x27;,&#xA;        }]&#xA;    }&#xA;&#xA;&#xA;   for file in os.listdir(&#x27;./&#x27;):&#xA;        if file.endswith(&#x27;.mp3&#x27;):       #if song.mp3 already exists delete it to make room for a new download&#xA;            os.remove(&#x27;song.mp3&#x27;)&#xA;        else:                           #download the file from youtube&#xA;            with youtube_dl.YoutubeDL(ydl_opts) as ydl:&#xA;                ydl.download([url])&#xA;    for file in os.listdir(&#x27;./&#x27;):       #after downloading rename the file and move it to current folder&#xA;        if not file == (&#x27;song.mp3&#x27;) and file.endswith(&#x27;.mp3&#x27;):&#xA;            os.rename(file, &#x27;song.mp3&#x27;)&#xA;            print(os.path.join(os.getcwd(), &#x27;song.mp3&#x27;))&#xA;            print(os.path.join(os.getcwd(), &#x27;/music/current/song.mp3&#x27;))&#xA;            os.replace(os.path.join(os.getcwd(), &#x27;song.mp3&#x27;), os.path.join(os.getcwd(), &#x27;/music/current/song.mp3&#x27;))   #move file to current&#xA;&#xA;    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)&#xA;    if not voice is None:               #if voice is already created&#xA;        if not voice.is_connected():    #and is not connected&#xA;            await voiceChannel.connect()&#xA;        voice.play(discord.FFmpegPCMAudio(&#x27;song.mp3&#x27;))&#xA;    else:&#xA;        await ctx.send(&#x27;Bot made an oopsy. Cast mending and heal bot.&#x27;)&#xA;client.run(&#x27;token&#x27;)&#xA;

    &#xA;

    Error :

    &#xA;

    [youtube] wkJ7oDMqz0A: Downloading webpage&#xA;[download] The Minor Bee-wkJ7oDMqz0A.webm has already been downloaded&#xA;[download] 100% of 5.13MiB&#xA;[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3&#xA;Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)&#xA;[youtube] wkJ7oDMqz0A: Downloading webpage&#xA;[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm&#xA;[download] 100% of 5.13MiB in 00:00                   &#xA;[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3&#xA;Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)&#xA;[youtube] wkJ7oDMqz0A: Downloading webpage&#xA;[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm&#xA;[download] 100% of 5.13MiB in 00:00                  &#xA;[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3&#xA;Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)&#xA;C:.....song.mp3 -> **C:/music/current/song.mp3**&#xA;Ignoring exception in command playMusic:&#xA;Traceback (most recent call last):&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped&#xA;    ret = await coro(*args, **kwargs)&#xA;  File "C:...tut-bot.py", line 84, in playMusic&#xA;    os.replace(os.path.join(os.getcwd(), &#x27;song.mp3&#x27;), os.path.join(os.getcwd(), &#x27;/music/current/song.mp3&#x27;))   #move file to current&#xA;FileNotFoundError: [WinError 3] The system cannot find the path specified: &#x27;C:\....\\song.mp3&#x27; -> &#x27;C:/music/current/song.mp3&#x27;&#xA;&#xA;The above exception was the direct cause of the following exception:&#xA;&#xA;Traceback (most recent call last):&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke&#xA;    await ctx.command.invoke(ctx)&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke&#xA;    await injected(*ctx.args, **ctx.kwargs)&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped&#xA;    raise CommandInvokeError(exc) from exc&#xA;discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: &#x27;C:\\...\\song.mp3&#x27; -> &#x27;C:/music/current/song.mp3&#x27;&#xA;

    &#xA;

  • Why is my discord bot not able to find the file that is there when I open the folder manually ?

    22 juin 2021, par Toma

    I made a discord bot that should play music using ffmpeg.

    &#xA;

    It's connecting and downloading the youtube webm file after which it should convert and rename it to song.mp3 but it doesn't manage to do so. I check the folder and the error message doesn't match what I see - the file is there and has been renamed.

    &#xA;

      &#xA;
    1. Am I using the replace command correctly to move the file ?
    2. &#xA;

    3. I'd note that I'm using windows10 and that the folders are all read only and that although I'm the admin I can't change that no matter what I do (I guess it's a win10 bug). Does that have anything to do with it ?
    4. &#xA;

    5. Is there another mistake in the code that'd prevent the file from being found by the bot ?
    6. &#xA;

    &#xA;

    My code :

    &#xA;

    import discord&#xA;from discord.ext import commands&#xA;import youtube_dl #for url music command&#xA;import os&#xA;&#xA;client = commands.Bot(command_prefix = &#x27;>&lt;&#x27;)&#xA;&#xA;#connect to voice channel&#xA;@client.command(aliases = [&#x27;c&#x27;])&#xA;async def connect(ctx, vcName):&#xA;    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)&#xA;    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))&#xA;    if voice == None: #if voice is not connected to any channel&#xA;        await voiceChannel.connect()&#xA;    else:&#xA;        if voice.channel == vcName: #if trying to connect to the same channel&#xA;            await ctx.send(&#x27;already connected to this channel&#x27;)&#xA;        else:&#xA;            await voice.move_to(vcName)&#xA;&#xA;@client.command(aliases = [&#x27;d&#x27;])&#xA;async def delFile(ctx):&#xA;    song_there = os.path.exists(os.getcwd()&#x2B;&#x27;/music/current/song.mp3&#x27;) #true when song.mp3 exists in &#x27;current&#x27; folder in &#x27;music&#x27; folder&#xA;    if song_there:&#xA;        await ctx.send(&#x27;song was detected&#x27;)&#xA;        os.remove(&#x27;song.mp3&#x27;)&#xA;        if song_there:&#xA;            await ctx.send(&#x27;song was not deleted&#x27;)&#xA;    else:&#xA;        await ctx.send(&#x27;File is not found. check the name again&#x27;)&#xA;&#xA;#play music from url&#xA;&#xA;@client.command(aliases = [&#x27;p&#x27;])&#xA;async def playMusic(ctx, vcName, url : str): #play music file&#xA;    song_there = os.path.exists(os.path.join(os.getcwd(),&#x27;/music/current/song.mp3&#x27;))&#xA;    try:&#xA;        if song_there:&#xA;            print(&#x27;previous song found&#x27;)&#xA;            os.remove(os.path.join(os.getcwd(),&#x27;/music/current/song.mp3&#x27;)) #removes the song in current to make room for a new song&#xA;            if song_there:&#xA;                print(&#x27;song was not deleted&#x27;)&#xA;            else:&#xA;                print(&#x27;song deleted&#x27;)&#xA;    except PermissionError:&#xA;        await ctx.send(&#x27;A song is currently playing&#x27;)&#xA;        return&#xA;    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))&#xA;    ydl_opts = {&#xA;        &#x27;format&#x27;: &#x27;bestaudio/best&#x27;,&#xA;        &#x27;postprocessors&#x27;: [{&#xA;            &#x27;key&#x27;: &#x27;FFmpegExtractAudio&#x27;,&#xA;            &#x27;preferredcodec&#x27;: &#x27;mp3&#x27;,&#xA;            &#x27;preferredquality&#x27;: &#x27;192&#x27;,&#xA;        }]&#xA;    }&#xA;&#xA;&#xA;   for file in os.listdir(&#x27;./&#x27;):&#xA;        if file.endswith(&#x27;.mp3&#x27;):       #if song.mp3 already exists delete it to make room for a new download&#xA;            os.remove(&#x27;song.mp3&#x27;)&#xA;        else:                           #download the file from youtube&#xA;            with youtube_dl.YoutubeDL(ydl_opts) as ydl:&#xA;                ydl.download([url])&#xA;    for file in os.listdir(&#x27;./&#x27;):       #after downloading rename the file and move it to current folder&#xA;        if not file == (&#x27;song.mp3&#x27;) and file.endswith(&#x27;.mp3&#x27;):&#xA;            os.rename(file, &#x27;song.mp3&#x27;)&#xA;            print(os.path.join(os.getcwd(), &#x27;song.mp3&#x27;))&#xA;            print(os.path.join(os.getcwd(), &#x27;/music/current/song.mp3&#x27;))&#xA;            os.replace(os.path.join(os.getcwd(), &#x27;song.mp3&#x27;), os.path.join(os.getcwd(), &#x27;/music/current/song.mp3&#x27;))   #move file to current&#xA;&#xA;    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)&#xA;    if not voice is None:               #if voice is already created&#xA;        if not voice.is_connected():    #and is not connected&#xA;            await voiceChannel.connect()&#xA;        voice.play(discord.FFmpegPCMAudio(&#x27;song.mp3&#x27;))&#xA;    else:&#xA;        await ctx.send(&#x27;Bot made an oopsy. Cast mending and heal bot.&#x27;)&#xA;client.run(&#x27;token&#x27;)&#xA;

    &#xA;

    Error :

    &#xA;

    [youtube] wkJ7oDMqz0A: Downloading webpage&#xA;[download] The Minor Bee-wkJ7oDMqz0A.webm has already been downloaded&#xA;[download] 100% of 5.13MiB&#xA;[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3&#xA;Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)&#xA;[youtube] wkJ7oDMqz0A: Downloading webpage&#xA;[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm&#xA;[download] 100% of 5.13MiB in 00:00                   &#xA;[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3&#xA;Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)&#xA;[youtube] wkJ7oDMqz0A: Downloading webpage&#xA;[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm&#xA;[download] 100% of 5.13MiB in 00:00                  &#xA;[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3&#xA;Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)&#xA;C:.....song.mp3 -> **C:/music/current/song.mp3**&#xA;Ignoring exception in command playMusic:&#xA;Traceback (most recent call last):&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped&#xA;    ret = await coro(*args, **kwargs)&#xA;  File "C:...tut-bot.py", line 84, in playMusic&#xA;    os.replace(os.path.join(os.getcwd(), &#x27;song.mp3&#x27;), os.path.join(os.getcwd(), &#x27;/music/current/song.mp3&#x27;))   #move file to current&#xA;FileNotFoundError: [WinError 3] The system cannot find the path specified: &#x27;C:\....\\song.mp3&#x27; -> &#x27;C:/music/current/song.mp3&#x27;&#xA;&#xA;The above exception was the direct cause of the following exception:&#xA;&#xA;Traceback (most recent call last):&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke&#xA;    await ctx.command.invoke(ctx)&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke&#xA;    await injected(*ctx.args, **ctx.kwargs)&#xA;  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped&#xA;    raise CommandInvokeError(exc) from exc&#xA;discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: &#x27;C:\\...\\song.mp3&#x27; -> &#x27;C:/music/current/song.mp3&#x27;&#xA;

    &#xA;