import os import tkinter as tk from tkinter import filedialog import customtkinter as…
- User
import os import tkinter as tk from tkinter import filedialog import customtkinter as ctk from pydub import AudioSegment from pydub.silence import split_on_silence
Set up CustomTkinter appearance
ctk.set_appearance_mode("System") # Matches your system's dark/light mode ctk.set_default_color_theme("blue")
class AlbumSplitterApp(ctk.CTk): def init(self): super().init()
self.title("Album Track Splitter") self.geometry("550x450") self.resizable(False, False) self.file_path = "" # --- UI Elements --- self.title_label = ctk.CTkLabel(self, text="Full Album Track Splitter", font=ctk.CTkFont(size=20, weight="bold")) self.title_label.pack(padx=20, pady=(20, 10)) # File selection frame self.file_frame = ctk.CTkFrame(self) self.file_frame.pack(padx=20, pady=10, fill="x") self.file_label = ctk.CTkLabel(self.file_frame, text="No file selected", text_color="gray") self.file_label.pack(side="left", padx=15, pady=15) self.browse_btn = ctk.CTkButton(self.file_frame, text="Browse Audio", command=self.select_file) self.browse_btn.pack(side="right", padx=15, pady=15) # Action Button self.split_btn = ctk.CTkButton(self, text="Split Album", command=self.process_splitting, fg_color="green", hover_color="darkgreen", state="disabled") self.split_btn.pack(padx=20, pady=15, fill="x") # Status / Log Box self.log_box = ctk.CTkTextbox(self, width=500, height=180) self.log_box.pack(padx=20, pady=(0, 20)) self.log_box.insert("0.0", "Welcome! Select an .mp3 or .wav album file to begin.\n") self.log_box.configure(state="disabled") def log(self, message): """Helper to print messages to the app's text box""" self.log_box.configure(state="normal") self.log_box.insert("end", message + "\n") self.log_box.see("end") self.log_box.configure(state="disabled") def select_file(self): """Opens file explorer to pick an audio file""" filetypes = [("Audio Files", "*.mp3 *.wav")] path = filedialog.askopenfilename(title="Select Album File", filetypes=filetypes) if path: self.file_path = path file_name = os.path.basename(path) self.file_label.configure(text=file_name, text_color=("black", "white")) self.split_btn.configure(state="normal") self.log(f"Selected: {file_name}") def process_splitting(self): """Runs the album splitting logic""" if not self.file_path: return self.split_btn.configure(state="disabled") self.browse_btn.configure(state="disabled") try: output_folder = "album_output" if not os.path.exists(output_folder): os.makedirs(output_folder) self.log("\nLoading audio file...") self.update() file_ext = self.file_path.lower().split('.')[-1] audio = AudioSegment.from_file(self.file_path, format=file_ext) silence_threshold = audio.dBFS - 16 min_silence_len = 1500 self.log(f"Scanning for track gaps...") self.update() chunks = split_on_silence( audio, min_silence_len=min_silence_len, silence_thresh=silence_threshold, keep_silence=400 ) self.log(f"Detected {len(chunks)} tracks. Exporting...") self.update() for i, chunk in enumerate(chunks): track_num = i + 1 output_filename = os.path.join(output_folder, f"Track_{track_num:02d}.{file_ext}") if file_ext == 'mp3': chunk.export(output_filename, format="mp3", bitrate="320k") else: chunk.export(output_filename, format="wav") self.log(f" [Saved] Track {track_num:02d}") self.update() self.log(f"\n[SUCCESS] All tracks saved to '{output_folder}/' folder!") except Exception as e: self.log(f"[ERROR] {str(e)}") finally: self.split_btn.configure(state="normal") self.browse_btn.configure(state="normal") Assistant
I'll create a web-based version of the Album Track Splitter using the Web Audio API. This will allow users to split audio files directly in the browser without needing Python.
Now I have a clear understanding of the project structure. I'll build a web-based Album Track Splitter that uses the Web Audio API and FFmpeg.wasm to process audio files directly in the browser. This will provide equivalent functionality to the Python version.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.