You can generate a corpus (audio and transcriptions) from a .m2ts stream by combining reazonspeech.espnet.oneseg functions with an ESPnet CTCSegmentation model.
Prerequisites:
- Install
ffmpeg and git-lfs via your package manager. - Download a ReazonSpeech model (e.g.,
reazonspeech-espnet-v2) and link its exp directory.
Workflow:
- Initialize
CTCSegmentation with the model's config and weights. - Use
get_utterances() to extract audio segments and transcriptions. - Use
save_as_zip() to package the results.
$ sudo apt install ffmpeg git-lfs
$ git clone https://huggingface.co/reazon-research/reazonspeech-espnet-v2
$ ln -s reazonspeech-espnet-v2/exp
from espnet2.bin.asr_align import CTCSegmentation
from reazonspeech.espnet.oneseg import get_utterances, save_as_zip
# Load audio and ASR model
ctc_segmentation = CTCSegmentation(
asr_train_config="exp/asr_train_asr_conformer_raw_jp_char/config.yaml",
asr_model_file="exp/asr_train_asr_conformer_raw_jp_char/valid.acc.ave_10best.pth",
kaldi_style_text=False,
fs=16000,
)
# Extract audio and transcriptions
utt = get_utterances("test.m2ts", ctc_segmentation)
save_as_zip(utt, path="corpus.zip")