Downloads · 30 days
0
MidFord327/Hubert-Base-ONNX
Hubert-Base-ONNX is a feature extraction model from MidFord327. Use it when you need embeddings to search or compare text. It is set up for fairseq. The card lists the license as apache-2.0.
This is the ONNX-exported version of the Hubert Base model, fine-tuned for voice conversion and compatible with modern inference pipelines. This model allows fast and efficient audio processing in ONNX runtime environ…
Downloads · 30 days
0
Access
Public
Updated Sep 16, 2025
Repo size
378 MB
Likes
2
Public
Click a slice to open those files.
.onnx378 MB · 100%
From the Hugging Face model README
This is the ONNX-exported version of the Hubert Base model, fine-tuned for voice conversion and compatible with modern inference pipelines. This model allows fast and efficient audio processing in ONNX runtime environments.
It builds upon the following models:
Model: hubert_base.onnx
Producer: pytorch 2.0.0
IR Version: 8
Opsets: ai.onnx:18
Parameters: 94,370,816
float32 | shape: [batch_size, sequence_length]
bool | shape: [batch_size, sequence_length]
padding_mask = np.zeros(waveform.shape, dtype=np.bool_)float32 | shape: [batch_size, sequence_length, 768 ]import numpy as np
import onnxruntime as ort
class OnnxHubert:
"""
Class to load and run the ONNX model exported by Hubert.
Attributes:
session (ort.InferenceSession): The ONNX Runtime session.
input_name (str): The name of the input node.
output_name (str): The name of the output node.
Methods:
extract_features_batch (source, padding_mask): Run the ONNX model and extract features from the batch.
extract_features (source, padding_mask): Run the ONNX model and extract features from a single input.
"""
def __init__(self, model_path: str, thread_num: int = None):
"""
Initialize the OnnxHubert object.
Parameters:
model_path (str): The path to the ONNX model file.
thread_num (int, optional): The number of threads to use for inference. Defaults to None.
Attributes:
session (ort.InferenceSession): The ONNX Runtime session.
input_name (str): The name of the input node.
output_name (str): The name of the output node.
"""
self.session = ort.InferenceSession(model_path)
self.input_name = self.session.get_inputs()[0].name
self.output_name = self.session.get_outputs()[0].name
def extract_features(
self,
source: np.ndarray,
padding_mask: np.ndarray
) -> np.ndarray:
"""
Extract features from the batch using the ONNX model.
Inputs:
source: ndarray of shape (batch_size, sequence_length) float32
padding_mask: ndarray of shape (batch_size, sequence_length) bool
Returns:
ndarray of shape (D, 768) with the extracted features
"""
result = self.session.run(None, {
"source": source,
"padding_mask": padding_mask
})
return result[0]
You can install the required libraries with:
pip install onnxruntime numpy