Add ONNX model
#1
by
Xenova
HF Staff
- opened
Example code (you can remove , revision="refs/pr/1" when this PR is merged)
import librosa
import onnxruntime as ort
import numpy as np
import soundfile as sf
from huggingface_hub import hf_hub_download
# Download the ONNX model from HF Hub
model_path = hf_hub_download(repo_id="YatharthS/FlashSR", filename="model.onnx", subfolder="onnx", revision="refs/pr/1")
# Load audio file at 16kHz
y, sr = librosa.load("path/to/audio.wav", sr=16000) # Resamples to 16kHz
lowres_wav = y[np.newaxis, :] # Add batch dimension
# Create ONNX session and run inference
ort_session = ort.InferenceSession(model_path)
onnx_output = ort_session.run(["reconstruction"], {"audio_values": lowres_wav})[0]
# Save output audio at 48kHz
sf.write('output.wav', onnx_output.squeeze(0), samplerate=48000)
Discussion: https://github.com/ysharma3501/FlashSR/issues/1#issuecomment-3693175415
YatharthS
changed pull request status to
merged