Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAI TTS Support #9

Closed
Madnex opened this issue Nov 7, 2023 · 15 comments
Closed

OpenAI TTS Support #9

Madnex opened this issue Nov 7, 2023 · 15 comments
Labels
enhancement New feature or request

Comments

@Madnex
Copy link

Madnex commented Nov 7, 2023

Hi! Awesome project :)

Any plans to support TTS by OpenAI as well?

@p0n1
Copy link
Owner

p0n1 commented Nov 7, 2023

Yes. I am trying.

@p0n1
Copy link
Owner

p0n1 commented Nov 10, 2023

Hi @Madnex I just released v0.4.0 with OpenAI TTS support. Any feedback would be greatly appreciated.

@Madnex
Copy link
Author

Madnex commented Nov 10, 2023

Oh boy that was fast 😱
Will try it out soon 😎👍

@iconoclasthero
Copy link

Here's my feedback: https://pastebin.com/HKqTZH4k
It errored out on the first try with the very first epub I tried to convert. Do I need to pay for OpenAI? FWIW, the .epub in question is 1,735,742 bytes... I'm not sure what that should translate into characters of text, but somewhere less than a MB I would assume once all the HTML formatting is removed.

@p0n1
Copy link
Owner

p0n1 commented Nov 11, 2023

Here's my feedback: https://pastebin.com/HKqTZH4k

It errored out on the first try with the very first epub I tried to convert. Do I need to pay for OpenAI? FWIW, the .epub in question is 1,735,742 bytes... I'm not sure what that should translate into characters of text, but somewhere less than a MB I would assume once all the HTML formatting is removed.

@iconoclasthero Yes, I think OpenAI doesn't provide a free quota for TTS. You may have to add your credit card or add some credits. You can you the --preview option to get an overview of books. Like '2023-11-10 13:47:19 [INFO] ✨ Total characters in selected chapters: 565900 ✨'.

@smeehee88
Copy link

smeehee88 commented Nov 12, 2023

Hi! love the project. I've been following it for a bit over on reddit.
Is there anyway that an option to specify the openai api base url could be added so we can use something like Localai rather than the official openai api?

@p0n1
Copy link
Owner

p0n1 commented Nov 13, 2023

Hi! love the project. I've been following it for a bit over on reddit. Is there anyway that an option to specify the openai api base url could be added so we can use something like Localai rather than the official openai api?

@smeehee88 Sure. I can add an option for custom OpenAI base url. Haven't try LocalAI or something similar. I'm very interested in the LocalAI results, especially on OpenAI TTS compatibility and performance.

@p0n1 p0n1 added the enhancement New feature or request label Nov 13, 2023
@p0n1
Copy link
Owner

p0n1 commented Nov 13, 2023

@smeehee88 I just found the localai TTS is totally different from OpenAI in their API. https://localai.io/features/text-to-audio/ So just changing the base URL of OpenAI API/SDK will not work.

@YaibaToKen
Copy link

YaibaToKen commented Nov 13, 2023

@smeehee88 I just found the localai TTS is totally different from OpenAI in their API. https://localai.io/features/text-to-audio/ So just changing the base URL of OpenAI API/SDK will not work.

image

This is from their documentation: https://localai.io/basics/getting_started/#python

Assuming I'm understanding this properly, we should already be able to use LocalAI for this just by setting that environment variable, for example, in our docker containers.

@p0n1 p0n1 mentioned this issue Nov 14, 2023
@p0n1
Copy link
Owner

p0n1 commented Nov 14, 2023

We could move discussion on LocalAI support to #17.

@p0n1
Copy link
Owner

p0n1 commented Nov 14, 2023

This is from their documentation: https://localai.io/basics/getting_started/#python

Assuming I'm understanding this properly, we should already be able to use LocalAI for this just by setting that environment variable, for example, in our docker containers.

@YaibaToKen Not yet I think.

@Madnex
Copy link
Author

Madnex commented Nov 15, 2023

Hi @p0n1 here my feedback for the current version:
Running with just docker did not work. Using this command docker run --rm -v ./:/app -e OPENAI_API_KEY=$OPENAI_API_KEY ghcr.io/p0n1/epub_to_audiobook your_book.epub audiobook_output --tts openai

gave me this: python: can't open file '/app/epub_to_audiobook.py': [Errno 2] No such file or directory

Running with python (venv) gave me this error: ModuleNotFoundError: No module named 'importlib_metadata'. After installing the missing library it worked :) Maybe something to add to requirements.txt?

Besides from that it works like a charm 🚀

@p0n1
Copy link
Owner

p0n1 commented Nov 15, 2023

Hi @p0n1 here my feedback for the current version: Running with just docker did not work. Using this command docker run --rm -v ./:/app -e OPENAI_API_KEY=$OPENAI_API_KEY ghcr.io/p0n1/epub_to_audiobook your_book.epub audiobook_output --tts openai

gave me this: python: can't open file '/app/epub_to_audiobook.py': [Errno 2] No such file or directory

Running with python (venv) gave me this error: ModuleNotFoundError: No module named 'importlib_metadata'. After installing the missing library it worked :) Maybe something to add to requirements.txt?

Besides from that it works like a charm 🚀

Thank you @Madnex!

For docker, the epub_to_audiobook.py source code was override by the mounted docker volume. I didn't catch that because I actually mount in the repo so the container can still find the code in my host. I just pushed a fix with v0.4.2 on this issue. You can retry after updating by docker pull ghcr.io/p0n1/epub_to_audiobook:latest.

For python package, did you use python with version bellow 3.8? I did some search and found it might be related. Just documented it here in case anyone ran into similar issue.

Thanks again for your detailed report. Really helped a lot!

@Madnex
Copy link
Author

Madnex commented Nov 21, 2023

Thanks a lot for the fix! Docker is working now as expected 🚀

And for python it was 3.9.6 actually. Might indeed be because of that.

Great work!

@Madnex
Copy link
Author

Madnex commented Nov 21, 2023

Closing as it is implemented 🚀

@Madnex Madnex closed this as completed Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants
@iconoclasthero @YaibaToKen @Madnex @p0n1 @smeehee88 and others