MLX implementation of https://github.com/NVIDIA/BigVGAN
1
stars
12
commits
Jupyter Notebook
primary language
May 14, 2025
updated
An MLX-adapted implementation of BigVGAN.
snake, snakebeta).pip install mlx-bigvgan
from mlx_bigvgan import BigVGAN
model = BigVGAN.from_pretrained("wyrom/mlx-bigvgan_v2_24khz_100band_256x")
model.eval()
mx.eval(model.parameters())
import numpy as np
import mlx.core as mx
from mlx_bigvgan import log_mel_spectrogram, load_audio
# Load audio file
audio = load_audio("path/to/audio.wav")
h = model.config
# Compute log-mel spectrogram
mel_spec = log_mel_spectrogram(audio,
n_fft=h.n_fft,
n_mels=h.num_mels,
sample_rate=h.sampling_rate,
hop_length=h.hop_size,
fmin=h.fmin,
fmax=h.fmax,
padding=(h.n_fft - h.hop_size) // 2,
mel_norm="slaney",
mel_scale="slaney",
power=1.0,
)
# reshape to [B(1), T, C_mels]
mel_spec = mx.expand_dims(mel_spec, 0)
# Generate waveform
waveform = model(mel_spec) # [B(1), T, 1]
# Reshape to [T, 1]
waveform_float = waveform.squeeze(0)
# Convert to int16
waveform_int16 = mx.clip(waveform_float * 32767, -32768, 32767).astype(mx.int16)
# save to wav
import soundfile as sf
sf.write("output.wav", waveform_int16, h.sampling_rate, "PCM_16")
You can convert the original BigVGAN weights to MLX format using the provided script.
repo_id is the Hugging Face model ID of the original BigVGAN model you want to convert.
See nvidia/BigVGAN for move pretrained models.
python -m mlx_bigvgan.convert --repo_id nvidia/bigvgan_v2_xxx --output_dir mlx_models
This project is licensed under the MIT License. See the LICENSE file for details.
12 commits
Jupyter Notebook
97.5%
Python
2.5%
MLX implementation of https://github.com/NVIDIA/BigVGAN
1
stars
12
commits
Jupyter Notebook
primary language
May 14, 2025
updated
An MLX-adapted implementation of BigVGAN.
snake, snakebeta).pip install mlx-bigvgan
from mlx_bigvgan import BigVGAN
model = BigVGAN.from_pretrained("wyrom/mlx-bigvgan_v2_24khz_100band_256x")
model.eval()
mx.eval(model.parameters())
import numpy as np
import mlx.core as mx
from mlx_bigvgan import log_mel_spectrogram, load_audio
# Load audio file
audio = load_audio("path/to/audio.wav")
h = model.config
# Compute log-mel spectrogram
mel_spec = log_mel_spectrogram(audio,
n_fft=h.n_fft,
n_mels=h.num_mels,
sample_rate=h.sampling_rate,
hop_length=h.hop_size,
fmin=h.fmin,
fmax=h.fmax,
padding=(h.n_fft - h.hop_size) // 2,
mel_norm="slaney",
mel_scale="slaney",
power=1.0,
)
# reshape to [B(1), T, C_mels]
mel_spec = mx.expand_dims(mel_spec, 0)
# Generate waveform
waveform = model(mel_spec) # [B(1), T, 1]
# Reshape to [T, 1]
waveform_float = waveform.squeeze(0)
# Convert to int16
waveform_int16 = mx.clip(waveform_float * 32767, -32768, 32767).astype(mx.int16)
# save to wav
import soundfile as sf
sf.write("output.wav", waveform_int16, h.sampling_rate, "PCM_16")
You can convert the original BigVGAN weights to MLX format using the provided script.
repo_id is the Hugging Face model ID of the original BigVGAN model you want to convert.
See nvidia/BigVGAN for move pretrained models.
python -m mlx_bigvgan.convert --repo_id nvidia/bigvgan_v2_xxx --output_dir mlx_models
This project is licensed under the MIT License. See the LICENSE file for details.
12 commits
Jupyter Notebook
97.5%
Python
2.5%