模型:
lengyue233/content-vec-best
Official Repo: ContentVec 该仓库将fairseq ContentVec模型引入HuggingFace Transformers。
要使用该模型,您需要定义
class HubertModelWithFinalProj(HubertModel):
def __init__(self, config):
super().__init__(config)
# The final projection layer is only used for backward compatibility.
# Following https://github.com/auspicious3000/contentvec/issues/6
# Remove this layer is necessary to achieve the desired outcome.
self.final_proj = nn.Linear(config.hidden_size, config.classifier_proj_size)
然后使用以下代码加载模型
model = HubertModelWithFinalProj.from_pretrained("lengyue233/content-vec-best")
x = model(audio)["last_hidden_state"]
您需要从官方仓库下载ContentVec_legacy模型,然后运行以下代码
python convert.py