So, I am a beginner in Pyhton and recently I have covered what would be the basics of the language.
And now I have this little project in mind which is basically to create a script that can convert files in a massive way. Specifically convert .ogg files into .mp4 or .mkv files. The intention of this is to convert whatsapp audio files that come in .ogg format to make them more manipulable.
I would like hints suggestions and guidance on how I could do this. Which lib could I use to help me and where can I learn more about this and file conversion using python
Not a python user, but will try to give you some direction.
There is a software called ffmpeg. It can be used as a command line tool to convert any audio/video files to almost any format. If you decide to use it manually then you need to download binaries here, put your .ogg file in the /bin directory next to ffmpeg.exe file and execute (here is the screenshot for better understanding):
./ffmpeg.exe -i input.ogg output.mp4
or:
./ffmpeg.exe -i input.ogg -c copy output.mp4
These are only basic commands, for more examples check this answer.
But I would suggest to simply use a python wrapper of this tool that is already implemented, check this quick start guide with lots of examples in python. For more details this answer can be also helpful.
Related
I am working on a group project. We are looking to develop a program that can receive audio via laptop microphone and compare it to a saved audio file and output a audio message if the input and saved files match. Audios may be speeches, music or songs.
We would like to compare audio files with some sort of python method, but we haven't been able to find any way to do this. We are looking for a library of some sort or another to be able to take data from each file and see if they are similar.
We have watched a lot of tutorials, searched the web and still need some major help. Could someone explain to us how to get started?
Instead of comparing audios, Try converting audio to spectrogram using python of both audio files & Compare both images. You can best results.
But if you want to process only audio files Yes, there some libraries which you can use.
1. Librosa - Python library for audio and music analysis
link for Librosa
Try project dejavu,it really helps.It's based on Numpy.
However, if you just want to filter audio files, Yes, there are some python libraries you can use.
Here is the link for one;
https://pypi.org/project/SpeechRecognition/
or use pip install SpeechRecognition to install
Hope this solves your problem.
I'm looking to make an audio editor using Python for a project in which I'm not allowed to use modules that need be downloaded (I can only do a simple import ).
I want to be able to have users upload a file (preferably in mp3 or some other common format for all operating systems) and be able to play back and edit it. I also need to write out a mp3 file with the new audio.
Would this be feasible in Python 2.7 without outside modules?
EDIT: This will be hosted online if that makes any difference.
Would any of these audio modules help?
audioop is a built-in module to manipulate raw audio data. It requires a format such as .WAV but you could either convert that separately or in the program.
If you want to simply upload wav files to be used with audioop, consider looking at the wave module.
The Python official site offers PDF documentation downloads, but they are separated by chapters. I downloaded the source code and built the PDF documentation, which were separate PDFs also.
How can I build one PDF file from the Makefile in the source code? I think that would be more convenient to read.
If concatenating the separate PDFs won't leaves out the table of contents (bookmarks), it would be acceptable too. I tried convert from Imagemagick, pdftk and pdfunite from poppler-utils, they all lose the bookmarks after concatenation.
If you already have PDFs, there is no need to re-create them. Instead, use something like PDF Split & Merge or PDFArchitect.
--- edit ---
Since the above mentioned solutions work only partially, I googled a bit and found sejda. You can download latest version here.
sejda-console merge -f PDFfile_1.pdf PDFfile_2.pdf -o PDFoutput.pdf
I tried it and it works as expected.
Try sejda-console -h merge for other options (i.e. specify dir with PDFs instead single files, etc.)
-- edit2 --
It seems sejda-console is not freely available anymore, only as commercial sejda-console-pro
But the current free version of PDFsam (v.4.2.12) allows for the same bookmarking options.
Both appear to have the same developer.
apt-get install poppler
pdfunite *.pdf all.pdf
For a website i am developing in django i need users to be able to upload .wav or .aif files. I, of course, have to make sure these files really are what they pretend to be - audiofiles. The files then are provided on the webpage, where i need them to be either .ogg or .mp3
While searching for a solution i stumbled across some fearsome possibilities, like using ctypes to handle external libraries. I also found, of course, PyMedia, which i cannot use because i develop on MacOSX. And the python audio tools provide a lot of functionality i do not need.
So far i can see a few possibilities that would satisfy me and are within reach of my programming capabilities:
1 Get PyMedia to run on MacOSX
2 Find a way to use some modules of the python audio tools without the need to use libcdio
3 use python subprocess to run the command line tools of the converters
As i have used none of those tools yet, i can't tell which would possibly be the quickest way to solve my problem. If you Python-Audio-Gurus are out there, could you please share some thoughts? Or maybe you even have a fantastic 1-step-to-happiness solution?
Not strictly a pythonic answer, but perhaps take a look at sox which is a simple command line audio file converter. It can do resampling of audio files for you as well.
Check out the command line options of sox for details. This will of course involve calling the external program using the subprocess module(or other method).
I'm looking for python code that can convert .wav or other format to FLAC or mpeg. I hope there is one that doesn't depend on other binaries or libraries and just pure python so that it can run independently anywhere where python is installed ie also serverside. Do you know any examples?
Thanks
Python Audio Tools seems to fit your description.
Worst case, you'd have to rip the source code out and go from there.
As others have said, there are other alternatives.