[论文] - [代码] - [展示] - [项目页面] - [权重] - [演示]

2024年7月(v2.3):
2024年7月(v2.2): 仓库现在包含使用Gradio构建的交互式本地演示。
2024年7月(v2.1): BigVGAN现已与🤗 Hugging Face Hub集成,可使用预训练检查点轻松进行推理。我们还在Hugging Face Spaces上提供了交互式演示。
2024年7月(v2): 我们发布了BigVGAN-v2以及预训练检查点。以下是亮点:
本仓库包含预训练的 BigVGAN 检查点,可轻松进行推理,并支持 huggingface_hub。
如果您对模型训练和其他功能感兴趣,请访问官方 GitHub 仓库获取更多信息:https://github.com/NVIDIA/BigVGAN
git lfs install
git clone https://huggingface.co/nvidia/bigvgan_v2_22khz_80band_256x以下示例介绍了如何使用 BigVGAN:从 Hugging Face Hub 加载预训练的 BigVGAN 生成器,从输入波形计算梅尔频谱图,并将该梅尔频谱图作为模型输入生成合成波形。
device = 'cuda'
import torch
import bigvgan
import librosa
from meldataset import get_mel_spectrogram
# instantiate the model. You can optionally set use_cuda_kernel=True for faster inference.
model = bigvgan.BigVGAN.from_pretrained('nvidia/bigvgan_v2_22khz_80band_256x', use_cuda_kernel=False)
# remove weight norm in the model and set to eval mode
model.remove_weight_norm()
model = model.eval().to(device)
# load wav file and compute mel spectrogram
wav_path = '/path/to/your/audio.wav'
wav, sr = librosa.load(wav_path, sr=model.h.sampling_rate, mono=True) # wav is np.ndarray with shape [T_time] and values in [-1, 1]
wav = torch.FloatTensor(wav).unsqueeze(0) # wav is FloatTensor with shape [B(1), T_time]
# compute mel spectrogram from the ground truth audio
mel = get_mel_spectrogram(wav, model.h).to(device) # mel is FloatTensor with shape [B(1), C_mel, T_frame]
# generate waveform from mel
with torch.inference_mode():
wav_gen = model(mel) # wav_gen is FloatTensor with shape [B(1), 1, T_time] and values in [-1, 1]
wav_gen_float = wav_gen.squeeze(0).cpu() # wav_gen is FloatTensor with shape [1, T_time]
# you can convert the generated waveform to 16 bit linear PCM
wav_gen_int16 = (wav_gen_float * 32767.0).numpy().astype('int16') # wav_gen is now np.ndarray with shape [1, T_time] and int16 dtype实例化 BigVGAN 时,您可以通过参数 use_cuda_kernel 应用快速 CUDA 推理内核:
import bigvgan
model = bigvgan.BigVGAN.from_pretrained('nvidia/bigvgan_v2_22khz_80band_256x', use_cuda_kernel=True)首次使用时,它会通过 nvcc 和 ninja 构建内核。如果构建成功,内核将保存到 alias_free_activation/cuda/build 目录,模型会自动加载该内核。此代码库已使用 CUDA 12.1 版本测试通过。
请确保您的系统中已安装上述两者,并且系统中安装的 nvcc 版本与您的 PyTorch 构建所使用的版本相匹配。
有关详细信息,请参阅官方 GitHub 仓库:https://github.com/NVIDIA/BigVGAN?tab=readme-ov-file#using-custom-cuda-kernel-for-synthesis
我们在 Hugging Face Collections 上提供了预训练模型。
您可以在列出的模型仓库中下载生成器权重的检查点(命名为 bigvgan_generator.pt)及其判别器/优化器状态(命名为 bigvgan_discriminator_optimizer.pt)。
| 模型名称 | 采样率 | 梅尔频段 | 最高频率 | 上采样倍率 | 参数量 | 数据集 | 步数 | 是否微调 |
|---|---|---|---|---|---|---|---|---|
| bigvgan_v2_44khz_128band_512x | 44 kHz | 128 | 22050 | 512 | 122M | 大规模 compilation 数据集 | 5M | 否 |
| bigvgan_v2_44khz_128band_256x | 44 kHz | 128 | 22050 | 256 | 112M | 大规模 compilation 数据集 | 5M | 否 |
| bigvgan_v2_24khz_100band_256x | 24 kHz | 100 | 12000 | 256 | 112M | 大规模 compilation 数据集 | 5M | 否 |
| bigvgan_v2_22khz_80band_256x | 22 kHz | 80 | 11025 | 256 | 112M | 大规模 compilation 数据集 | 5M | 否 |
| bigvgan_v2_22khz_80band_fmax8k_256x | 22 kHz | 80 | 8000 | 256 | 112M | 大规模 compilation 数据集 | 5M | 否 |
| bigvgan_24khz_100band | 24 kHz | 100 | 12000 | 256 | 112M | LibriTTS | 5M | 否 |
| bigvgan_base_24khz_100band | 24 kHz | 100 | 12000 | 256 | 14M | LibriTTS | 5M | 否 |
| bigvgan_22khz_80band | 22 kHz | 80 | 8000 | 256 | 112M | LibriTTS + VCTK + LJSpeech | 5M | 否 |
| bigvgan_base_22khz_80band | 22 kHz | 80 | 8000 | 256 | 14M | LibriTTS + VCTK + LJSpeech | 5M | 否 |