Build a Voice Recorder GUI using Python
Prerequisites: Python GUI – tkinter, Create a Voice Recorder using Python
Python provides various tools and can be used for various purposes. One such purpose is recording voice. It can be done using the sounddevice module. This recorded file can be saved using the soundfile module
- Sounddevice: The sounddevice module provides bindings for the PortAudio library and a few convenience functions to play and record NumPy arrays containing audio signals. To install this type the below command in the terminal.
pip install sounddevice
- SoundFile: SoundFile can read and write sound files. To install this type the below command in the terminal.
pip install SoundFile
- Import the required module.
- Set frequency and duration.
- Record voice data in NumPy array, you can use rec().
- Store into the file using soundfile.write().
Step 1: Import modules
import sounddevice as sd
import soundfile as sf
Step 2: Set frequency and duration and record voice data in NumPy array, you can use rec()
fs = 48000
duration = 5
myrecording = sd.rec(int(duration * fs), samplerate=fs,
Note: fs is the sample rate of the recording (usually 44100 or 44800 Hz)
Step 3: Now store these array into audio files.
# Save as FLAC file at correct sampling rate
sf.write('My_Audio_file.flac', myrecording, fs)
Let’s create a GUI application for the same. We’ll be using Tkinter for doing the same.
sounddevice as sd
soundfile as sf
, myrecording, fs)
" Voice Recoder : "
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!