Views
No views yet
1import onnxruntime as ort
2from transformers import HubertModel
3import torch
4
5# Load the upstream HuBERT model.
6upstream = HubertModel.from_pretrained("facebook/hubert-base-ls960")
7upstream.eval()
8
9# Load the autoencoder model.
10postprocessor = ort.InferenceSession("sslzip_256.onnx")
11node_name = postprocessor.get_inputs()[0].name
12
13# Prepare an input waveform (assuming 16kHz audio).
14x = torch.randn(1, 16000)
15
16# Extract the latent representation for downstream tasks.
17with torch.inference_mode():
18 h = upstream(x, output_hidden_states=True).hidden_states[-1]
19 z = postprocessor.run(None, {node_name: h.cpu().numpy()})[0]
20
21# Use z as you like.
22print(z.shape)1@InProceedings{yoshimura2025sslzip,
2 author = {Takenori Yoshimura and Shinji Takaki and Kazuhiro Nakamura and Keiichiro Oura and Takato Fujimoto and Kei Hashimoto and Yoshihiko Nankaku and Keiichi Tokuda},
3 title = {{SSLZip}: Simple autoencoding for enhancing self-supervised speech representations in speech generation},
4 booktitle = {13th ISCA Speech Synthesis Workshop (SSW 2025)},
5 pages = {xxx--xxx},
6 year = {2025},
7}