Views
No views yet
1from transformers import HubertModel
2import torch.nn as nn
3class HubertModelWithFinalProj(HubertModel):
4 def __init__(self, config):
5 super().__init__(config)
6
7 # The final projection layer is only used for backward compatibility.
8 # Following https://github.com/auspicious3000/contentvec/issues/6
9 # Remove this layer is necessary to achieve the desired outcome.
10 self.final_proj = nn.Linear(config.hidden_size, config.classifier_proj_size)1audio = torch.randn(1, 16000)
2
3model = HubertModelWithFinalProj.from_pretrained("lengyue233/content-vec-best")
4
5x = model(audio)["last_hidden_state"]python convert.py