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, channels=2)
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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Create a Voice Recorder using Python
- Create a Screen recorder using Python
- Build a GUI Application to Get Live Stock Price using Python
- Build a GUI Application to get distance between two places using Python
- Build an GUI Application to Get Live Air Quality Information Using Python.
- Build a GUI Application to ping the host using Python
- Voice search Wikipedia using Python
- Python Script to Shutdown your PC using Voice Commands
- Voice Assistant using python
- Text-To-Speech changing voice in Python
- Personal Voice Assistant in Python
- Python | Simple GUI calculator using Tkinter
- Python | Distance-time GUI calculator using Tkinter
- Python - Compound Interest GUI Calculator using Tkinter
- Cryptography GUI using python
- Python | Create a GUI Marksheet using Tkinter
- Python: Weight Conversion GUI using Tkinter
- Python | ToDo GUI Application using Tkinter
- Python | GUI Calendar using Tkinter
- Create a GUI to convert CSV file into excel file using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.