1 Star 0 Fork 1

aurae/deepspeech.pytorch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
noise_inject.py 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
import argparse
import torch
from scipy.io.wavfile import write
from deepspeech_pytorch.loader.data_loader import load_audio, NoiseInjection
parser = argparse.ArgumentParser()
parser.add_argument('--input-path', default='input.wav', help='The input audio to inject noise into')
parser.add_argument('--noise-path', default='noise.wav', help='The noise file to mix in')
parser.add_argument('--output-path', default='output.wav', help='The noise file to mix in')
parser.add_argument('--sample-rate', default=16000, help='Sample rate to save output as')
parser.add_argument('--noise-level', type=float, default=1.0,
help='The Signal to Noise ratio (higher means more noise)')
args = parser.parse_args()
noise_injector = NoiseInjection()
data = load_audio(args.input_path)
mixed_data = noise_injector.inject_noise_sample(data, args.noise_path, args.noise_level)
mixed_data = torch.tensor(mixed_data, dtype=torch.float).unsqueeze(1) # Add channels dim
write(filename=args.output_path,
data=mixed_data.numpy(),
rate=args.sample_rate)
print('Saved mixed file to %s' % args.output_path)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/bigcash/deepspeech.pytorch.git
git@gitee.com:bigcash/deepspeech.pytorch.git
bigcash
deepspeech.pytorch
deepspeech.pytorch
master

搜索帮助