## 🔥 Feature: External API for Audiobook Generation #19
## 🔥 Feature: External API for Audiobook Generation #19Blaizzy merged 14 commits intoBlaizzy:mainfrom
Conversation
…g. for audiobook projects
|
Thanks for the great contribution @sergenes! I left one comment. |
|
Made some small changes. Could you please run before we merge:
|
Done! |
|
Let me know if you'd like me to rebase the branch! |
|
Yes, that would be great. Please do rebase :) |
I was busy with the kids over the weekend. I'll try to find some time at the beginning of next week! |
|
No worries, ping me when you do :) |
Done! I tested both options a bit. Please merge to avoid needing to rebase again! :) |
|
Hmm, it looks like merging is blocked because you pushed to this branch once. What should we do? |
|
I can make a new Pull Request.. |
|
New PR: #42 |
|
@sergenes no need for a new PR, I made the necessary changes and it's ready to be merged :) |
|
thank you! |
Summary
This PR introduces
generate_audio(), a new function to allow external scripts to generate speech audio usingmlx_audiofor audiobook projects.Changes
✅ Exposes
generate_audio()for direct function calls outside the library.✅ Supports multiple audio formats (
wav,flac, etc.).✅ Allows external scripts to generate audiobook chapters with custom voices, speed, and language codes.
✅ Includes a
verboseflag to control logging output.--
✅ Added from_cli flag: a simple way to handle CLI vs. script execution differences. This ensures that CLI-generated files get the _000 suffix as expected, while script-based calls save files without a suffix (e.g., audiobook_chapter1.wav).
Usage Example
External projects can now generate audiobooks like this:
Why This PR?
This change makes it easier to integrate mlx_audio into audiobook generation projects, showcasing its potential for text-to-speech applications.
I'm going to use it for my experiments here:
https://github.com/sergenes/runandread-audiobook
But I'm pretty sure it will be useful to others as well!
🔥🔥🔥 I love this repo! Thank you for your work! 🚀👏