GPT-SoVITS icon indicating copy to clipboard operation
GPT-SoVITS copied to clipboard

执行api.py报错

Open blackmore1 opened this issue 1 year ago • 1 comments

You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference. Traceback (most recent call last): File "/Users/zefengsong/Documents/github/GPT-SoVITS/api.py", line 273, in vq_model = SynthesizerTrn( TypeError: module.models.SynthesizerTrn() argument after ** must be a mapping, not DictToAttrRecursive

blackmore1 avatar Feb 06 '24 09:02 blackmore1

You need to turn it back to a dict. Change class DictToAttrRecursive to this:

class DictToAttrRecursive:
    def __init__(self, input_dict):
        for key, value in input_dict.items():
            if isinstance(value, dict):
                setattr(self, key, DictToAttrRecursive(value))
            else:
                setattr(self, key, value)

    def to_dict(self):
        output_dict = {}
        for key in self.__dict__:
            value = getattr(self, key)
            if isinstance(value, DictToAttrRecursive):
                output_dict[key] = value.to_dict()
            else:
                output_dict[key] = value
        return output_dict

and use:

vq_model = SynthesizerTrn(
    hps.data.filter_length // 2 + 1,
    hps.train.segment_size // hps.data.hop_length,
    n_speakers=hps.data.n_speakers,
    **hps.model.to_dict())  # 调用 to_dict

rayquazaMega avatar Feb 09 '24 06:02 rayquazaMega