How to record microphone to mp3 in Termux on Android?

Viewed 1722

I'm interested to try out Termux command line on Android to record microphone audio to mp3. I've tried running different commands but without much effect. Can anyone pinpoint correct example command to start recording of the microphone, to mp3, at a default location, for example downloads folder? (This is on Android Oreo)

termux-microphone-record

-d Start recording w/ defaults

-f Start recording to specific file

-l Start recording w/ specified limit (in seconds, unlimited for 0)

-e Start recording w/ specified encoder (aac, amr_wb, amr_nb)

-b Start recording w/ specified bitrate (in kbps)

-r Start recording w/ specified sampling rate (in Hz)

-c Start recording w/ specified channel count (1, 2, ...)

-i Get info about current recording

-q Quits recording

from https://wiki.termux.com/wiki/Termux-microphone-record

2 Answers

The Below command will record for 10 sec and save your file.mp3 in your termux Home directory.

termux-microphone-record -d -f filename.mp3 -l 10

Termux does not (yet) appear to support recording directly to mp3 format. To get an mp3, you'll need to convert your recording using ffmpeg.

AWR Wide format has good quality for speech recording.

# Begin recording
termux-microphone-record -e awr_wide -f filename.amr

# Stop recording
termux-microphone-record -q

# Convert to mp3
ffmpeg -i filename.amr filename.mp3
Related