Skip to content

Instantly share code, notes, and snippets.

@burak-yildizoz
Last active June 22, 2025 04:21
Show Gist options
  • Save burak-yildizoz/ba1dc044d703cc36909372d9e5728ed1 to your computer and use it in GitHub Desktop.
Save burak-yildizoz/ba1dc044d703cc36909372d9e5728ed1 to your computer and use it in GitHub Desktop.
Python script to convert Audacity (.aup3) files to MP3 format
import glob
import os
import pyaudacity as pa
import time
import tkinter.messagebox
files = glob.glob("*.aup3")
for file in files:
if not file.isascii():
if not tkinter.messagebox.askokcancel("File Warning", f"File contains non-ASCII character: {file}\nThis may lead to problems. Proceed?"):
exit()
index = 0
while index < len(files):
file = files[index]
time.sleep(2)
print(f"Processing {file}")
try:
pa.open(file)
pa.export_mp3()
pa.close()
except FileNotFoundError as e:
if tkinter.messagebox.askokcancel("File Error", e):
continue
else:
break
except pa.PyAudacityException as e:
if tkinter.messagebox.askokcancel("Audacity Error", e):
continue
else:
break
index += 1
output_folder = os.path.expanduser("~/Documents/Audacity/macro-output")
os.startfile(output_folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment