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 keeps downloading already downloaded models. #244

Open
vindolin opened this issue Oct 15, 2023 · 5 comments
Open

Piper keeps downloading already downloaded models. #244

vindolin opened this issue Oct 15, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@vindolin
Copy link

Running the command: echo 'Welcome to the world of speech synthesis!' | piper --model en_US-danny-low --output-raw | aplay -r 22050 -f S16_LE -t raw works on my RPi4, but when I repeat the same command. it outputs the warning: WARNING:piper.download:Wrong size (expected=5953, actual=4166) for /home/vindolin/projects/piper/en_US-danny-low.onnx.json and repeats downloading the same files before playing the output.

Any ideas?

@vindolin
Copy link
Author

I dug around a bit and discovered that the file sizes and md5 hashes in my /home/tulpe/.virtualenvs/piper/lib/python3.9/site-packages/piper/voices.json differed from the ones on https://huggingface.co/rhasspy/piper-voices

@Tristan-Hopkins
Copy link

I've noticed the same thing, however, it seems harmless. a simple fix is to run it like this instead - echo 'This is a test.' | \ piper -m /path/to/model.onnx --output_file test.wav

@synesthesiam synesthesiam self-assigned this Oct 26, 2023
@synesthesiam synesthesiam added the bug Something isn't working label Oct 26, 2023
@ichthyosaurus
Copy link

Have you tried running piper --update-voices -m <any model> to fetch the latest voices.json? Piper prefers the voices.json found in your data dir over the bundled one.

I fixed a related bug in #367.

@wentbackward
Copy link

Have you tried running piper --update-voices -m <any model> to fetch the latest voices.json? Piper prefers the voices.json found in your data dir over the bundled one.

I fixed a related bug in #367.

This works for me.

@jn64
Copy link

jn64 commented Mar 24, 2024

piper-tts 1.2.0 via pip
Python 3.11
Fedora 38

I can repro the original report (without --data-dirs, so #367 doesn't apply). On first run, piper downloads a model, then on subsequent runs, the $model.onnx.json file is re-downloaded every time due to wrong size. --update-voices fixes it.

From what I understand, the problem is:

  1. Without voices.json in the cwd (or $DATA_DIR? not clear to me), piper falls back to the bundled voices.json which may be outdated. E.g. in 1.2.0, the size of en_US-lessac-medium.onnx.json was 7010 B, but it's 4885 B in the current file on huggingface (btw I don't know how/why this file differs from this repo)

  2. If piper is called with a model name (as opposed to a path to a model file), it will check voices.json. If the local files matching that name do not match the size (or checksum?) in voices.json, they are re-downloaded on every use.

Although the $model.onnx.json files are tiny, the constant re-downloading is unnecessary, and adds unexpected latency to the speech synthesis.

Suggestions:

  1. Check and update voices.json on first run (i.e. do --update-voices by default if voices.json doesn't exist in cwd). Piper already downloads the model files on first run, and voices.json size is negligible in comparison. This does not prevent voices.json eventually becoming outdated again, but at least out of the box, the user is not unexpectedly downloading files repeatedly.

  2. Add some file modified time check to reduce superfluous downloads. Even people who want the model to be auto-updated probably don't need it to be updated on every single use.

  3. Alternatively, default to no network access and always favour local files. Add an option to update both voices.json and models (e.g. --update, replacing --update-voices). If any files don't match voices.json there should be a warning printed but no network access without the option. There could be a prompt to download if the specified models don't exist locally, to make it easier for first time users.

    It can be achieved by specifying a path to the model file instead of model name, but the current behaviour (even if this issue is fixed) is unexpected since one of the draws of piper is that it is "local".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants