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

Read operation timed out/Nothing to bind? #5

Open
Paul10142 opened this issue Feb 26, 2024 · 3 comments
Open

Read operation timed out/Nothing to bind? #5

Paul10142 opened this issue Feb 26, 2024 · 3 comments

Comments

@Paul10142
Copy link

Wanted to start out by thanking you for creating such an awesome tool. I have absolutely no coding background (just downloaded Python today) but have been trying to teach myself things for the last few hours in order to try to make this product to work.

I installed the dependencies (although needed to adjust code to "pip3 install -r requirements.txt" to work. I have successfully made a copy of the StyleTTS2 space and added billing info to Hugging Face, and updated the "epub-to-audiobook-hf.py" script with the API key and token. I did not opt to add a Repo ID. The epub file I'm testing out, "lying.epub", was added to the same folder as the python script.

I'm on Mac, and I used the cd + file pathway for the "epub-to-audiobook-hf" folder before proceeding. I had a lot of errors running the code python3 epub-to-audiobook-hf.py ., namely No such file or directory: './META-INF/container.xml'. However, I eventually realized that if I replaced the . with the name of the file, I could get the program to start running . In the example used, that would be python3 epub-to-audiobook-hf.py lying.epub

However, at this point I now get a httpx.ReadTimeout: The read operation timed out error (copied below). It sounds like this is due to an error processing data from the StyleTTS 2 website, but am able to figure out beyond that. Occasionally get a folder for the audio file to generate in <1 sec, but receive a different error:

Converting Chapters using StyleTTS 2, via HF Spaces Loaded as API: https://paul202-styletts2-public.hf.space/ ✔ Chapters done generating, now converting to m4b. Collecting file data... File scan complete. Error: Nothing to bind.

With the above error, the code will spit out the name and author of the book which makes me feel that it is at least able to read some of the .epub file. I have confirmed that my API and token are properly added in the python script without errors. Please let me know how I could go about fixing this, and I apologize in advance since I assume this is a very basic question. (PS. working on this has motivated me to start learning the basics of coding and python!).

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ebooklib/epub.py:1395: UserWarning: In the future version we will turn default option ignore_ncx to True.
  warnings.warn('In the future version we will turn default option ignore_ncx to True.')
Epub Title: Lying
Epub Author: Sam Harris
Converting Chapters using StyleTTS 2, via HF Spaces
Loaded as API: https://paul202-styletts2-public.hf.space/ ✔
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
    yield
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_transports/default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 101, in handle_request
    return self._connection.handle_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py", line 143, in handle_request
    raise exc
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py", line 113, in handle_request
    ) = self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py", line 186, in _receive_response_headers
    event = self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py", line 224, in _receive_event
    data = self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 124, in read
    with map_exceptions(exc_map):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ReadTimeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 304, in <module>
    main()
  File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 301, in main
    generate_audiobook(epub_filename, voice_type, keep_awake)
  File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 244, in generate_audiobook
    client = Client(spaces_api_url,hf_token=hf_token)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py", line 145, in __init__
    self.config = self._get_config()
                  ^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py", line 740, in _get_config
    r = httpx.get(
        ^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_api.py", line 198, in get
    return request(
           ^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_api.py", line 106, in request
    return client.request(
           ^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 827, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_transports/default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out
@Paul10142
Copy link
Author

Also - tried this around with other epub files, most of the time got the same bind error however recently got a ValueError: 'You must enter some text' as well.

Full code:
paulclancy@Pauls-MacBook-Pro epub-to-audiobook-hf % python3 epub-to-audiobook-hf.py leadership_strat.epub --voice m-us-2 /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ebooklib/epub.py:1395: UserWarning: In the future version we will turn default option ignore_ncx to True. warnings.warn('In the future version we will turn default option ignore_ncx to True.') Epub Title: Leadership_Strategy_and_Tactics Epub Author: Jocko Willink Converting Chapters using StyleTTS 2, via HF Spaces Loaded as API: https://paul202-styletts2-public.hf.space/ ✔ Traceback (most recent call last): File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 304, in <module> main() File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 301, in main generate_audiobook(epub_filename, voice_type, keep_awake) File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 264, in generate_audiobook convert_chapter(client,chapter_path,chapter_paragraphs, voice_type) File "/Users/paulclancy/Desktop/Audiobooks/epub-to-audiobook-hf/epub-to-audiobook-hf.py", line 97, in convert_chapter result = client.predict( ^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py", line 404, in predict return self.submit(*args, api_name=api_name, fn_index=fn_index).result() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py", line 1612, in result return super().result(timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 456, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py", line 994, in _inner predictions = _predict(*data) ^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py", line 1036, in _predict raise ValueError(result["error"]) ValueError: 'You must enter some text' paulclancy@Pauls-MacBook-Pro epub-to-audiobook-hf %

@duplaja
Copy link
Owner

duplaja commented Feb 26, 2024

Hey @Paul10142 , thank you for reaching out! The code that actually parses the epub can be a bit fragile. Can you try the following for me:

  1. Install Calibre, if you don't have it already ( https://calibre-ebook.com/ )

  2. Open up the file, and use the Convert option, to convert it to epub again.

  3. Try running the epub through the script here.

Epub files often are poorly written / don't follow the proper format, so normalizing them through Calibre can sometimes help fix those issues.

If that doesn't do it, then if you're able, I might have you send me a copy of one of the epubs that didn't work, so I can do some troubleshooting on my side.

Thank you,
Dan

@Paul10142
Copy link
Author

Hey @duplaja thanks so much for the quick response! I had originally used a calibre epub file, however I just went and reconverted it to a different file. When running through the script using python3 epub-to-audiobook-hf.py Lying.epub, I received the same error (httpx.ReadTimeout: The read operation timed out). I also tried this with a different, large epub file and received a different error, noted below. In both cases, a separate folder for each book was created in my "epub-to-audiobook-hf" folder, albeit with 0 bytes and no document inside.

Please let me know if I am using your code properly (using the cd command to search within the epub-to-audiobook-hf folder + replacing the . with the audiobook file name) along with any other troubleshooting on my end. I would be happy to send you the file as well if that would help.

Converting Chapters using StyleTTS 2, via HF Spaces Loaded as API: https://paul202-styletts2-public.hf.space/ ✔ Chapters done generating, now converting to m4b. Collecting file data... File scan complete. Error: Nothing to bind. Book 'Undaunted Courage' by Stephen E. Ambrose has been created. Book Generated in: 0.5931520462036133 seconds paulclancy@Pauls-MacBook-Pro epub-to-audiobook-hf %

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants