Reducing the size of audio file created using audio-recorder-streamlit component

Hello, I am using audio-recorder-streamlit component to record audio. It is working however the issue is that the file size is large. For a mere 2 mins 30 secs audio it exceeds 25 MB which creates problem for me while using the Whisper API (as it has 25 MB limit).

I couldn’t find any option in audio-recorder-streamlit to specify the bit rate.
The other option I could think of is to use ffmpeg but I’d have liked to avoid it since it means installing a new application outside of python (packages.txt).

Is there any other better way to solve my problem? Thanks.

Using ffmpeg inside streamlit cloud app was much easier than I thought.
Added ffmpeg to packages.txt, pydub to requirements.txt

After that we only need these 3 lines:

from pydub import AudioSegment
audio = AudioSegment.from_file(input_file)
audio.export(output_file, bitrate='128k', format='mp3')

Problem solved!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.