Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio: Converting between M4A and FLAC, WAV, or raw

I'm working with audio recorded via Quicktime and saved in .m4a format. I'd like to use Google Cloud Provider's Speech API and their recommendations are:

Do:

Use a lossless codec to record and transmit audio. FLAC or LINEAR16 is recommended.

Avoid:

Using mp3, mp4, m4a, mu-law, a-law or other lossy codecs during recording or transmission may reduce accuracy. If your audio is already in an encoding not supported by the API, transcode it to lossless FLAC or LINEAR16. If your application must use a lossy codec to conserve bandwidth, we recommend the AMR_WB, OGG_OPUS or SPEEX_WITH_HEADER_BYTE codecs, in that preferred order.

Source: https://cloud.google.com/speech/docs/best-practices

The API supports FLAC, WAV, or raw and I'm trying to transcode my file into one of these programmatically for use in an application. However, I'm unable to find a good Python library to do this.

UPDATE: Here's the answer: https://www.ffmpeg.org/ (not python, but for sure the most comprehensive tool out there)

like image 901
David Stevens Avatar asked Feb 23 '18 01:02

David Stevens


People also ask

Does converting M4A to FLAC lose quality?

By converting FLAC to M4A(AAC) you will convert the lossless audio to a lossy audio will means quality loss, by converting FLAC M4A(ALAC) you get the same lossless audio file which almost at the same quality.

Does converting M4A to WAV improve quality?

If you are looking for high-quality audio files, M4A will not be the right choice as the format is encoded using the lossy compression. Thus, converting M4A to WAV will help you get high-quality audio files. Moreover, when your M4A audio files are not compatible with your device, the conversion will help.

Which audio format is best FLAC or WAV?

As the compressed file format, FLAC wins this battle hands down. WAV is uncompressed and will take up significantly more space on your device. It will also take longer to transfer to other devices and download. If the speed of transmission matters to you, FLAC is the best file format to use.

Is M4A better or WAV?

As mentioned above, the WAV file is not compressed while the M4A file is usually compressed, which leads to the distinction in audio quality. If you want to enjoy the lossless audio, WAV is the container you need to choose, but if you care more about the file size than the audio quality, M4A is suitable for you.


1 Answers

I am using a python library call pydub: pydub github link They were built upon ffmpeg

like image 132
Daisy QL Avatar answered Oct 15 '22 10:10

Daisy QL