PyTorch语音识别框架,将语音转成文本格式
patter
PyTorch中的语音到文本框架,初始支持DeepSpeech2架构(及其变体)。
特征
- 基于文件的语料库定义配置,模型体系结构和可重复性的培训配置
- DeepSpeech模型具有高度可配置性
- 各种RNN类型(RNN,LSTM,GRU)和大小(层/隐藏单元)
- 各种激活功能(Clipped ReLU,Swish)
- 具有Lookahead(用于流式传输)或双向RNN的仅向前RNN
- 可配置的CNN前端
- 可选的batchnorm
- 可选的RNN重量噪音
- 具有KenLM支持的波束解码器
- 数据集扩充,支持:
- 速度扰动
- 获得扰动
- 移动(及时)扰动
- 噪声添加(随机SNR)
- 脉冲响应扰动
- Tensorboard集成
- 基于gRPC的模型服务器
安装
需要手动安装两个依赖项:
- SeanNaren / warp-ctc和包含在回购中的pytorch绑定
- parlance / ctcdecode CTC波束解码器支持语言模型
一旦安装了这些依赖项,就可以通过简单运行来安装模式python setup.py install。出于调试和开发目的,可以安装模式python setup.py develop。
数据集定义
使用带有换行符分隔的json对象的json-lines文件定义模式的数据集。每个链接都包含一个json对象,它定义了一个话语的音频路径,转录路径和持续时间(以秒为单位)。
{"audio_filepath": "/path/to/utterance1.wav", "text_filepath": "/path/to/utterance1.txt", "duration": 23.147} {"audio_filepath": "/path/to/utterance2.wav", "text_filepath": "/path/to/utterance2.txt", "duration": 18.251}
训练
Patter包括一个顶级训练器脚本,该脚本调用底层库方法进行训练。要使用内置命令行培训师,必须定义三个文件:语料库配置,模型配置和培训配置。以下提供各自的实例。
语料库配置
语料库配置文件用于指定语料库中的训练和验证集以及音频应该发生的任何增强。有关这些选项的更多文档,请参阅下面的示例配置。
# Filter the audio configured in the `datasets` below to be within min and max duration. Remove min or max (or both) to # do no filtering min_duration = 1.0 max_duration = 17.0 # Link to manifest files (as described above) of the training and validation sets. A future release will allow multiple # files to be specified for merging corpora on the fly. If `augment` is true, each audio will be passed through the # augmentation pipeline specified below. Valid names for the datasets are in the set ["train", "val"] [[dataset]] name = "train" manifest = "/path/to/corpora/train.json" augment = true [[dataset]] name = "val" manifest = "/path/to/corpora/val.json" augment = false # Optional augmentation pipeline. If specified, audio from a dataset with the augment flag set to true will be passed # through each augmentation, in order. Each augmentation must minimally specify the type and a probability. The # probability indicates that the augmentation will run on a given audio file with that probability # The noise augmentation mixes audio from a dataset of noise files with a random SNR drawn from within the range specified. [[augmentation]] type = "noise" prob = 0.0 [augmentation.config] manifest = "/path/to/noise_manifest.json" min_snr_db = 3 max_snr_db = 35 # The impulse augmentation applies a random impulse response drawn from the manifest to the audio [[augmentation]] type = "impulse" prob = 0.0 [augmentation.config] manifest = "/path/to/impulse_manifest.json" # The speed augmentation applies a random speed perturbation without altering pitch [[augmentation]] type = "speed" prob = 1.0 [augmentation.config] min_speed_rate = 0.95 max_speed_rate = 1.05 # The shift augmentation simply adds a random amount of silence to the audio or removes some of the initial audio [[augmentation]] type = "shift" prob = 1.0 [augmentation.config] min_shift_ms = -5 max_shift_ms = 5 # The gain augmentation modifies the gain of the audio by a fixed amount randomly chosen within the specified range [[augmentation]] type = "gain" prob = 1.0 [augmentation.config] min_gain_dbfs = -10 max_gain_dbfs = 10
型号配置
此时,patter仅支持DeepSpeech 2和DeepSpeech 3(与DS2 w / o BatchNorm + Weight Noise)架构相同的变体。未来版本中可能包含未来的模型体系结构,包括新颖的体系结构。要配置体系结构和超参数,请将模型定义为配置TOML。见例子:
# model class - only DeepSpeechOptim currently model = "DeepSpeechOptim" # define input features/windowing. Currently only STFT is supported, but window is configurable. [input] type = "stft" normalize = true sample_rate = 16000 window_size = 0.02 window_stride = 0.01 window = "hamming" # Define layers of [2d CNN -> Activation -> Optional BatchNorm] as a frontend [[cnn]] filters = 32 kernel = [41, 11] stride = [2, 2] padding = [0, 10] batch_norm = true activation = "hardtanh" activation_params = [0, 20] [[cnn]] filters = 32 kernel = [21, 11] stride = [2, 1] padding = [0, 2] batch_norm = true activation = "hardtanh" activation_params = [0, 20] # Configure the RNN. Currently LSTM, GRU, and RNN are supported. QRNN will be added for forward-only models in a future release [rnn] type = "lstm" bidirectional = true size = 512 layers = 4 batch_norm = true # DS3 suggests using weight noise instead of batch norm, only set when rnn batch_norm = false #[rnn.noise] #mean=0.0 #std=0.001 # only used/necessary when rnn bidirectional = false #[context] #context = 20 #activation = "swish" # Set of labels for model to predict. Specifying a label for the CTC 'blank' symbol is not required and handled automatically [labels] labels = ["'", "A", "B", "C", "D", "E", "F", "G", "H","I", "J", "K", "L", "M", "N", "O", "P", "Q","R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", ]
测试
提供模式测试脚本用于对训练模型进行评估。它将测试配置和训练模型作为参数。
cuda = true batch_size = 10 num_workers = 4 [[dataset]] name = "test" manifest = "/path/to/manifests/test.jl" augment = false [decoder] algorithm = "greedy" # or "beam" workers = 4 # If `beam` is specified as the decoder type, the below is used to initialize the beam decoder [decoder.beam] beam_width = 30 cutoff_top_n = 40 cutoff_prob = 1.0 # If "beam" is specified and you want to use a language model, configure the ARPA or KenLM format LM and alpha/beta weights [decoder.beam.lm] lm_path = "/path/to/language/model.arpa" alpha = 2.15 beta = 0.35
更多使用方法可以查看官方文档
开源地址:
https://github.com/ryanleary/patter
更多更优质的资讯,请关注我,你的支持会鼓励我不断分享更多更好的优质文章。
PyTorch语音识别框架,将语音转成文本格式相关推荐
- 在微信的视频通话中将语音转成文字并显示在通话界面中,可以使用语音识别技术,将语音转换成文本,再通过编程技巧将文本显示在通话界面中。实现方法...
在微信的视频通话中将语音转成文字并显示在通话界面中,可以使用以下步骤进行实现: 使用语音识别技术将语音转换成文本.这可以使用现有的语音识别API,如百度语音识别API等. 通过编程技巧将文本显示在通话 ...
- Linux上silk微信语音转换成mp3格式
最近项目中有个需求,要求把silk微信小程序语音转换成mp3格式,现在Linux中已经实现了,windows的实现方式也很简单,可在网上搜索其它方式,文章最后也给出了几个链接可以参考.以下是对笔者在实 ...
- 怎么把html格式转换成数字,怎么把数字转变成文本格式
1. excel表格怎么把数字转换成文本格式 方法有三: 其一:百双击该单元格,在6前面加个英文下的单引号',然后回车,这个单元格就变成文本了度,适合数据量少的情况. 其二:选中所有需要转换类型的单元 ...
- 将excel的单元格日期格式转换成文本格式
有时在用excel处理数据时需要将日期格式,如"2008年7月18日"或"2008-7-18"的日期格式转换成"20080718"的8位文本 ...
- excel分列格式问题:转化成文本格式问题
excel分列格式问题:转化成文本格式问题 怎么遇到的问题? 如何解决问题? 怎么遇到的问题? 因为有科学计数法的形式所以想要转换成文本格式方便导入数据库,就必须用到如图所示的分列. 其余操作一切正常 ...
- 在微信的视频通话中将语音转成文字并显示在通话界面中,可以使用语音识别技术,将语音转换成文本,再通过编程技巧将文本显示在通话界面中。在手机上实现方法代码...
在微信的视频通话中将语音转成文字并显示在通话界面中可以通过以下步骤实现: 使用微信的语音识别 API 识别语音并将其转换为文本 使用编程技巧将文本显示在通话界面中 在手机上使用相应的编程语言(如Jav ...
- python语音输入转化成文字_利用百度语音识别接口将语音转换成文字教程
importbase64importjsonimportosimporttimeimportshutilimportrequestsclassBaiduVoiceToTxt():#初始化函数 def ...
- 利用百度语音识别接口将语音转换成文字教程
一.说明 如果有一个工具能识别音视中的语音并转换成文字输出,由于可以复制粘贴而不需要逐字逐句地打,那我们进行为音频配字幕工作时将会事半功倍. 其中的关键点是音文转换,音文转换其实在很多地方都可以看到比 ...
- 星辉信息科技教程-Centos上silk微信语音转换成mp3格式
进行相关软件定制开发或者手机软件开发时,需要将QQ及微信的语音转换成MP3存储.QQ,微信的语音存储格式都是silk,所以星辉科技出此教程,搭建环境进行转换操作 注意:本文安装都在/usr/local ...
最新文章
- linux下程序执行的步骤及其作用
- Python初学者之ModuleNotFoundError:No module named 'cv2'简单解决办法
- jenkins 手动执行_我常用的SpringBoot+Jenkins自动化部署技巧,贼好用,推荐给大家...
- Deep Learning 教程翻译
- 【Linux】一步一步学Linux——bind命令(231)
- 两个矩阵是否相交的算法_算法血拼:Google+百度+Alibaba+字节+Tencent+网易+360+拼夕夕...
- STM32 编码器的CUBEMX的使用
- iOS开发 UILabel实现自适应高宽
- Jupyter Lab在线运行矩池云教程
- Cesium 模拟下雪
- 大学电路题目怎么搜_大学扫一扫题目出答案软件,可以拍照搜大学题目的app,大学电路分析搜题软件...
- 错误: 实例 ruiy 执行所请求操作失败,实例处于错误状态。: 请稍后再试 [错误: #39;ascii#39; codec can#39;t decode byte 0xe6 in po...
- php中alight是什么意思,进阶PHP需要注意的一些点
- DirectX12(D3D12)基础教程(四)——初识DirectXMath库、使用独立堆创建常量缓冲、理解管线状态对象、理解围栏同步
- DSG SuperSync大型数据库高性能复制平台产品介绍
- Environment Variables
- RTC在大规模直播场景下的技术分析
- insightfacde 算法学习
- 【git-02】用git管理vue项目
- python怎么换背景_3行Python代码实现图像照片抠图和换底色的方法