Views
No views yet
espnet and espnet_model_zoo. The requirements are:librosa
torch
espnet
espnet_model_zooSpeech2Text.decode_long decodes one recording of any length with CTC best-path decoding. Audio shorter than 30s is padded to 30s; anything longer is split into overlapping buffers. It returns (start_time, end_time, text) per segment, and a CTC-only model such as this one has no timestamps, so it returns a single entry covering the recording.1from espnet2.bin.s2t_inference import Speech2Text
2
3s2t = Speech2Text.from_pretrained(
4 "espnet/owsm_ctc_v4_1B",
5 device="cuda",
6 use_flash_attn=False, # set to True for better efficiency if flash attn is installed and dtype is float16 or bfloat16
7 lang_sym='<eng>',
8 task_sym='<asr>',
9)
10
11segments = s2t.decode_long(
12 "audio.wav", # a single audio (path or 1-D array/tensor) as input
13 batch_size=16,
14 context_len_in_secs=4,
15)
16text = " ".join(segment for _, _, segment in segments)
17
18# For several recordings, call it once per recording:
19texts = [
20 " ".join(t for _, _, t in s2t.decode_long(path, batch_size=16))
21 for path in ["audio1.wav", "audio2.wav", "audio3.wav"]
22]1import librosa
2from espnet2.bin.s2t_inference import Speech2Text
3
4s2t = Speech2Text.from_pretrained(
5 "espnet/owsm_ctc_v4_1B",
6 device="cuda",
7 generate_interctc_outputs=False,
8 lang_sym='<eng>',
9 task_sym='<asr>',
10)
11
12# NOTE: OWSM-CTC is trained on 16kHz audio with a fixed 30s duration. Please ensure your input has the correct sample rate; otherwise resample it to 16k before feeding it to the model
13speech, rate = librosa.load("xxx.wav", sr=16000)
14speech = librosa.util.fix_length(speech, size=(16000 * 30))
15
16# best_path is CTC best-path (greedy) decoding: one encoder pass, no search.
17# Calling s2t(speech) instead runs a CTC prefix beam search, which is far
18# slower and takes beam_size, lm_weight and the rest.
19res = s2t.best_path(speech)[0]
20print(res)1import soundfile as sf
2import torch
3from espnet2.bin.s2t_inference import Speech2Text
4
5context_len_in_secs = 4 # left and right context when doing buffered inference
6batch_size = 32 # depends on the GPU memory
7s2t = Speech2Text.from_pretrained(
8 "espnet/owsm_ctc_v4_1B",
9 device='cuda' if torch.cuda.is_available() else 'cpu',
10 generate_interctc_outputs=False,
11 lang_sym='<eng>',
12 task_sym='<asr>',
13)
14
15speech, rate = sf.read(
16 "xxx.wav"
17)
18
19segments = s2t.decode_long(
20 speech,
21 batch_size=batch_size,
22 context_len_in_secs=context_len_in_secs,
23)
24print(" ".join(text for _, _, text in segments))ctc-segmentation1import soundfile as sf
2from espnet2.bin.s2t_ctc_align import CTCSegmentation
3from espnet_model_zoo.downloader import ModelDownloader
4
5# Download model first
6d = ModelDownloader()
7downloaded = d.download_and_unpack("espnet/owsm_ctc_v4_1B")
8
9aligner = CTCSegmentation(
10 **downloaded,
11 fs=16000,
12 ngpu=1,
13 batch_size=32, # batched parallel decoding; reduce it if your GPU memory is smaller
14 kaldi_style_text=True,
15 time_stamps="auto", # "auto" can be more accurate than "fixed" when converting token index to timestamp
16 lang_sym="<eng>",
17 task_sym="<asr>",
18 context_len_in_secs=2, # left and right context in buffered decoding
19)
20
21speech, rate = sf.read(
22 "./test_utils/ctc_align_test.wav"
23)
24print(f"speech duration: {len(speech) / rate : .2f} seconds")
25text = """
26utt1 THE SALE OF THE HOTELS
27utt2 IS PART OF HOLIDAY'S STRATEGY
28utt3 TO SELL OFF ASSETS
29utt4 AND CONCENTRATE ON PROPERTY MANAGEMENT
30"""
31
32segments = aligner(speech, text)
33print(segments)| Name | Size | Hugging Face Repo |
|---|---|---|
| OWSM v3.1 base | 101M | https://huggingface.co/espnet/owsm_v3.1_ebf_base |
| OWSM v3.1 small | 367M | https://huggingface.co/espnet/owsm_v3.1_ebf_small |
| OWSM v3.1 medium | 1.02B | https://huggingface.co/espnet/owsm_v3.1_ebf |
| OWSM v3.2 small | 367M | https://huggingface.co/espnet/owsm_v3.2 |
| OWSM v4 base | 102M | https://huggingface.co/espnet/owsm_v4_base_102M |
| OWSM v4 small | 370M | https://huggingface.co/espnet/owsm_v4_small_370M |
| OWSM v4 medium | 1.02B | https://huggingface.co/espnet/owsm_v4_medium_1B |
| Name | Size | Hugging Face Repo |
|---|---|---|
| OWSM-CTC v3.1 medium | 1.01B | https://huggingface.co/espnet/owsm_ctc_v3.1_1B |
| OWSM-CTC v3.2 medium | 1.01B | https://huggingface.co/espnet/owsm_ctc_v3.2_ft_1B |
| OWSM-CTC v4 medium | 1.01B | https://huggingface.co/espnet/owsm_ctc_v4_1B |
1@inproceedings{owsm-v4,
2 title={{OWSM} v4: Improving Open Whisper-Style Speech Models via Data Scaling and Cleaning},
3 author={Yifan Peng and Shakeel Muhammad and Yui Sudo and William Chen and Jinchuan Tian and Chyi-Jiunn Lin and Shinji Watanabe},
4 booktitle={Proceedings of the Annual Conference of the International Speech Communication Association (INTERSPEECH)},
5 year={2025},
6}1@inproceedings{owsm-ctc,
2 title = "{OWSM}-{CTC}: An Open Encoder-Only Speech Foundation Model for Speech Recognition, Translation, and Language Identification",
3 author = "Peng, Yifan and
4 Sudo, Yui and
5 Shakeel, Muhammad and
6 Watanabe, Shinji",
7 booktitle = "Proceedings of the Annual Meeting of the Association for Computational Linguistics (ACL)",
8 year = "2024",
9 month= {8},
10 url = "https://aclanthology.org/2024.acl-long.549",
11}1@inproceedings{owsm-v32,
2 title={On the Effects of Heterogeneous Data Sources on Speech-to-Text Foundation Models},
3 author={Jinchuan Tian and Yifan Peng and William Chen and Kwanghee Choi and Karen Livescu and Shinji Watanabe},
4 booktitle={Proceedings of the Annual Conference of the International Speech Communication Association (INTERSPEECH)},
5 year={2024},
6 month={9},
7 pdf="https://arxiv.org/pdf/2406.09282"
8}
9@inproceedings{owsm-v31,
10 title={{OWSM v3.1: Better and Faster Open Whisper-Style Speech Models based on E-Branchformer}},
11 author={Yifan Peng and Jinchuan Tian and William Chen and Siddhant Arora and Brian Yan and Yui Sudo and Muhammad Shakeel and Kwanghee Choi and Jiatong Shi and Xuankai Chang and Jee-weon Jung and Shinji Watanabe},
12 booktitle={Proceedings of the Annual Conference of the International Speech Communication Association (INTERSPEECH)},
13 year={2024},
14 month={9},
15 pdf="https://arxiv.org/pdf/2401.16658",
16}1@inproceedings{owsm,
2 title={Reproducing Whisper-Style Training Using An Open-Source Toolkit And Publicly Available Data},
3 author={Yifan Peng and Jinchuan Tian and Brian Yan and Dan Berrebbi and Xuankai Chang and Xinjian Li and Jiatong Shi and Siddhant Arora and William Chen and Roshan Sharma and Wangyou Zhang and Yui Sudo and Muhammad Shakeel and Jee-weon Jung and Soumi Maiti and Shinji Watanabe},
4 booktitle={Proceedings of the IEEE Automatic Speech Recognition and Understanding Workshop (ASRU)},
5 year={2023},
6 month={12},
7 pdf="https://arxiv.org/pdf/2309.13876",
8}