
Recherche avancée
Autres articles (63)
-
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
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 (...) -
Submit bugs and patches
13 avril 2011Unfortunately a software is never perfect.
If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
You may also (...)
Sur d’autres sites (7257)
-
Anomalie #2809 : Les variables de personnalisation ne sont pas prises en compte
2 août 2012, par nicolas -Ah mais bon sang, bien sûr, désolé… :-/ Bon, du coup ça marche presque pour ça : $debut_intertitre = ’’ ; $fin_intertitre = ’’ ; Sauf qu’il me génère au lieu de , bizarre… Et ça ne marche toujours pas pour ça : $ouvre_ref = ’’ ; $ferme_ref = ’’ ; $ouvre_note = ’’ ; $ferme_note = (...)
-
Anomalie #3520 : [3.1 22372] Le clic du milieu de la souris referme le détail observé
2 août 2015, par realet RealETEn fait, le comportement sur ces triangles est dérogatoire par rapport à celui habituel : au lieu que ce soit au survol de la souris que ça se déplie, c’est au clic.
Cependant, c’est peut-être mieux pour les tablettes et mobiles.
-
Convert from oga to mp3 using pydub : ffmpeg returned error code : 1
29 juin 2023, par Juan DavidI want to take an OGA file within a binary stream and convert it into mp3 using also another stream. I'm getting a permissions error even with running VSCode as administrator. This is my code :


from pydub import AudioSegment
AudioSegment.converter = "C:\\ProgramData\\chocolatey\\lib\\ffmpeg\\tools\\ffmpeg\\bin\\ffmpeg.exe"

input_stream = io.BytesIO()
input_stream.seek(0) 
await new_file.download_to_memory(input_stream)
 
# Create an audio segment from the binary stream
audio = AudioSegment.from_file(input_stream, format='ogg')

# Create an output stream for the MP3 data
output_stream = io.BytesIO()

# Export the audio to MP3 using ffmpeg and write the output to the stream
audio.export(output_stream, format='mp3', codec='libmp3lame')

# Get the MP3 data from the output stream
mp3_data = output_stream.getvalue()



Error message :


File "C:\ProgramData\Anaconda3\envs\chatbot\lib\site-packages\telegram\ext\_application.py", line 1124, in process_update
 await coroutine
 File "C:\ProgramData\Anaconda3\envs\chatbot\lib\site-packages\telegram\ext\_handler.py", line 141, in handle_update
 return await self.callback(update, context)
 File "c:\Users\jdbol\OneDrive\Desktop\testbots\echobot.py", line 80, in voice_to_text
 audio = AudioSegment.from_file(input_stream, format='ogg')
 File "C:\ProgramData\Anaconda3\envs\chatbot\lib\site-packages\pydub\audio_segment.py", line 773, in from_file 
 raise CouldntDecodeError(
pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1

Output from ffmpeg/avlib:

ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
 built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
 configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
 libavutil 58. 2.100 / 58. 2.100
 libavcodec 60. 3.100 / 60. 3.100
 libavformat 60. 3.100 / 60. 3.100
 libavdevice 60. 1.100 / 60. 1.100
 libavfilter 9. 3.100 / 9. 3.100
 libswscale 7. 1.100 / 7. 1.100
 libswresample 4. 10.100 / 4. 10.100
 libpostproc 57. 1.100 / 57. 1.100
fd:: End of file



I ran the command in a terminal and the file converted without an issue :


ffmpeg -i .\file_12.oga output.mp3 



- 

- I'm not sure if the .exe file must be included into the path. When I don't do it, What I get is a permissions error.
- What other codecs can be used here ?
- Is it possible to use oga files ? I tried to declare this but I got an 'Unknown input format : 'oga' message
(audio = AudioSegment.from_file(input_stream, format='oga')
)








Thanks !


UPDATE : I created a more simple version that is not using a binary stream and worked like a charm, so we know for sure that something is happening with the BytesIO object


async def voice_to_text(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
 # Get the absolute path of the script
 filename = 'file_9.oga'
 script_dir = os.path.dirname(os.path.abspath(__file__))

 # Construct the file paths for input and output files
 input_file_path = os.path.join(script_dir, filename)
 output_file_path = os.path.join(script_dir, os.path.splitext(filename)[0] + ".mp3")

 # Load the OGA audio file
 audio = AudioSegment.from_file(input_file_path, format='ogg')

 # Export the audio to MP3 format
 audio.export(output_file_path, format='mp3')

 print("Conversion complete. MP3 file saved as:", output_file_path)



UPDATE 2 : It seems like
await new_file.download_to_memory(input_stream)
is the problematic line. I tried to save the file and its corrupt. Not sure how to use this method then.

https://docs.python-telegram-bot.org/en/stable/telegram.file.html#telegram.File.download_to_memory