myshell-ai / MeloTTS

High-quality multi-lingual text-to-speech library by MyShell.ai. Support English, Spanish, French, Chinese, Japanese and Korean.
MIT License
4.85k stars 631 forks source link

Error on english_bert.py in melo/text/english_bert.py when using local bert-base-uncased model. #132

Open ivanhe123 opened 6 months ago

ivanhe123 commented 6 months ago

When I tried to use an downloaded local version of bert-base-uncased, it loaded correctly and I enter the correct path. I cannot download the model using the c ode becuase for some reason the model will time out. The hf repo is at google-bert/bert-base-uncased. then there is a warning after a >Text split to sentences. log (which is from faster-whisper):

 > Text split to sentences.
Hello, how are you recently?
 > ===========================
  0%|          | 0/1 [00:00<?, ?it/s]
Some weights of the model checkpoint at xxx/melo/text/bert-base-uncased were not used when initializing BertForMaskedLM: ['bert.pooler.dense.bias', 'bert.pooler.dense.weight', 'cls.seq_relationship.bias', 'cls.seq_relationship.weight']
- This IS expected if you are initializing BertForMaskedLM from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing BertForMaskedLM from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
  0%|          | 0/1 [00:02<?, ?it/s]
Traceback (most recent call last):
  File "xxx\run_multi_3.py", line 78, in <module>
    model.tts_to_file(text, speaker_id, src_path, speed=speed)
  File "xxx\melo\api.py", line 100, in tts_to_file
    bert, ja_bert, phones, tones, lang_ids = utils.get_text_for_tts_infer(t, language, self.hps, device, self.symbol_to_id)
  File "xxx\melo\utils.py", line 38, in get_text_for_tts_infer
    bert = get_bert(norm_text, word2ph, language_str, device)
  File "xxx\melo\text\__init__.py", line 29, in get_bert
    bert = lang_bert_func_map[language](norm_text, word2ph, device)
  File "xxx\melo\text\english_bert.py", line 30, in get_bert_feature
    assert inputs["input_ids"].shape[-1] == len(word2ph)
AssertionError