Last active
July 17, 2025 15:30
-
-
Save SharedAcademia/683ce346939ac5e2e8fcb005cdbc71ff to your computer and use it in GitHub Desktop.
.wav to .mp3 (for tts with kokoro script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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