ONNX
deskpai commited on
Commit
2dec448
Β·
verified Β·
1 Parent(s): c0d2aac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +166 -3
README.md CHANGED
@@ -1,3 +1,166 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🎯 CTC Forced Aligner
2
+
3
+ We are open-sourcing the CTC forced aligner used in [Deskpai](https://www.deskpai.com).
4
+
5
+ With focus on production-ready model inference, it supports 18 different alignment models, including multilingual models(German, English, Spanish, French and Italian etc), and provides SRT and WebVTT alignment and generation out of box. It supports both ONNXRuntime and PyTorch for model serving.
6
+
7
+ ## πŸš€ Installation
8
+
9
+ - CPU inference via ONNXRuntime
10
+
11
+ ```bash
12
+ pip install ctc_forced_aligner
13
+ ```
14
+
15
+ - GPU inference via ONNXRuntime
16
+
17
+ ```bash
18
+ pip install ctc_forced_aligner[gpu]
19
+ ```
20
+
21
+ - CPU/GPU inference via PyTorch
22
+
23
+ ```bash
24
+ pip install ctc_forced_aligner[torch]
25
+ ```
26
+
27
+ - Install all dependencies
28
+
29
+ ```bash
30
+ pip install ctc_forced_aligner[all]
31
+ ```
32
+
33
+ ## πŸ“ Sample Inference Code
34
+
35
+ - CPU/GPU inference via ONNXRuntime
36
+
37
+ ```python
38
+ from ctc_forced_aligner import AlignmentSingleton
39
+ alignment_service = AlignmentSingleton()
40
+ input_audio_path = "audio.mp3"
41
+ input_text_path = "input.txt"
42
+ output_srt_path = "output.srt"
43
+ ret = alignment_service.generate_srt(input_audio_path,
44
+ input_text_path,
45
+ output_srt_path)
46
+ if ret:
47
+ print(f"Aligned SRT is generated at {output_srt_path}")
48
+ output_vtt_path = "output.vtt"
49
+ ret = alignment_service.generate_webvtt(input_audio_path,
50
+ input_text_path,
51
+ output_vtt_path)
52
+ if ret:
53
+ print(f"aligned VTT is generated to {output_vtt_path}")
54
+ ```
55
+
56
+ - CPU/GPU inference via PyTorch
57
+
58
+ ```python
59
+ from ctc_forced_aligner import AlignmentTorch
60
+ at = AlignmentTorch()
61
+ ret = at.generate_srt(input_audio_path, input_text_path, output_srt_path)
62
+ if ret:
63
+ print(f"aligned srt is generated to {output_srt_path}")
64
+ ret = at.generate_webvtt(input_audio_path, input_text_path, output_vtt_path)
65
+ if ret:
66
+ print(f"aligned VTT is generated to {output_vtt_path}")
67
+ ```
68
+
69
+ - Inference with multiple models
70
+
71
+ ```python
72
+ from ctc_forced_aligner import AlignmentTorch
73
+ at = AlignmentTorch()
74
+ ret = at.generate_srt(input_audio_path, input_text_path, output_srt_path, model_type='WAV2VEC2_ASR_BASE_960H')
75
+ if ret:
76
+ print(f"aligned srt is generated to {output_srt_path}")
77
+ ret = at.generate_webvtt(input_audio_path, input_text_path, output_vtt_path, model_type='WAV2VEC2_ASR_BASE_960H')
78
+ if ret:
79
+ print(f"aligned VTT is generated to {output_vtt_path}")
80
+ ```
81
+
82
+ ## Models Supported
83
+
84
+ ### βœ… Wav2Vec2 Models
85
+
86
+ These are fine-tuned models with a **CTC-based ASR head**:
87
+ - `WAV2VEC2_ASR_BASE_960H`
88
+ - `WAV2VEC2_ASR_BASE_100H`
89
+ - `WAV2VEC2_ASR_BASE_10M`
90
+ - `WAV2VEC2_ASR_LARGE_10M`
91
+ - `WAV2VEC2_ASR_LARGE_100H`
92
+ - `WAV2VEC2_ASR_LARGE_960H`
93
+ - `WAV2VEC2_ASR_LARGE_LV60K_10M`
94
+ - `WAV2VEC2_ASR_LARGE_LV60K_100H`
95
+ - `WAV2VEC2_ASR_LARGE_LV60K_960H`
96
+
97
+ ### βœ… VoxPopuli Models (Multilingual)
98
+
99
+ These models are fine-tuned for **specific languages**:
100
+ - `VOXPOPULI_ASR_BASE_10K_DE` (German ASR)
101
+ - `VOXPOPULI_ASR_BASE_10K_EN` (English ASR)
102
+ - `VOXPOPULI_ASR_BASE_10K_ES` (Spanish ASR)
103
+ - `VOXPOPULI_ASR_BASE_10K_FR` (French ASR)
104
+ - `VOXPOPULI_ASR_BASE_10K_IT` (Italian ASR)
105
+
106
+ - Fine-tuned on **VoxPopuli** speech corpus.
107
+
108
+ ### βœ… HuBERT Models
109
+ - `HUBERT_ASR_LARGE`
110
+ - `HUBERT_ASR_XLARGE`
111
+
112
+
113
+ ## πŸ’‘ Which One and How to Use?
114
+
115
+ **For PyTorch serving**, use `AlignmentTorch` or `AlignmentTorchSingleton`.
116
+
117
+ - **For English ASR** β†’ `WAV2VEC2_ASR_LARGE_960H` or `HUBERT_ASR_LARGE`
118
+ - **For multilingual ASR** β†’ `VOXPOPULI_ASR_BASE_10K_*`
119
+ - **For low-resource ASR** β†’ `WAV2VEC2_ASR_BASE_10M` (smallest model)
120
+ - **For best accuracy** β†’ `WAV2VEC2_ASR_LARGE_LV60K_960H` or `HUBERT_ASR_XLARGE`
121
+
122
+ **For ONNXRuntime serving** with minimum dependencies, use `Alignment` or `AlignmentSingleton`.
123
+
124
+ Please contact [us](mailto:dev@deskpai.com) if you want to integrate your model into this package.
125
+
126
+ ## πŸ“„ License
127
+
128
+ ### Code
129
+
130
+ - This project includes code from [pytorch/audio](https://github.com/pytorch/audio), licensed under the `BSD-2-Clause` license.
131
+ - This project includes code from [MahmoudAshraf97/ctc-forced-aligner](https://github.com/MahmoudAshraf97/ctc-forced-aligner), licensed under the `BSD` license.`This project is licensed under the BSD License, note that the default model has CC-BY-NC 4.0 License, so make sure to use a different model for commercial usage.`
132
+ - Modifications and additional code are contributed by [Deskpai.com](https://www.deskpai.com) and licensed under the [DOSL-1.0 license](https://github.com/deskpai/deskpai/blob/main/LICENSE).
133
+
134
+ ### Model
135
+
136
+ - The following models are developed by Meta AI (formerly Facebook AI) under `MIT License` and redistributed with the same license.
137
+ - `WAV2VEC2_ASR_BASE_960H`
138
+ - `WAV2VEC2_ASR_BASE_100H`
139
+ - `WAV2VEC2_ASR_BASE_10M`
140
+ - `WAV2VEC2_ASR_LARGE_10M`
141
+ - `WAV2VEC2_ASR_LARGE_100H`
142
+ - `WAV2VEC2_ASR_LARGE_960H`
143
+ - `WAV2VEC2_ASR_LARGE_LV60K_10M`
144
+ - `WAV2VEC2_ASR_LARGE_LV60K_100H`
145
+ - `WAV2VEC2_ASR_LARGE_LV60K_960H`
146
+ - VoxPopuli and HuBERT models are also developed by Meta AI and are generally released under the MIT License. The specific licensing for these models can be found in their respective repositories or documentation. Please check it on your own.
147
+ - `VOXPOPULI_ASR_BASE_10K_DE`
148
+ - `VOXPOPULI_ASR_BASE_10K_EN`
149
+ - `VOXPOPULI_ASR_BASE_10K_ES`
150
+ - `VOXPOPULI_ASR_BASE_10K_FR`
151
+ - `VOXPOPULI_ASR_BASE_10K_IT`
152
+ - `HUBERT_ASR_LARGE`
153
+ - `HUBERT_ASR_XLARGE`
154
+ - The model `MMS_FA` is published by the authors of Scaling Speech Technology to 1,000+ Languages Pratap et al., 2023 under `CC-BY-NC 4.0 License`.
155
+ - The onnx model weights are created by [Deskpai.com](https://www.deskpai.com) based on the model of [MahmoudAshraf/mms-300m-1130-forced-aligner](https://huggingface.co/MahmoudAshraf/mms-300m-1130-forced-aligner) and under `CC-BY-NC 4.0 License`.
156
+
157
+ πŸ“ Note: It's essential to verify the licensing terms from the official repositories or documentation before using these models.
158
+
159
+ ## πŸ™ Reference
160
+
161
+ - [LESS PEAKY AND MORE ACCURATE CTC FORCED ALIGNMENT BY LABEL PRIORS](https://arxiv.org/pdf/2406.02560)
162
+ - [Montreal Forced Aligner User Guide](https://montreal-forced-aligner.readthedocs.io/en/stable/user_guide/index.html)
163
+ - [Forced Alignment with Wav2Vec2](https://pytorch.org/audio/main/tutorials/forced_alignment_tutorial.html)
164
+ - [NeuFA: Neural Network Based End-to-End Forced Aligner](https://arxiv.org/abs/2203.16838)
165
+ - [Tradition or Innovation: A Comparison of Modern ASR Methods for Forced
166
+ Alignment](https://arxiv.org/pdf/2406.19363v1)