π Create a Modern Python GUI Voice Recorder App – Record & Save Audio Easily!
Demo :
Click Video πππ
π Description:
π Learn how to build a stylish and modern Python GUI Voice Recorder App using Tkinter and SoundDevice! π€ Save your voice like a pro and create an interactive audio recording application. Perfect for beginners and advanced coders!
πΉ Features of this App:
✅ Modern & Attractive GUI π¨
✅ Record high-quality audio π€
✅ Save recordings in .wav
format π
✅ Python & Tkinter-based GUI
Code :
π§ Install Required Libraries : cmd => pip install sounddevice scipy customtkinter
import sounddevice as sdfrom scipy.io.wavfile import writeimport numpy as npimport customtkinter as ctkfrom tkinter import messageboximport threadingimport time# App Settingsctk.set_appearance_mode("dark")ctk.set_default_color_theme("blue")class VoiceRecorderApp(ctk.CTk):def __init__(self):super().__init__()self.title("π€ Modern Voice Recorder")self.geometry("400x500")self.resizable(False, False)self.recording = Falseself.frames = []self.sample_rate = 44100# UI Componentsself.label_title = ctk.CTkLabel(self, text="π Voice Recorder", font=("Arial", 24, "bold"))self.label_title.pack(pady=20)self.progress_label = ctk.CTkLabel(self, text="Press Start to Record", font=("Arial", 16))self.progress_label.pack(pady=10)self.start_button = ctk.CTkButton(self, text="▶ Start Recording", command=self.start_recording, fg_color="green")self.start_button.pack(pady=10)self.stop_button = ctk.CTkButton(self, text="⏹ Stop Recording", command=self.stop_recording, fg_color="red", state="disabled")self.stop_button.pack(pady=10)self.exit_button = ctk.CTkButton(self, text="❌ Exit", command=self.quit)self.exit_button.pack(pady=20)def record_audio(self):self.recording = Trueself.frames = []self.progress_label.configure(text="Recording... π€")with sd.InputStream(samplerate=self.sample_rate, channels=2, dtype="int16") as stream:while self.recording:frame, _ = stream.read(1024)self.frames.append(frame)def start_recording(self):self.start_button.configure(state="disabled")self.stop_button.configure(state="normal")threading.Thread(target=self.record_audio, daemon=True).start()def stop_recording(self):self.recording = Falseself.start_button.configure(state="normal")self.stop_button.configure(state="disabled")self.progress_label.configure(text="Recording Saved! πΆ")# Save filefilename = "recorded_audio.wav"audio_data = np.concatenate(self.frames, axis=0)write(filename, self.sample_rate, audio_data)messagebox.showinfo("Recording Complete", f"Audio saved as {filename}")# Run Appif __name__ == "__main__":app = VoiceRecorderApp()app.mainloop()
Comments
Post a Comment