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

FileNotFoundError: [Errno 2] No such file or directory: 'feats_stats.npz' when using custom model path #44

Open
xunicorn opened this issue Dec 18, 2024 · 3 comments

Comments

@xunicorn
Copy link

How to reproduce:

  1. docker image (Debian GNU/Linux 12 (bookworm))
  2. install via your readMe
  3. run this code
import os
from ukrainian_tts.tts import TTS, Voices, Stress

MODEL_PATH = "/app/models/ukrainian_tts/robinhad"
os.makedirs(MODEL_PATH, exist_ok=True)

tts = TTS(device="cpu", cache_folder=MODEL_PATH) # can try gpu, mps

UPLOAD_FOLDER = "uploads"

text = "Привіт. Раз, два, три!"

def check():
    output_path = os.path.join(UPLOAD_FOLDER, "output.wav")

    with open(output_path, mode="wb") as file:
        _, output_text = tts.tts(text, Voices.Dmytro.value, Stress.Dictionary.value, file)

    print("Accented text:", output_text)

if __name__ == "__main__":
    check()

Expectation: model will be downloaded on specific path and using it for voice generation.
Real: model was downloaded into specific folder, all files exists. But raise exception:

  state = torch.load(filename, lambda storage, loc: storage)
downloading https://github.com/robinhad/ukrainian-tts/releases/download/v6.0.0
Found /app/models/ukrainian_tts/robinhad/model.pth. Skipping download...
Found /app/models/ukrainian_tts/robinhad/config.yaml. Skipping download...
Found /app/models/ukrainian_tts/robinhad/spk_xvector.ark. Skipping download...
Found /app/models/ukrainian_tts/robinhad/feats_stats.npz. Skipping download...
downloaded.
Traceback (most recent call last):
  File "/app/src/test-tts-2.py", line 12, in <module>
    tts = TTS(device="cpu", cache_folder=MODEL_PATH) # can try gpu, mps
  File "/usr/local/lib/python3.10/site-packages/ukrainian_tts/tts.py", line 43, in __init__
  File "/usr/local/lib/python3.10/site-packages/ukrainian_tts/tts.py", line 43, in __init__
    self.__setup_cache(cache_folder)
    self.__setup_cache(cache_folder)
  File "/usr/local/lib/python3.10/site-packages/ukrainian_tts/tts.py", line 117, in __setup_cache
  File "/usr/local/lib/python3.10/site-packages/ukrainian_tts/tts.py", line 117, in __setup_cache
    self.synthesizer = Text2Speech(
  File "/usr/local/lib/python3.10/site-packages/espnet2/bin/tts_inference.py", line 92, in __init__
    model, train_args = TTSTask.build_model_from_file(
  File "/usr/local/lib/python3.10/site-packages/espnet2/bin/tts_inference.py", line 92, in __init__
    model, train_args = TTSTask.build_model_from_file(
    model, train_args = TTSTask.build_model_from_file(
  File "/usr/local/lib/python3.10/site-packages/espnet2/tasks/abs_task.py", line 1846, in build_model_from_file
    model = cls.build_model(args)
  File "/usr/local/lib/python3.10/site-packages/espnet2/tasks/tts.py", line 311, in build_model
    normalize = normalize_class(**args.normalize_conf)
  File "/usr/local/lib/python3.10/site-packages/espnet2/layers/global_mvn.py", line 40, in __init__
    stats = np.load(stats_file)
  File "/usr/local/lib/python3.10/site-packages/numpy/lib/npyio.py", line 405, in load
    fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: 'feats_stats.npz'
@xunicorn
Copy link
Author

i have tried relative path to cache folder - the same

@tdenny
Copy link

tdenny commented Dec 19, 2024

I found in the config.yaml (among the other files downloaded):

normalize_conf:
    stats_file: feats_stats.npz

By updating that line, I got it to use the cache_folder.

normalize_conf:
    stats_file: << my cache directory >>/feats_stats.npz

Maybe, some lines in the __setup_cache function to update that config line after downloading?

@Cfomodz
Copy link

Cfomodz commented Jan 7, 2025

Give that a shot @xunicorn and let me know any feedback you have :)

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

3 participants