FastSpeech2 icon indicating copy to clipboard operation
FastSpeech2 copied to clipboard

RuntimeError: The size of tensor a (51) must match the size of tensor b (53) at non-singleton dimension 1

Open yinchyu opened this issue 4 years ago • 11 comments

File "/data/home/scv1106/FastSpeech2/model/modules.py", line 121, in forward x = x + pitch_embedding RuntimeError: The size of tensor a (51) must match the size of tensor b (53) at non-singleton dimension 1

use biaobei dataset to training, but found the problem that the tensor is not in same dimension what should i do to reslove the problems?

yinchyu avatar Dec 06 '21 08:12 yinchyu

我之前也是这样,我觉得是词库不是完整导致有的索引为空 数据不对齐。 但是当我补充完词汇后发现了新的问题 不知道是不是采样率的问题 你可以先打印缺少的字符 在text/system中

yanzhuangzhuang-beep avatar Dec 09 '21 11:12 yanzhuangzhuang-beep

使用MFA后的数据 我的实验就正常可以跑了

yanzhuangzhuang-beep avatar Dec 10 '21 04:12 yanzhuangzhuang-beep

我使用了mfa 生成的词汇表和声学模型,但是还是有这个问题,

yinchyu avatar Dec 10 '21 07:12 yinchyu

Maybe your lexicon generated by MFA contains some phones that are not included in the phone list in the text/pinyin.py file.

finals = [
    "a1",
    "a2",
    "a3",
    "a4",
    "a5",
    "ai1",
    "ai2",
    "ai3",
    "ai4",
...
]

You can print out the missing phones by modifying the _symbols_to_sequence function in text/__init__.py into

def _symbols_to_sequence(symbols):
    missing=[s for s in symbols if not _should_keep_symbol(s)]
    if missing:
        print(missing)
    return [_symbol_to_id[s] for s in symbols if _should_keep_symbol(s)]

And add the missing phones into text/pinyin.py

chenming6615 avatar Dec 14 '21 08:12 chenming6615

if chinese, please try PR: https://github.com/ming024/FastSpeech2/pull/153

everschen avatar Oct 02 '22 12:10 everschen

我也遇到了类似的问题,但是我是刚训练的,mfa生成的音节已经不是拼音了,是一些我看不懂的符号

AkiKagura avatar Nov 13 '22 07:11 AkiKagura

我也遇到了类似的问题,但是我是刚训练的,mfa生成的音节已经不是拼音了,是一些我看不懂的符号

你需要把音素加到,text/symbols里

tuntun990606 avatar Feb 11 '23 07:02 tuntun990606

Maybe your lexicon generated by MFA contains some phones that are not included in the phone list in the text/pinyin.py file.

finals = [
    "a1",
    "a2",
    "a3",
    "a4",
    "a5",
    "ai1",
    "ai2",
    "ai3",
    "ai4",
...
]

You can print out the missing phones by modifying the _symbols_to_sequence function in text/__init__.py into

def _symbols_to_sequence(symbols):
    missing=[s for s in symbols if not _should_keep_symbol(s)]
    if missing:
        print(missing)
    return [_symbol_to_id[s] for s in symbols if _should_keep_symbol(s)]

And add the missing phones into text/pinyin.py

This worked

jobanpreet495 avatar Aug 24 '23 17:08 jobanpreet495

MFA によって生成された辞書には、ファイル内の電話リストに含まれていない電話が含まれている可能性がありますtext/pinyin.py

finals = [
    "a1",
    "a2",
    "a3",
    "a4",
    "a5",
    "ai1",
    "ai2",
    "ai3",
    "ai4",
...
]

_symbols_to_sequenceの関数をtext/__init__.py次のように変更することで、不足している電話機を印刷できます。

def _symbols_to_sequence(symbols):
    missing=[s for s in symbols if not _should_keep_symbol(s)]
    if missing:
        print(missing)
    return [_symbol_to_id[s] for s in symbols if _should_keep_symbol(s)]

不足している電話を追加します text/pinyin.py

this is useful when also training japanese model! Thank you!!!

laTH380 avatar Nov 08 '23 17:11 laTH380

Maybe your lexicon generated by MFA contains some phones that are not included in the phone list in the text/pinyin.py file.

finals = [
    "a1",
    "a2",
    "a3",
    "a4",
    "a5",
    "ai1",
    "ai2",
    "ai3",
    "ai4",
...
]

You can print out the missing phones by modifying the _symbols_to_sequence function in text/__init__.py into

def _symbols_to_sequence(symbols):
    missing=[s for s in symbols if not _should_keep_symbol(s)]
    if missing:
        print(missing)
    return [_symbol_to_id[s] for s in symbols if _should_keep_symbol(s)]

And add the missing phones into text/pinyin.py I am getting list of many missing phones, where should I exactly add them. Please guide me on this

Lakhjeet1082 avatar May 11 '24 16:05 Lakhjeet1082

Maybe your lexicon generated by MFA contains some phones that are not included in the phone list in the text/pinyin.py file.

finals = [
    "a1",
    "a2",
    "a3",
    "a4",
    "a5",
    "ai1",
    "ai2",
    "ai3",
    "ai4",
...
]

You can print out the missing phones by modifying the _symbols_to_sequence function in text/__init__.py into

def _symbols_to_sequence(symbols):
    missing=[s for s in symbols if not _should_keep_symbol(s)]
    if missing:
        print(missing)
    return [_symbol_to_id[s] for s in symbols if _should_keep_symbol(s)]

And add the missing phones into text/pinyin.py I am getting list of many missing phones, where should I exactly add them. Please guide me on this

add them into to the finals list in the file text/pinyin.py

https://github.com/ming024/FastSpeech2/blob/d4e79eb52e8b01d24703b2dfc0385544092958f3/text/pinyin.py#L211

chenming6615 avatar May 13 '24 05:05 chenming6615