aedocw / epub2tts

Turn an epub or text file into an audiobook
Apache License 2.0
496 stars 45 forks source link

xtts mode doesn't download model? #77

Closed friki67 closed 9 months ago

friki67 commented 9 months ago

epub2tts cosa.txt --xtts voz1/voz1-1.wav,voz1/voz1-2.wav,voz1/voz1-3.wav

Returns:

Namespace(sourcefile='cosa.txt', engine='tts', xtts='voz1/voz1-1.wav,voz1/voz1-2.wav,voz1/voz1-3.wav', openai='zzz', model='tts_models/en/vctk/vits', speaker='p335', scan=False, start=1, end=999, minratio=88, skiplinks=False, bitrate='69k', debug=False)

--- my Spanish text --

Saving to cosa-voz.m4b
Total characters: 214
Loading model: /home/ubuntu/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_v2
Traceback (most recent call last):
File "/home/ubuntu/.local/bin/epub2tts", line 8, in <module>
sys.exit(main())
File "/home/ubuntu/.local/lib/python3.10/site-packages/epub2tts.py", line 371, in main
mybook.read_book(voice_samples=args.xtts, engine=args.engine, openai=args.openai, model_name=args.model, speaker=args.speaker, bitrate=args.bitrate)
File "/home/ubuntu/.local/lib/python3.10/site-packages/epub2tts.py", line 225, in read_book
config.load_json(model_json)
File "/home/ubuntu/.local/lib/python3.10/site-packages/coqpit/coqpit.py", line 726, in load_json
with open(file_name, "r", encoding="utf8") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_v2/config.json'

and the foldertts_models--multilingual--multi-dataset--xtts_v2/ doesn't exists

Then I did epub2tts --bitrate 128k --model tts_models/multilingual/multi-dataset/xtts_v2 cosa.txt and agreed to the terms and conditions of the license. Just to download the model, then break the operation, re-run the inital command and it worked.

aedocw commented 9 months ago

Good catch, this is an issue where the path to voice samples is not handled properly (in my lazy testing the samples have all been in the same directory I'm working from!)

I'll fix this today, and confirm it catches the model properly as well.

friki67 commented 9 months ago

Wonderful.

I have some issues with the language, again.

I wrote them in https://github.com/aedocw/epub2tts/issues/71, just to keep things in place. Could you please have a look?

aedocw commented 9 months ago

Sorry I jumped to a wrong conclusion about what was going on here because I thought I had seem something similar once due to referencing the voice samples, but that was definitely not it.

I rely on TTS to detect whether or not the model is there, and if it's not, it should just download it. I'm really not sure what happened unless the model directory was there but it was not complete (i.e. missing config.json).

Let's let this open for now, and if you see it happen again please comment and I'll try harder to recreate the issue.

aedocw commented 9 months ago

The merge did not fix this, re-opening this bug.

friki67 commented 9 months ago

I rely on TTS to detect whether or not the model is there, and if it's not, it should just download it. I'm really not sure what happened unless the model directory was there but it was not complete (i.e. missing config.json).

The directory doesn't exists. The model isn't downloaded. I've reproduced the issue deleting all, reinstalling and using --xtts. 1- Install epub2tts 2- execute epub2tts mytext.txt --xtts voice1.wav,voice2.wav,voice3.wav 3- get the error, it doesn't try to download the model, just throw the error after the initial phase.

aedocw commented 9 months ago

Thanks - I've recreated this as well. I will play with how I'm initiating TTS so that it properly triggers the download.

aedocw commented 9 months ago

OK figured out what happened here... I had previously been using basically "plain" xtts v2, which will check to see if the model has been already downloaded and if not, downloads it and prompts for license agreement. Then I switched to using the model API so I could be more specific with some settings. The docs clearly state "To use the model API, you need to download the model files and pass config and model file paths manually." Oops! I didn't notice because I had already downloaded the model.

My clunky fix is to init tts in the more boring way first which will trigger the check to see if the model has already been downloaded. It's working for me, please validate when you get a chance and let me know if this has solved it for you.