dlxj commited on
Commit ·
87842ef
1
Parent(s): f5d2dd3
CTC 训练推理正常,for nemo==2.8.0.rc0,但是推理时第一个字符被吃了,其他都正常
Browse files
examples/asr/asr_cache_aware_streaming/speech_to_text_cache_aware_streaming_infer.py
CHANGED
|
@@ -115,7 +115,8 @@ from nemo.collections.asr.parts.submodules.rnnt_decoding import RNNTDecodingConf
|
|
| 115 |
from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
|
| 116 |
from nemo.collections.asr.parts.utils.rnnt_utils import Hypothesis
|
| 117 |
from nemo.collections.asr.parts.utils.streaming_utils import CacheAwareStreamingAudioBuffer
|
| 118 |
-
from nemo.collections.asr.parts.utils.transcribe_utils import setup_model, normalize_timestamp_output
|
|
|
|
| 119 |
from nemo.core.config import hydra_runner
|
| 120 |
from nemo.utils import logging
|
| 121 |
|
|
|
|
| 115 |
from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
|
| 116 |
from nemo.collections.asr.parts.utils.rnnt_utils import Hypothesis
|
| 117 |
from nemo.collections.asr.parts.utils.streaming_utils import CacheAwareStreamingAudioBuffer
|
| 118 |
+
from nemo.collections.asr.parts.utils.transcribe_utils import setup_model, normalize_timestamp_output
|
| 119 |
+
from nemo.collections.asr.parts.utils.timestamp_utils import process_timestamp_outputs
|
| 120 |
from nemo.core.config import hydra_runner
|
| 121 |
from nemo.utils import logging
|
| 122 |
|
examples/asr/asr_ctc/speech_to_text_ctc_bpe.py
CHANGED
|
@@ -94,7 +94,10 @@ def main(cfg):
|
|
| 94 |
|
| 95 |
if hasattr(cfg.model, 'test_ds') and cfg.model.test_ds.manifest_filepath is not None:
|
| 96 |
if asr_model.prepare_test(trainer):
|
| 97 |
-
trainer.
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
|
| 100 |
if __name__ == '__main__':
|
|
@@ -109,7 +112,7 @@ if __name__ == '__main__':
|
|
| 109 |
'exp_manager.resume_ignore_no_checkpoint=true',
|
| 110 |
'exp_manager.exp_dir=results/',
|
| 111 |
'exp_manager.checkpoint_callback_params.save_top_k=1',
|
| 112 |
-
'++trainer.check_val_every_n_epoch=
|
| 113 |
'++model.encoder.conv_norm_type=layer_norm',
|
| 114 |
'model.tokenizer.dir=data/common_voice_11_0/ja/tokenizers/tokenizer_spe_bpe_v2491',
|
| 115 |
'model.train_ds.tarred_audio_filepaths=data/common_voice_11_0/ja/train_tarred_1bk/audio__OP_0..1023_CL_.tar',
|
|
@@ -119,7 +122,7 @@ if __name__ == '__main__':
|
|
| 119 |
'model.train_ds.manifest_filepath=data/common_voice_11_0/ja/train_tarred_1bk/tarred_audio_manifest.json',
|
| 120 |
'model.validation_ds.manifest_filepath=data/common_voice_11_0/ja/validation/validation_common_voice_11_0_manifest.json',
|
| 121 |
'model.test_ds.manifest_filepath=data/common_voice_11_0/ja/test/test_common_voice_11_0_manifest.json',
|
| 122 |
-
'trainer.max_epochs=
|
| 123 |
'trainer.devices=1',
|
| 124 |
'trainer.accelerator=gpu',
|
| 125 |
'trainer.strategy=auto',
|
|
|
|
| 94 |
|
| 95 |
if hasattr(cfg.model, 'test_ds') and cfg.model.test_ds.manifest_filepath is not None:
|
| 96 |
if asr_model.prepare_test(trainer):
|
| 97 |
+
if trainer.checkpoint_callback and trainer.checkpoint_callback.best_model_path:
|
| 98 |
+
trainer.test(asr_model, ckpt_path='best')
|
| 99 |
+
else:
|
| 100 |
+
trainer.test(asr_model)
|
| 101 |
|
| 102 |
|
| 103 |
if __name__ == '__main__':
|
|
|
|
| 112 |
'exp_manager.resume_ignore_no_checkpoint=true',
|
| 113 |
'exp_manager.exp_dir=results/',
|
| 114 |
'exp_manager.checkpoint_callback_params.save_top_k=1',
|
| 115 |
+
'++trainer.check_val_every_n_epoch=700',
|
| 116 |
'++model.encoder.conv_norm_type=layer_norm',
|
| 117 |
'model.tokenizer.dir=data/common_voice_11_0/ja/tokenizers/tokenizer_spe_bpe_v2491',
|
| 118 |
'model.train_ds.tarred_audio_filepaths=data/common_voice_11_0/ja/train_tarred_1bk/audio__OP_0..1023_CL_.tar',
|
|
|
|
| 122 |
'model.train_ds.manifest_filepath=data/common_voice_11_0/ja/train_tarred_1bk/tarred_audio_manifest.json',
|
| 123 |
'model.validation_ds.manifest_filepath=data/common_voice_11_0/ja/validation/validation_common_voice_11_0_manifest.json',
|
| 124 |
'model.test_ds.manifest_filepath=data/common_voice_11_0/ja/test/test_common_voice_11_0_manifest.json',
|
| 125 |
+
'trainer.max_epochs=700',
|
| 126 |
'trainer.devices=1',
|
| 127 |
'trainer.accelerator=gpu',
|
| 128 |
'trainer.strategy=auto',
|
nemo/collections/asr/data/audio_to_text.py
CHANGED
|
@@ -936,7 +936,8 @@ class _TarredAudioToTextDataset(IterableDataset):
|
|
| 936 |
self.current_bytes, self.current_fn = next(self.iterator)
|
| 937 |
self.offset_id = 0
|
| 938 |
else:
|
| 939 |
-
|
|
|
|
| 940 |
if len(offset_list) == self.offset_id + 1:
|
| 941 |
self.current_bytes, self.current_fn = next(self.iterator)
|
| 942 |
self.offset_id = 0
|
|
|
|
| 936 |
self.current_bytes, self.current_fn = next(self.iterator)
|
| 937 |
self.offset_id = 0
|
| 938 |
else:
|
| 939 |
+
file_id, _ = os.path.splitext(os.path.basename(self.current_fn))
|
| 940 |
+
offset_list = self.collection.mapping[file_id]
|
| 941 |
if len(offset_list) == self.offset_id + 1:
|
| 942 |
self.current_bytes, self.current_fn = next(self.iterator)
|
| 943 |
self.offset_id = 0
|
readme.txt
CHANGED
|
@@ -15,6 +15,9 @@ see https://github.com/NVIDIA-NeMo/NeMo/discussions/8473
|
|
| 15 |
|
| 16 |
|
| 17 |
CTC 能正常训练的 nemo 版本是 2.2.1
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
这个 KeyError 报错是由于 WebDataset 解析 tar 包中的路径与 NeMo 的 Manifest 映射字典键值不匹配 导致的。
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
CTC 能正常训练的 nemo 版本是 2.2.1
|
| 18 |
+
common_voice_11_0 需要的版本是 datasets==3.6.0
|
| 19 |
+
numpy==1.26.4
|
| 20 |
+
|
| 21 |
|
| 22 |
|
| 23 |
这个 KeyError 报错是由于 WebDataset 解析 tar 包中的路径与 NeMo 的 Manifest 映射字典键值不匹配 导致的。
|
requirements.txt
CHANGED
|
@@ -12,3 +12,8 @@ modal>=1.3.0.post1
|
|
| 12 |
torch==2.11.0
|
| 13 |
nemo-toolkit[asr,cu13]
|
| 14 |
lhotse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
torch==2.11.0
|
| 13 |
nemo-toolkit[asr,cu13]
|
| 14 |
lhotse
|
| 15 |
+
nv_one_logger_core>=2.3.1
|
| 16 |
+
nv_one_logger_training_telemetry>=2.3.1
|
| 17 |
+
nv_one_logger_pytorch_lightning_integration>=2.3.1
|
| 18 |
+
kaldi-python-io
|
| 19 |
+
kaldialign
|
server_aware_streaming.py
CHANGED
|
@@ -13,7 +13,8 @@ import torch
|
|
| 13 |
from aiohttp import web, WSMsgType
|
| 14 |
from loguru import logger
|
| 15 |
|
| 16 |
-
from nemo.collections.asr.parts.utils.transcribe_utils import normalize_timestamp_output
|
|
|
|
| 17 |
|
| 18 |
# Enable debug logging with DEBUG_ASR=1
|
| 19 |
DEBUG_ASR = os.environ.get("DEBUG_ASR", "0") == "1"
|
|
|
|
| 13 |
from aiohttp import web, WSMsgType
|
| 14 |
from loguru import logger
|
| 15 |
|
| 16 |
+
from nemo.collections.asr.parts.utils.transcribe_utils import normalize_timestamp_output
|
| 17 |
+
from nemo.collections.asr.parts.utils.timestamp_utils import process_timestamp_outputs
|
| 18 |
|
| 19 |
# Enable debug logging with DEBUG_ASR=1
|
| 20 |
DEBUG_ASR = os.environ.get("DEBUG_ASR", "0") == "1"
|
test_websocket_client.py
CHANGED
|
@@ -166,7 +166,7 @@ if __name__ == "__main__":
|
|
| 166 |
import sys
|
| 167 |
# sys.argv.append( '--all' )
|
| 168 |
|
| 169 |
-
audio_path = "./
|
| 170 |
|
| 171 |
server_url = "ws://127.0.0.1:8080"
|
| 172 |
|
|
@@ -174,7 +174,7 @@ if __name__ == "__main__":
|
|
| 174 |
if "--all" in sys.argv:
|
| 175 |
asyncio.run(test_multiple_chunk_sizes(audio_path, server_url))
|
| 176 |
else:
|
| 177 |
-
chunk_ms =
|
| 178 |
if "--chunk" in sys.argv:
|
| 179 |
idx = sys.argv.index("--chunk")
|
| 180 |
if idx + 1 < len(sys.argv):
|
|
|
|
| 166 |
import sys
|
| 167 |
# sys.argv.append( '--all' )
|
| 168 |
|
| 169 |
+
audio_path = "./common_voice_ja_25372057.wav" # "./common_voice_ja_25372057.wav" # "./harvard_16k.wav"
|
| 170 |
|
| 171 |
server_url = "ws://127.0.0.1:8080"
|
| 172 |
|
|
|
|
| 174 |
if "--all" in sys.argv:
|
| 175 |
asyncio.run(test_multiple_chunk_sizes(audio_path, server_url))
|
| 176 |
else:
|
| 177 |
+
chunk_ms = 700
|
| 178 |
if "--chunk" in sys.argv:
|
| 179 |
idx = sys.argv.index("--chunk")
|
| 180 |
if idx + 1 < len(sys.argv):
|