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

Piper TTS FileNotFoundError #83

Open
Gandalf-the-Blue opened this issue Aug 28, 2024 · 6 comments
Open

Piper TTS FileNotFoundError #83

Gandalf-the-Blue opened this issue Aug 28, 2024 · 6 comments

Comments

@Gandalf-the-Blue
Copy link

Hi, I'm trying the following command for local piper-tts audio. I downloaded the
piper_linux_x86_64.tar.gz from https://github.com/rhasspy/piper/releases/tag/2023.11.14-2 and extracted and dumped the contents into the same folder as the epub_to_audiobook folder and downloaded the voice model I wanted = en_GB-cori-high.onnx

python3 main.py ./book/book.epub ./book/audio/ --tts piper --model_name ./en_GB-cori-high.onnx

I'm getting the following error, and for some reason after I confirm the cost ($0.00 Yay!) I run into the following issue. Can you help me out here?

Traceback (most recent call last):
  File "/home/uname/Valinor/TV/epubaudio/epub_to_audiobook/main.py", line 147, in <module>
    main()
  File "/home/uname/Valinor/TV/epubaudio/epub_to_audiobook/main.py", line 143, in main
    AudiobookGenerator(config).run()
  File "/home/uname/Valinor/TV/epubaudio/epub_to_audiobook/audiobook_generator/core/audiobook_generator.py", line 101, in run
    tts_provider.text_to_speech(
  File "/home/uname/Valinor/TV/epubaudio/epub_to_audiobook/audiobook_generator/tts_providers/piper_tts_provider.py", line 60, in text_to_speech
    run(
  File "/usr/lib64/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'piper'
@p0n1
Copy link
Owner

p0n1 commented Aug 29, 2024

Hi. Did you only 'dumped the contents into the same folder as the epub_to_audiobook folder' but not added it into path?

The current code needs to execute piper-tts directly.

@Gandalf-the-Blue
Copy link
Author

Gandalf-the-Blue commented Aug 29, 2024

It's in the same folder but called piper - made sure it was executable. Also tried changing the code to piper and rerunning, resulting in the error

@p0n1
Copy link
Owner

p0n1 commented Sep 5, 2024

Hi @Gandalf-the-Blue. I just changed the piper related code in #84. Maybe you can try again.

I updated piper related parameters, you can check this https://github.com/p0n1/epub_to_audiobook?tab=readme-ov-file#examples-using-piper-tts for latest examples.

Besides, you can specify your custom path to the piper executable by using the --piper_path parameter, like:

python3 main.py "path/to/book.epub" "path/to/output/folder" --tts piper --model_name <path_to>/en_US-libritts_r-medium.onnx --piper_path <path_to>/piper

@Gandalf-the-Blue
Copy link
Author

Hey so I tried this again, doing the whole thing again and now I get this errror -

(venv) user@manwe:~/Valinor/TV/epub_to_audiobook$ python3 main.py Adrift.epub ./Adrift --tts piper --model_name ~/Downloads/piper/en_GB-cori-high.onnx --piper_path ~/Downloads/piper/piper --output_format mp3
/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version.  If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]'
  for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}):
2024-09-05 11:10:13,060 - audiobook_generator.py:44 - run - INFO - Chapters count: 134.
2024-09-05 11:10:13,060 - audiobook_generator.py:62 - run - INFO - Converting chapters from 1 to 134.
2024-09-05 11:10:13,060 - audiobook_generator.py:66 - run - INFO - ✨ Total characters in selected book chapters: 277087 ✨
Estimate book voiceover would cost you roughly: $0.00

Do you want to continue? (y/n)
y
2024-09-05 11:10:14,694 - audiobook_generator.py:84 - run - INFO - Converting chapter 1/134: ALSO_BY_SCOTT_GALLOWAY, characters: 203
2024-09-05 11:10:14,694 - piper_tts_provider.py:60 - text_to_speech - INFO - Running Piper TTS command: /home/user/Downloads/piper/piper --model /home/user/Downloads/piper/en_GB-cori-high.onnx --speaker 0 --sentence_silence 0.2 --length_scale 1.0 -f /tmp/tmpi16r8fjx/piper.wav --debug
terminate called after throwing an instance of 'std::runtime_error'
  what():  Model config doesn't exist
2024-09-05 11:10:14,755 - utils.py:62 - set_audio_tags - ERROR - Error while setting audio tags: [Errno 2] No such file or directory: '/tmp/tmpi16r8fjx/piper.wav', /tmp/tmpi16r8fjx/piper.wav
Traceback (most recent call last):
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/_util.py", line 251, in _openfile
    fileobj = open(filename, "rb+" if writable else "rb")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpi16r8fjx/piper.wav'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/Valinor/TV/epub_to_audiobook/main.py", line 189, in <module>
    main()
  File "/home/user/Valinor/TV/epub_to_audiobook/main.py", line 185, in main
    AudiobookGenerator(config).run()
  File "/home/user/Valinor/TV/epub_to_audiobook/audiobook_generator/core/audiobook_generator.py", line 100, in run
    tts_provider.text_to_speech(
  File "/home/user/Valinor/TV/epub_to_audiobook/audiobook_generator/tts_providers/piper_tts_provider.py", line 69, in text_to_speech
    set_audio_tags(tmpfilename, audio_tags)
  File "/home/user/Valinor/TV/epub_to_audiobook/audiobook_generator/core/utils.py", line 63, in set_audio_tags
    raise e  # TODO: use this raise to catch unknown errors for now
    ^^^^^^^
  File "/home/user/Valinor/TV/epub_to_audiobook/audiobook_generator/core/utils.py", line 51, in set_audio_tags
    tags = ID3(output_file)
           ^^^^^^^^^^^^^^^^
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/id3/_file.py", line 76, in __init__
    super(ID3, self).__init__(*args, **kwargs)
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/id3/_tags.py", line 175, in __init__
    super(ID3Tags, self).__init__(*args, **kwargs)
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/_util.py", line 534, in __init__
    super(DictProxy, self).__init__(*args, **kwargs)
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/_tags.py", line 110, in __init__
    self.load(*args, **kwargs)
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/_util.py", line 185, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/_util.py", line 154, in wrapper
    with _openfile(self, filething, filename, fileobj,
  File "/usr/lib64/python3.12/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/home/user/Valinor/TV/epub_to_audiobook/venv/lib64/python3.12/site-packages/mutagen/_util.py", line 272, in _openfile
    raise MutagenError(e)
mutagen.MutagenError: [Errno 2] No such file or directory: '/tmp/tmpi16r8fjx/piper.wav'

@Gandalf-the-Blue
Copy link
Author

I should also add, that when I tried the piper examples from their git repo - I had to add the --config and point it to the model json file to get it to work.

@p0n1
Copy link
Owner

p0n1 commented Sep 11, 2024

I should also add, that when I tried the piper examples from their git repo - I had to add the --config and point it to the model json file to get it to work.

I see the error what(): Model config doesn't exist in your log. Not sure if you put model and config into the same folder. I just put model and config file in the same folder with the main.py script so it's working. I'll add an option like --piper_ config later to handle this issue better.

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