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

Fix fairseq #11

Merged
merged 2 commits into from
Mar 9, 2024
Merged

Fix fairseq #11

merged 2 commits into from
Mar 9, 2024

Conversation

eginhard
Copy link
Owner

@eginhard eginhard commented Mar 8, 2024

Copied from coqui-ai#3502 (supersedes coqui-ai#3500 and coqui-ai#3471, fixes coqui-ai#3142, fixes coqui-ai#3361, fixes coqui-ai#3501, fixes coqui-ai#3638):

Fix error on using fairseq model. Variables like dataset and model aren't defined.

So, this is the bug a user faced recently while using the model fairseq, as you can see the user encountered the error: unbound variable 'dataset' in the file manage.py in the method _set_model_item, on inspecting the code, I found that infact, in the condition when fairseq was in 'model_name' there was no declaration of variable dataset as well as the variable model, so I just added them in the first if condition and it solved the issue. I tested it and it worked like charm.

Code:

from TTS.api import TTS

tts = TTS(model_name="tts_models/eng/fairseq/vits", progress_bar=False, gpu=True)
tts.tts_to_file("This is a test.", file_path="output.wav")

Error:

D:\Software\anaconda3\envs\freqtrade310\python.exe C:\Users\uyplayer\Downloads\uig-script_arabic\model.py 
D:\Software\anaconda3\envs\freqtrade310\lib\site-packages\TTS\api.py:70: UserWarning: `gpu` will be deprecated. Please use `tts.to(device)` instead.
  warnings.warn("`gpu` will be deprecated. Please use `tts.to(device)` instead.")
Traceback (most recent call last):
  File "C:\Users\uyplayer\Downloads\uig-script_arabic\model.py", line 5, in <module>
    tts = TTS(model_name="tts_models/eng/fairseq/vits", progress_bar=False, gpu=True)
  File "D:\Software\anaconda3\envs\freqtrade310\lib\site-packages\TTS\api.py", line 74, in __init__
    self.load_tts_model_by_name(model_name, gpu)
  File "D:\Software\anaconda3\envs\freqtrade310\lib\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 "D:\Software\anaconda3\envs\freqtrade310\lib\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 "D:\Software\anaconda3\envs\freqtrade310\lib\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 "D:\Software\anaconda3\envs\freqtrade310\lib\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

Process finished with exit code 1

fixes: coqui-ai#3142 coqui-ai#3361 coqui-ai#3501

Since this is my first PR, It would be really nice if it would get merged, or if there's anything else I can help with please let me know. ThankYou.

@eginhard eginhard merged commit d80f7f4 into dev Mar 9, 2024
34 checks passed
@eginhard eginhard deleted the fix-fairseq branch March 9, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants