Git Product home page Git Product logo

epub-to-audiobook-hf's Introduction

Epub to Audiobook (M4B)

Epub to MB4 Audiobook, with StyleTTS2 via HuggingFace Spaces API

Notes

  • This uses StyleTTS 2. Running on the Smallest Tesla T4 space, it generates audio at around 10x realtime (10 min audio for one minute of running). See a demo here, to hear the quality.

  • This requires a HuggingFace account, with billing attached. To give an idea of efficiency, I generated a 5 hour audiobook in around 30 min, $0.35 in costs or so (counting start up time, etc)

  • This is very much a version 1.0. I haven't extensively tested the epub parsing, outside of a few that I had. I can't guarantee it'll work with all of them.

  • This is designed to handle failure gracefully, in that if you start generating, and it crashes / errors during the generating process (happens occasionally with the HF API), then it'll skip over already generated chapters, and generate starting with the first one that is missing. This is also nice for breaking up the generation of large books. The m4b file is only generated once all chapters are generated.

Directions

  • Clone this repository locally.

  • Install all dependencies, as needed: pip install -r requirements.txt

  • Sign up on HuggingFace.co, if you have not already. (note: may have to disable adblocker to sign up, otherwise redirect breaks). Add a payment method. Generate a token with write access, using this link: https://huggingface.co/settings/tokens

  • Make a copy on HuggingFace of this space: https://huggingface.co/spaces/Dupaja/styletts2-public/ (3 dots, Duplicate this Space, private copy). Pick the lowest GPU instance, Small Tesla T4. (Note: This demo instance is running on the Free CPU plan, so it is not really usable. If you want to test out the voices first, check out the official demo here: https://huggingface.co/spaces/styletts2/styletts2 .

  • Go to your new space's settings, and set your "Sleep After" time to 15 min, to prevent it from running when not in use. This runs at a cost of $0.60 / hour, billed by the minute, and you can pause at any time from the settings page, using the Pause toggle.

Once the Space builds, do the following:

  • Go to your Space's App page, and find the API link in the footer. This will give you the API URL (with this setup, API url will change each time you restart / pause / sleep the Space. Not sure if there's a way to change this).

  • Add the API url to epub-to-audiobook-hf.py (will need to update each time the Space goes to sleep) and your HuggingFace Token to this file, lines 24 and 26.

  • Put the epub you want to generate from in the same folder as epub-to-audiobook-hf.py

  • Run using `python3 epub-to-audiobook-hf.py .

A Big Thanks To:

epub-to-audiobook-hf's People

Contributors

duplaja avatar

Stargazers

Drew Thomasson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.