6. Audio Conversion
In this example, we will convert an audio or video file into a FLAC audio-format, which can be then transcribed by the Soniox speech recognition service. This is useful when the original file format (audio or video) is not supported by the Soniox service. It can also help to reduce the network bandwidth between your application and Soniox service.
We recommend using FFmpeg utility, which is a widely used and accepted library for audio and video processing. Follow the instructions on Download page and install the FFmpeg.
To convert an audio / video file to FLAC file, use the following command:
ffmpeg -i INPUT_FILE -c:a flac -ac 1 -ar 16000 -sample_fmt s16 OUTPUT_FILE.flac
The soniox Python library provides utility functions which use FFmpeg to convert audio/video file to FLAC audio format. This requires that FFmpeg is installed and available in the $PATH variable.
from soniox.conversion import convert_to_flac_file # Converts input file to output FLAC file. convert_to_flac_file(input_file, output_file)