赞
踩
NeMo可以做以下三个方面的事情:
对应以上任务分别是三个库:
nemo.collections.asr
nemo.collections.nlp
nemo.collections.tts
1.linux系统直接按照官方文档安装即可
2.mac
1)需要先安装ffmpeg和libsndfile1,
使用brew install ffmpeg
安装
如果电脑没有brew需要先安装brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
如果这个命令不行或者遇到connection refuse的问题,那么可以切换国内源
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# conda 虚拟环境配置
conda env list
conda create -n nemo_test --clone base
conda activate nemo_test
# nemo安装
pip install nemo_toolkit['all']
安装小坑总结,如果没有遇到可以忽略
a 安装过程中遇到
zsh:no_match
解决方案
vim ~/.bash
b 遇到cmak需要安装cmake
brew install cmake
c protobuf compiler not found
brew install protobuf
d metadata error
官方入门任务Colab
任务包含三个阶段:
1.识别俄语转化为文本
2.俄语文本翻译成英文
3.英文在生成语音
直接运行的话有坑,在导入collections系列时会报错:
File "/usr/local/lib/python3.7/dist-packages/webdataset/cache.py", line 43
while data := stream.read(chunk_size):
SyntaxError: invalid syntax
其实就是安装的问题,安装要改成:
!apt-get update && apt-get install -y libsndfile1 ffmpeg
!pip install Cython
!pip install nemo_toolkit['all']
识别的俄语:
翻译结果:
Nemo使用OmegaConf和Hydra进行参数控制,
OmegaConf可以使用yaml格式的参数的配置文件,Hydra可以动态的在命令行修改参数。
以citrinet模型为例,主要的参数大概有这些:
preprocessor
- MelSpectrogram preprocessing layerencoder
- The acoustic encoder model.decoder
- The CTC decoder layer.optim
(and potentially sched) - Optimizer configuration. Can optionally include Scheduler information.spec_augment
- Spectrogram Augmentation support.train_ds, validation_ds and test_ds
- Dataset and data loader construction information.# 先导入一个模型 citrinet = nemo_asr.models.EncDecCTCModelBPE.from_pretrained('stt_en_citrinet_512') #使用cfg获取模型参数 from omegaconf import OmegaConf import copy cfg = copy.deepcopy(citrinet.cfg) # 修改配置文件 ## OmegaConf won't allow you to add new config items, so we temporarily disable this safeguard. OmegaConf.set_struct(cfg, False) ## Let's see the old optim config print("Old Config: ") print(OmegaConf.to_yaml(cfg.optim)) OmegaConf.to_yaml(cfg.optim) sched = {'name': 'CosineAnnealing', 'warmup_steps': 1000, 'min_lr': 1e-6} sched = OmegaConf.create(sched) # Convert it into a DictConfig ## Assign it to cfg.optim.sched namespace cfg.optim.sched = sched ## Let's see the new optim config print("New Config: ") print(OmegaConf.to_yaml(cfg.optim)) ## Here, we restore the safeguards so no more additions can be made to the config OmegaConf.set_struct(cfg, True) # update the model config ## preprocessor new_preprocessor_config = copy.deepcopy(cfg.preprocessor) new_preprocessor = citrinet.from_config_dict(new_preprocessor_config) citrinet.preprocessor = new_preprocessor ##
reference:
1.nvidia-nemo git
2.nemo安装
2.cmake install
3.brotobuf instatl
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。