A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/build-a-voice-recorder-gui-using-python/ below:

Build a Voice Recorder GUI using Python

Build a Voice Recorder GUI using Python

Last Updated : 15 Jul, 2025

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

Module Needed
pip install sounddevice
pip install SoundFile

Approach:

Implementation:

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.

Python3
import sounddevice as sd
import soundfile as sf
from tkinter import *


def Voice_rec():
    fs = 48000
    
    # seconds
    duration = 5
    myrecording = sd.rec(int(duration * fs), 
                         samplerate=fs, channels=2)
    sd.wait()
    
    # Save as FLAC file at correct sampling rate
    return sf.write('my_Audio_file.flac', myrecording, fs)


master = Tk()

Label(master, text=" Voice Recoder : "
     ).grid(row=0, sticky=W, rowspan=5)


b = Button(master, text="Start", command=Voice_rec)
b.grid(row=0, column=2, columnspan=2, rowspan=2,
       padx=5, pady=5)

mainloop()

Output:


How to Build a Voice Recorder using Python?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4