speech enhancement sgmse
简介
核心亮点
- 基于生成式模型,有效去除复杂非平稳噪声
- 显著提升语音自然度,还原纯净人声
- MIT 协议开源,方便集成到自有产品线
- 可作为 ASR 预处理,大幅提高语音识别率
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("sp-uhh/speech-enhancement-sgmse")
tokenizer = AutoTokenizer.from_pretrained("sp-uhh/speech-enhancement-sgmse")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download sp-uhh/speech-enhancement-sgmse
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download sp-uhh/speech-enhancement-sgmse config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('sp-uhh/speech-enhancement-sgmse')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/sp-uhh/speech-enhancement-sgmse
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/sp-uhh/speech-enhancement-sgmse
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('sp-uhh/speech-enhancement-sgmse')
tokenizer = AutoTokenizer.from_pretrained('sp-uhh/speech-enhancement-sgmse')
完整文档
---
language: en
tags:
- speech-enhancement
- dereverberation
- diffusion-models
- generative-models
- pytorch
- audio-processing
license: mit
datasets:
- VoiceBank-DEMAND
- WSJ0-CHiME3
- WSJ0-REVERB
- EARS-WHAM
- EARS-Reverb
model_name: speech-enhancement-dereverberation-diffusion
model_type: diffusion-based-generative-model
library_name: pytorch
key_files:
- model.py
- train.py
- inference.py
inference: true
pipeline_tag: audio-to-audio
---
Speech Enhancement and Dereverberation with Diffusion-based Generative Models
<img src="https://raw.githubusercontent.com/sp-uhh/sgmse/main/diffusion_process.png" width="500" alt="Diffusion process on a spectrogram: In the forward process noise is gradually added to the clean speech spectrogram x0, while the reverse process learns to generate clean speech in an iterative fashion starting from the corrupted signal xT.">
This repository contains the official PyTorch implementations for the papers:
- Simon Welker, Julius Richter, Timo Gerkmann, *"Speech Enhancement with Score-Based Generative Models in the Complex STFT Domain"*, ISCA Interspeech, Incheon, Korea, Sept. 2022. [[bibtex]](#citations--references)
- Julius Richter, Simon Welker, Jean-Marie Lemercier, Bunlong Lay, Timo Gerkmann, *"Speech Enhancement and Dereverberation with Diffusion-Based Generative Models"*, IEEE/ACM Transactions on Audio, Speech, and Language Processing, vol. 31, pp. 2351-2364, 2023. [[bibtex]](#citations--references)
- Julius Richter, Yi-Chiao Wu, Steven Krenn, Simon Welker, Bunlong Lay, Shinji Watanabe, Alexander Richard, Timo Gerkmann, *"EARS: An Anechoic Fullband Speech Dataset Benchmarked for Speech Enhancement and Dereverberation"*, ISCA Interspecch, Kos, Greece, Sept. 2024. [[bibtex]](#citations--references)
- Julius Richter, Danilo de Oliveira, Timo Gerkmann, *"Investigating Training Objectives for Generative Speech Enhancement"* (preprint), 2024. [[bibtex]](#citations--references)
Audio examples and supplementary materials are available on our SGMSE project page, EARS project page, and Investigating training objectives project page.
Key Files
The following files are essential for this model:
model.py: Defines the model architecture and training processes.
train.py: Script for training the model.
enhancement.py: Used for evaluating and enhancing audio files.
requirements.txt: Lists the necessary dependencies.
calc_metrics.py: Script for calculating evaluation metrics.
Follow-up work
Please also check out our follow-up work with code available:
- Jean-Marie Lemercier, Julius Richter, Simon Welker, Timo Gerkmann, *"StoRM: A Diffusion-based Stochastic Regeneration Model for Speech Enhancement and Dereverberation"*, IEEE/ACM Transactions on Audio, Speech, Language Processing, vol. 31, pp. 2724 -2737, 2023. [[github]](https://github.com/sp-uhh/storm)
- Bunlong Lay, Simon Welker, Julius Richter, Timo Gerkmann, *"Reducing the Prior Mismatch of Stochastic Differential Equations for Diffusion-based Speech Enhancement"*, ISCA Interspeech, Dublin, Ireland, Aug. 2023. [[github]](https://github.com/sp-uhh/sgmse-bbed)
Installation
- Create a new virtual environment with Python 3.11 (we have not tested other Python versions, but they may work).
- Install the package dependencies via
pip install -r requirements.txt.
requirements_version.txt for the exact versions we used.
- If using W&B logging (default):
wandb login before running our code.
- If not using W&B logging:
--nolog to train.py.
- Your logs will be stored as local CSVLogger logs in lightning_logs/.
Pretrained checkpoints
- For the speech enhancement task, we offer pretrained checkpoints for models that have been trained on the VoiceBank-DEMAND and WSJ0-CHiME3 datasets, as described in our journal paper [2]. You can download them here.
gdown 1_H3EXvhcYBhOZ9QNUcD5VZHc6ktrRbwQ
- SGMSE+ trained on WSJ0-CHiME3: gdown 16K4DUdpmLhDNC7pJhBBc08pkSIn_yMPi
- For the dereverberation task, we offer a checkpoint trained on our WSJ0-REVERB dataset. You can download it here.
gdown 1eiOy0VjHh9V9ZUFTxu1Pq2w19izl9ejD
- Note that this checkpoint works better with sampler settings --N 50 --snr 0.33.
- For 48 kHz models [3], we offer pretrained checkpoints for speech enhancement, trained on the EARS-WHAM dataset, and for dereverberation, trained on the EARS-Reverb dataset. You can download them here.
gdown 1t_DLLk8iPH6nj8M5wGeOP3jFPaz3i7K5
- SGMSE+ trained on EARS-Reverb: gdown 1PunXuLbuyGkknQCn_y-RCV2dTZBhyE3V
- For the investigating training objectives checkpoints [4], we offer the pretrained checkpoints here
wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m1.ckpt
- M2: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m2.ckpt
- M3: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m3.ckpt
- M4: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m4.ckpt
- M5: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m5.ckpt
- M6: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m6.ckpt
- M7: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m7.ckpt
- M8: wget https://www2.informatik.uni-hamburg.de/sp/audio/publications/icassp2025_gense/checkpoints/m8.ckpt
Usage:
- For resuming training, you can use the
--ckptoption oftrain.py.
- For evaluating these checkpoints, use the
--ckptoption ofenhancement.py(see section Evaluation below).
Training
Training is done by executing train.py. A minimal running example with default settings (as in our paper [2]) can be run with
python train.py --base_dir <your_base_dir>where your_base_dir should be a path to a folder containing subdirectories train/ and valid/ (optionally test/ as well). Each subdirectory must itself have two subdirectories clean/ and noisy/, with the same filenames present in both. We currently only support training with .wav files.
To see all available training options, run python train.py --help. Note that the available options for the SDE and the backbone network change depending on which SDE and backbone you use. These can be set through the --sde and --backbone options.
Note:
- Our journal [2] uses
--backbone ncsnpp.
- For the 48 kHz model [3], use
--backbone ncsnpp_48k --n_fft 1534 --hop_length 384 --spec_factor 0.065 --spec_abs_exponent 0.667 --sigma-min 0.1 --sigma-max 1.0 --theta 2.0
- Our Interspeech paper [1] uses
--backbone dcunet. You need to pass--n_fft 512to make it work.
- Also note that the default