TTS icon indicating copy to clipboard operation
TTS copied to clipboard

For fairseq fix missing dataset, model var initialization

Open shoaib42 opened this issue 2 years ago • 2 comments

A simple fix for fairseq issue.

Issue : When loading the model we get

Traceback (most recent call last):
  File "/home/shoaib/temp.py", line 6, in <module>
    api = TTS("tts_models/pol/fairseq/vits")
  File "/home/shoaib/.local/lib/python3.10/site-packages/TTS/api.py", line 74, in __init__
    self.load_tts_model_by_name(model_name, gpu)
  File "/home/shoaib/.local/lib/python3.10/site-packages/TTS/api.py", line 171, in load_tts_model_by_name
    model_path, config_path, vocoder_path, vocoder_config_path, model_dir = self.download_model_by_name(
  File "/home/shoaib/.local/lib/python3.10/site-packages/TTS/api.py", line 129, in download_model_by_name
    model_path, config_path, model_item = self.manager.download_model(model_name)
  File "/home/shoaib/.local/lib/python3.10/site-packages/TTS/utils/manage.py", line 385, in download_model
    model_item, model_full_name, model, md5sum = self._set_model_item(model_name)
  File "/home/shoaib/.local/lib/python3.10/site-packages/TTS/utils/manage.py", line 304, in _set_model_item
    model_full_name = f"{model_type}--{lang}--{dataset}--{model}"
UnboundLocalError: local variable 'dataset' referenced before assignment

Both dataset and model are not defined/set in the branch that handles fairseq.

Addition : Initialized the variables in the branch.

Maybe its better to conform with the rest of the code, where the variables are unpacked from the str.split. What do you think?

PS - could not do a successful make install and subsequent test, but successfully tested on applying the changes and testing with this code

import torch
from TTS.api import TTS

# Get device
device = "cuda" if torch.cuda.is_available() else "cpu"
api = TTS("tts_models/pol/fairseq/vits")
api.tts_with_vc_to_file(
    "Dzień dobry",
    speaker_wav="speech.wav",
    file_path="output.wav"
)

shoaib42 avatar Dec 27 '23 06:12 shoaib42

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 27 '23 06:12 CLAassistant

Thanks it works for me by patching the existing pip install TTS /home/yodatak/.local/lib/python3.10/site-packages/TTS/utils/manage.py

yodatak avatar Jan 03 '24 23:01 yodatak

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.

stale[bot] avatar Feb 03 '24 13:02 stale[bot]