Skip to content

Instantly share code, notes, and snippets.

@SharedAcademia
Last active July 17, 2025 15:30
Show Gist options
  • Select an option

  • Save SharedAcademia/683ce346939ac5e2e8fcb005cdbc71ff to your computer and use it in GitHub Desktop.

Select an option

Save SharedAcademia/683ce346939ac5e2e8fcb005cdbc71ff to your computer and use it in GitHub Desktop.
.wav to .mp3 (for tts with kokoro script)
#make sure you have installed in terminal: pip install pydub
#and: brew install ffmpeg
from pydub import AudioSegment
# CONFIGURATION
INPUT_WAV = "audio.wav"
OUTPUT_MP3 = "output_name.mp3"
BITRATE = "192k" # you can set e.g. '128k', '192k', '256k'
print(f"Loading WAV: {INPUT_WAV}")
audio = AudioSegment.from_wav(INPUT_WAV)
print(f"Exporting as MP3: {OUTPUT_MP3} (bitrate {BITRATE})")
audio.export(OUTPUT_MP3, format="mp3", bitrate=BITRATE)
print("✅ Conversion complete! Code by SharedAcademia.org")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment