Python Tkinter Voice Recorder GUI to Record Audio From Microphone and Save it as .flac File Using SoundFile Library Desktop App Full Project For Beginners
Welcome folks today in this blog post we will be recording audio
from microphone using soundfile library in tkinter using python. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the following library using the pip
command as shown below
pip install soundfile
pip install sounddevice
After installing this library make an app.py
file and copy paste the following code
app.py
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()
Now if you execute the script by typing the command as shown below
python app.py
As you can see that audio file
is saved on the root directory