whisply 0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- whisply-0.3/LICENSE +201 -0
- whisply-0.3/PKG-INFO +226 -0
- whisply-0.3/README.md +193 -0
- whisply-0.3/pyproject.toml +3 -0
- whisply-0.3/setup.cfg +4 -0
- whisply-0.3/setup.py +48 -0
- whisply-0.3/whisply/__init__.py +0 -0
- whisply-0.3/whisply/cli.py +221 -0
- whisply-0.3/whisply/download_utils.py +79 -0
- whisply-0.3/whisply/enhance_annotations.py +72 -0
- whisply-0.3/whisply/little_helper.py +436 -0
- whisply-0.3/whisply/models.py +107 -0
- whisply-0.3/whisply/transcription.py +699 -0
- whisply-0.3/whisply.egg-info/PKG-INFO +226 -0
- whisply-0.3/whisply.egg-info/SOURCES.txt +17 -0
- whisply-0.3/whisply.egg-info/dependency_links.txt +1 -0
- whisply-0.3/whisply.egg-info/entry_points.txt +2 -0
- whisply-0.3/whisply.egg-info/requires.txt +19 -0
- whisply-0.3/whisply.egg-info/top_level.txt +1 -0
whisply-0.3/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
whisply-0.3/PKG-INFO
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: whisply
|
|
3
|
+
Version: 0.3
|
|
4
|
+
Summary: Transcribe, translate, annotate and subtitle audio and video files with OpenAI's Whisper ... fast!
|
|
5
|
+
Home-page: https://github.com/tsmdt/whisply
|
|
6
|
+
Author: Thomas Schmidt, Renat Shigapov
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: typer==0.12.5
|
|
15
|
+
Requires-Dist: faster-whisper==1.0.1
|
|
16
|
+
Requires-Dist: ffmpeg-python==0.2.0
|
|
17
|
+
Requires-Dist: optimum==1.19.1
|
|
18
|
+
Requires-Dist: pyannote.audio==3.1.1
|
|
19
|
+
Requires-Dist: pyannote.core==5.0.0
|
|
20
|
+
Requires-Dist: pyannote.database==5.1.0
|
|
21
|
+
Requires-Dist: pyannote.metrics==3.2.1
|
|
22
|
+
Requires-Dist: pyannote.pipeline==3.0.1
|
|
23
|
+
Requires-Dist: rich==13.7.1
|
|
24
|
+
Requires-Dist: torch==2.3.0
|
|
25
|
+
Requires-Dist: torch-audiomentations==0.11.1
|
|
26
|
+
Requires-Dist: torch-pitch-shift==1.2.4
|
|
27
|
+
Requires-Dist: torchaudio==2.3.0
|
|
28
|
+
Requires-Dist: torchmetrics==1.3.2
|
|
29
|
+
Requires-Dist: transformers==4.39.3
|
|
30
|
+
Requires-Dist: validators==0.28.1
|
|
31
|
+
Requires-Dist: yt-dlp>=2024.07.07
|
|
32
|
+
Requires-Dist: whisperx==3.1.5
|
|
33
|
+
|
|
34
|
+
# whisply
|
|
35
|
+
|
|
36
|
+
<img src="https://github.com/user-attachments/assets/3a15509b-b60e-4581-af87-ecaa8e5089a3" width="25%">
|
|
37
|
+
|
|
38
|
+
*Transcribe, translate, annotate and subtitle audio and video files with OpenAI's [Whisper](https://github.com/openai/whisper) ... fast!*
|
|
39
|
+
|
|
40
|
+
`whisply` combines [faster-whisper](https://github.com/SYSTRAN/faster-whisper) and [insanely-fast-whisper](https://github.com/chenxwh/insanely-fast-whisper) to offer an easy-to-use solution for batch processing files. It also enables word-level speaker annotation by integrating [whisperX](https://github.com/m-bain/whisperX) and [pyannote](https://github.com/pyannote/pyannote-audio).
|
|
41
|
+
|
|
42
|
+
## Table of contents
|
|
43
|
+
|
|
44
|
+
- [Features](#features)
|
|
45
|
+
- [Requirements](#requirements)
|
|
46
|
+
- [Installation](#installation)
|
|
47
|
+
- [Usage](#usage)
|
|
48
|
+
- [Speaker annotation and diarization](#speaker-annotation-and-diarization)
|
|
49
|
+
- [Requirements](#requirements-1)
|
|
50
|
+
- [How speaker annotation works](#how-speaker-annotation-works)
|
|
51
|
+
- [Batch processing](#batch-processing)
|
|
52
|
+
- [Using config files for batch processing](#using-config-files-for-batch-processing)
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
* 🚴♂️ **Performance**: Depending on your hardware `whisply` will use the fastest `Whisper` implementation:
|
|
57
|
+
* CPU: `fast-whisper` or `whisperX`
|
|
58
|
+
* GPU (Nvidia CUDA) and MPS (Metal Performance Shaders, Apple M1-M3): `insanely-fast-whisper` or `whisperX`
|
|
59
|
+
|
|
60
|
+
* ✅ **Auto device selection**: When performing transcription or translation tasks without speaker annotation or subtitling, `faster-whisper` (CPU) or `insanely-fast-whisper` (MPS, Nvidia GPUs) will be selected automatically based on your hardware if you do not provide a device by using the `--device` option.
|
|
61
|
+
|
|
62
|
+
* 🗣️ **Word-level annotations**: If you choose to `--subtitle` or `--annotate`, `whisperX` will be used, which supports word-level segmentation and speaker annotations. Depending on your hardware, `whisperX` can run either on CPU or Nvidia GPU (but not on Apple MPS). Out of the box `whisperX` will not provide timestamps for words containing only numbers (e.g. "1.5" or "2024"): `whisply` fixes those instances through timestamp approximation.
|
|
63
|
+
|
|
64
|
+
* 💬 **Subtitles**: Generating subtitles is customizable. You can specify the number of words per subtitle block (e.g., choosing "5" will generate `.srt` and `.webvtt` files where each subtitle block exactly 5 words per segment with the corresponding timestamps).
|
|
65
|
+
|
|
66
|
+
* 🧺 **Batch processing**: `whisply` can process single files, whole folders, URLs or a combination of all by combining paths in a `.list` document. See the [Batch processing](#batch-processing) section for more information.
|
|
67
|
+
|
|
68
|
+
* ⚙️ **Supported output formats**: `.json` `.txt` `.txt (annotated)` `.srt` `.webvtt` `.vtt` `.rttm`
|
|
69
|
+
|
|
70
|
+
## Requirements
|
|
71
|
+
|
|
72
|
+
* [FFmpeg](https://ffmpeg.org/)
|
|
73
|
+
* \>= Python3.10
|
|
74
|
+
* GPU processing requires:
|
|
75
|
+
* Nvidia GPU (CUDA: cuBLAS and cuDNN 8 for CUDA 12)
|
|
76
|
+
* Apple Metal Performance Shaders (MPS) (Mac M1-M3)
|
|
77
|
+
* Speaker annotation requires a [HuggingFace Access Token](https://huggingface.co/docs/hub/security-tokens)
|
|
78
|
+
|
|
79
|
+
<details>
|
|
80
|
+
<summary><b>GPU Fix</b> for <i>Could not load library libcudnn_ops_infer.so.8.</i> (<b>click to expand</b>)</summary>
|
|
81
|
+
<br>If you use <b>whisply</b> on a Linux system with a Nivida GPU and get this error:<br><br>
|
|
82
|
+
|
|
83
|
+
```shell
|
|
84
|
+
"Could not load library libcudnn_ops_infer.so.8. Error: libcudnn_ops_infer.so.8: cannot open shared object file: No such file or directory"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Run the following line in your CLI:
|
|
88
|
+
|
|
89
|
+
```shell
|
|
90
|
+
export LD_LIBRARY_PATH=`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + ":" + os.path.dirname(nvidia.cudnn.lib.__file__))'`
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Add this line to your Python environment to make it permanent:
|
|
94
|
+
|
|
95
|
+
```shell
|
|
96
|
+
echo "export LD_LIBRARY_PATH=\`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + \":\" + os.path.dirname(nvidia.cudnn.lib.__file__))'\`" >> path/to/your/python/env
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For more information please refer to the <a href="https://github.com/SYSTRAN/faster-whisper" target="_blank">faster-whisper</a> GitHub page.
|
|
100
|
+
|
|
101
|
+
</details>
|
|
102
|
+
|
|
103
|
+
## Installation
|
|
104
|
+
|
|
105
|
+
**1. Install `ffmpeg`**
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
--- macOS ---
|
|
109
|
+
brew install ffmpeg
|
|
110
|
+
|
|
111
|
+
--- Linux ---
|
|
112
|
+
sudo apt-get update
|
|
113
|
+
sudo apt-get install ffmpeg
|
|
114
|
+
|
|
115
|
+
--- Windows ----
|
|
116
|
+
https://ffmpeg.org/download.html
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**2. Clone this repository and change to project folder**
|
|
120
|
+
|
|
121
|
+
```shell
|
|
122
|
+
git clone https://github.com/tsmdt/whisply.git
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```shell
|
|
126
|
+
cd whisply
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**3. Create a Python virtual environment**
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
python3.11 -m venv venv
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**4. Activate the Python virtual environment**
|
|
136
|
+
|
|
137
|
+
```shell
|
|
138
|
+
source venv/bin/activate
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**5. Install `whisply` with `pip`**
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
pip install .
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Usage
|
|
148
|
+
|
|
149
|
+
```shell
|
|
150
|
+
Usage: whisply [OPTIONS]
|
|
151
|
+
|
|
152
|
+
WHISPLY 💬 Transcribe, translate, annotate and subtitle audio and video files with OpenAI's Whisper ... fast!
|
|
153
|
+
|
|
154
|
+
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
155
|
+
│ --files -f TEXT Path to file, folder, URL or .list to process. [default: None] │
|
|
156
|
+
│ --output_dir -o DIRECTORY Folder where transcripts should be saved. [default: transcriptions] │
|
|
157
|
+
│ --device -d [auto|cpu|gpu|mps] Select the computation device: CPU, GPU (NVIDIA), or MPS (Mac M1-M3). [default: auto] │
|
|
158
|
+
│ --model -m TEXT Whisper model to use (List models via --list_models). [default: large-v2] │
|
|
159
|
+
│ --lang -l TEXT Language of provided file(s) ("en", "de") (Default: auto-detection). [default: None] │
|
|
160
|
+
│ --annotate -a Enable speaker annotation (Saves .rttm). │
|
|
161
|
+
│ --hf_token -hf TEXT HuggingFace Access token required for speaker annotation. [default: None] │
|
|
162
|
+
│ --translate -t Translate transcription to English. │
|
|
163
|
+
│ --subtitle -s Create subtitles (Saves .srt, .vtt and .webvtt). │
|
|
164
|
+
│ --sub_length INTEGER Subtitle segment length in words [default: 5] │
|
|
165
|
+
│ --verbose -v Print text chunks during transcription. │
|
|
166
|
+
│ --config PATH Path to configuration file. [default: None] │
|
|
167
|
+
│ --list_filetypes List supported audio and video file types. │
|
|
168
|
+
│ --list_models List available models. │
|
|
169
|
+
│ --install-completion Install completion for the current shell. │
|
|
170
|
+
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
|
|
171
|
+
│ --help Show this message and exit. │
|
|
172
|
+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Speaker annotation and diarization
|
|
176
|
+
|
|
177
|
+
#### Requirements
|
|
178
|
+
|
|
179
|
+
In order to annotate speakers using `--annotate` you need to provide a valid [HuggingFace](https://huggingface.co) access token using the `--hf_token` option. Additionally, you must accept the terms and conditions for both version 3.0 and version 3.1 of the `pyannote` segmentation model. For detailed instructions, refer to the *Requirements* section on the [pyannote model page on HuggingFace](https://huggingface.co/pyannote/speaker-diarization-3.1).
|
|
180
|
+
|
|
181
|
+
#### How speaker annotation works
|
|
182
|
+
|
|
183
|
+
`whisply` uses [whisperX](https://github.com/m-bain/whisperX) for speaker diarization and annotation. Instead of returning chunk-level timestamps like the standard `Whisper` implementation `whisperX` is able to return word-level timestamps as well as annotating speakers word by word, thus returning much more precise annotations.
|
|
184
|
+
|
|
185
|
+
Out of the box `whisperX` will not provide timestamps for words containing only numbers (e.g. "1.5" or "2024"): `whisply` fixes those instances through timestamp approximation. Other known limitations of `whisperX` include:
|
|
186
|
+
|
|
187
|
+
* inaccurate speaker diarization if multiple speakers talk at the same time
|
|
188
|
+
* to provide word-level timestamps and annotations `whisperX` uses language specific alignment models; out of the box `whisperX` supports these languages: `en, fr, de, es, it, ja, zh, nl, uk, pt`.
|
|
189
|
+
|
|
190
|
+
Refer to the [whisperX GitHub page](https://github.com/m-bain/whisperX) for more information.
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
### Batch processing
|
|
194
|
+
|
|
195
|
+
Instead of providing a file, folder or URL by using the `--files` option you can pass a `.list` with a mix of files, folders and URLs for processing.
|
|
196
|
+
|
|
197
|
+
Example:
|
|
198
|
+
|
|
199
|
+
```shell
|
|
200
|
+
$ cat my_files.list
|
|
201
|
+
|
|
202
|
+
video_01.mp4
|
|
203
|
+
video_02.mp4
|
|
204
|
+
./my_files/
|
|
205
|
+
https://youtu.be/KtOayYXEsN4?si=-0MS6KXbEWXA7dqo
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Using config files for batch processing
|
|
209
|
+
|
|
210
|
+
You can provide a `.json` config file by using the `--config` option which makes batch processing easy. An example config looks like this:
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
{
|
|
214
|
+
"files": "./files/my_files.list", # Path to your files
|
|
215
|
+
"output_dir": "./transcriptions", # Output folder where transcriptions are saved
|
|
216
|
+
"device": "auto", # AUTO, GPU, MPS or CPU
|
|
217
|
+
"model": "large-v3-turbo", # Whisper model to use
|
|
218
|
+
"lang": null, # Null for auto-detection or language codes ("en", "de", ...)
|
|
219
|
+
"annotate": false, # Annotate speakers
|
|
220
|
+
"hf_token": "HuggingFace Access Token", # Your HuggingFace Access Token (needed for annotations)
|
|
221
|
+
"translate": false, # Translate to English
|
|
222
|
+
"subtitle": false, # Subtitle file(s)
|
|
223
|
+
"sub_length": 10, # Length of each subtitle block in number of words
|
|
224
|
+
"verbose": false # Print transcription segments while processing
|
|
225
|
+
}
|
|
226
|
+
```
|
whisply-0.3/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# whisply
|
|
2
|
+
|
|
3
|
+
<img src="https://github.com/user-attachments/assets/3a15509b-b60e-4581-af87-ecaa8e5089a3" width="25%">
|
|
4
|
+
|
|
5
|
+
*Transcribe, translate, annotate and subtitle audio and video files with OpenAI's [Whisper](https://github.com/openai/whisper) ... fast!*
|
|
6
|
+
|
|
7
|
+
`whisply` combines [faster-whisper](https://github.com/SYSTRAN/faster-whisper) and [insanely-fast-whisper](https://github.com/chenxwh/insanely-fast-whisper) to offer an easy-to-use solution for batch processing files. It also enables word-level speaker annotation by integrating [whisperX](https://github.com/m-bain/whisperX) and [pyannote](https://github.com/pyannote/pyannote-audio).
|
|
8
|
+
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
- [Requirements](#requirements)
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Usage](#usage)
|
|
15
|
+
- [Speaker annotation and diarization](#speaker-annotation-and-diarization)
|
|
16
|
+
- [Requirements](#requirements-1)
|
|
17
|
+
- [How speaker annotation works](#how-speaker-annotation-works)
|
|
18
|
+
- [Batch processing](#batch-processing)
|
|
19
|
+
- [Using config files for batch processing](#using-config-files-for-batch-processing)
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
* 🚴♂️ **Performance**: Depending on your hardware `whisply` will use the fastest `Whisper` implementation:
|
|
24
|
+
* CPU: `fast-whisper` or `whisperX`
|
|
25
|
+
* GPU (Nvidia CUDA) and MPS (Metal Performance Shaders, Apple M1-M3): `insanely-fast-whisper` or `whisperX`
|
|
26
|
+
|
|
27
|
+
* ✅ **Auto device selection**: When performing transcription or translation tasks without speaker annotation or subtitling, `faster-whisper` (CPU) or `insanely-fast-whisper` (MPS, Nvidia GPUs) will be selected automatically based on your hardware if you do not provide a device by using the `--device` option.
|
|
28
|
+
|
|
29
|
+
* 🗣️ **Word-level annotations**: If you choose to `--subtitle` or `--annotate`, `whisperX` will be used, which supports word-level segmentation and speaker annotations. Depending on your hardware, `whisperX` can run either on CPU or Nvidia GPU (but not on Apple MPS). Out of the box `whisperX` will not provide timestamps for words containing only numbers (e.g. "1.5" or "2024"): `whisply` fixes those instances through timestamp approximation.
|
|
30
|
+
|
|
31
|
+
* 💬 **Subtitles**: Generating subtitles is customizable. You can specify the number of words per subtitle block (e.g., choosing "5" will generate `.srt` and `.webvtt` files where each subtitle block exactly 5 words per segment with the corresponding timestamps).
|
|
32
|
+
|
|
33
|
+
* 🧺 **Batch processing**: `whisply` can process single files, whole folders, URLs or a combination of all by combining paths in a `.list` document. See the [Batch processing](#batch-processing) section for more information.
|
|
34
|
+
|
|
35
|
+
* ⚙️ **Supported output formats**: `.json` `.txt` `.txt (annotated)` `.srt` `.webvtt` `.vtt` `.rttm`
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
* [FFmpeg](https://ffmpeg.org/)
|
|
40
|
+
* \>= Python3.10
|
|
41
|
+
* GPU processing requires:
|
|
42
|
+
* Nvidia GPU (CUDA: cuBLAS and cuDNN 8 for CUDA 12)
|
|
43
|
+
* Apple Metal Performance Shaders (MPS) (Mac M1-M3)
|
|
44
|
+
* Speaker annotation requires a [HuggingFace Access Token](https://huggingface.co/docs/hub/security-tokens)
|
|
45
|
+
|
|
46
|
+
<details>
|
|
47
|
+
<summary><b>GPU Fix</b> for <i>Could not load library libcudnn_ops_infer.so.8.</i> (<b>click to expand</b>)</summary>
|
|
48
|
+
<br>If you use <b>whisply</b> on a Linux system with a Nivida GPU and get this error:<br><br>
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
"Could not load library libcudnn_ops_infer.so.8. Error: libcudnn_ops_infer.so.8: cannot open shared object file: No such file or directory"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Run the following line in your CLI:
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
export LD_LIBRARY_PATH=`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + ":" + os.path.dirname(nvidia.cudnn.lib.__file__))'`
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Add this line to your Python environment to make it permanent:
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
echo "export LD_LIBRARY_PATH=\`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + \":\" + os.path.dirname(nvidia.cudnn.lib.__file__))'\`" >> path/to/your/python/env
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For more information please refer to the <a href="https://github.com/SYSTRAN/faster-whisper" target="_blank">faster-whisper</a> GitHub page.
|
|
67
|
+
|
|
68
|
+
</details>
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
**1. Install `ffmpeg`**
|
|
73
|
+
|
|
74
|
+
```markdown
|
|
75
|
+
--- macOS ---
|
|
76
|
+
brew install ffmpeg
|
|
77
|
+
|
|
78
|
+
--- Linux ---
|
|
79
|
+
sudo apt-get update
|
|
80
|
+
sudo apt-get install ffmpeg
|
|
81
|
+
|
|
82
|
+
--- Windows ----
|
|
83
|
+
https://ffmpeg.org/download.html
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**2. Clone this repository and change to project folder**
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
git clone https://github.com/tsmdt/whisply.git
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
cd whisply
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**3. Create a Python virtual environment**
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
python3.11 -m venv venv
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**4. Activate the Python virtual environment**
|
|
103
|
+
|
|
104
|
+
```shell
|
|
105
|
+
source venv/bin/activate
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**5. Install `whisply` with `pip`**
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
pip install .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
```shell
|
|
117
|
+
Usage: whisply [OPTIONS]
|
|
118
|
+
|
|
119
|
+
WHISPLY 💬 Transcribe, translate, annotate and subtitle audio and video files with OpenAI's Whisper ... fast!
|
|
120
|
+
|
|
121
|
+
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
122
|
+
│ --files -f TEXT Path to file, folder, URL or .list to process. [default: None] │
|
|
123
|
+
│ --output_dir -o DIRECTORY Folder where transcripts should be saved. [default: transcriptions] │
|
|
124
|
+
│ --device -d [auto|cpu|gpu|mps] Select the computation device: CPU, GPU (NVIDIA), or MPS (Mac M1-M3). [default: auto] │
|
|
125
|
+
│ --model -m TEXT Whisper model to use (List models via --list_models). [default: large-v2] │
|
|
126
|
+
│ --lang -l TEXT Language of provided file(s) ("en", "de") (Default: auto-detection). [default: None] │
|
|
127
|
+
│ --annotate -a Enable speaker annotation (Saves .rttm). │
|
|
128
|
+
│ --hf_token -hf TEXT HuggingFace Access token required for speaker annotation. [default: None] │
|
|
129
|
+
│ --translate -t Translate transcription to English. │
|
|
130
|
+
│ --subtitle -s Create subtitles (Saves .srt, .vtt and .webvtt). │
|
|
131
|
+
│ --sub_length INTEGER Subtitle segment length in words [default: 5] │
|
|
132
|
+
│ --verbose -v Print text chunks during transcription. │
|
|
133
|
+
│ --config PATH Path to configuration file. [default: None] │
|
|
134
|
+
│ --list_filetypes List supported audio and video file types. │
|
|
135
|
+
│ --list_models List available models. │
|
|
136
|
+
│ --install-completion Install completion for the current shell. │
|
|
137
|
+
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
|
|
138
|
+
│ --help Show this message and exit. │
|
|
139
|
+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Speaker annotation and diarization
|
|
143
|
+
|
|
144
|
+
#### Requirements
|
|
145
|
+
|
|
146
|
+
In order to annotate speakers using `--annotate` you need to provide a valid [HuggingFace](https://huggingface.co) access token using the `--hf_token` option. Additionally, you must accept the terms and conditions for both version 3.0 and version 3.1 of the `pyannote` segmentation model. For detailed instructions, refer to the *Requirements* section on the [pyannote model page on HuggingFace](https://huggingface.co/pyannote/speaker-diarization-3.1).
|
|
147
|
+
|
|
148
|
+
#### How speaker annotation works
|
|
149
|
+
|
|
150
|
+
`whisply` uses [whisperX](https://github.com/m-bain/whisperX) for speaker diarization and annotation. Instead of returning chunk-level timestamps like the standard `Whisper` implementation `whisperX` is able to return word-level timestamps as well as annotating speakers word by word, thus returning much more precise annotations.
|
|
151
|
+
|
|
152
|
+
Out of the box `whisperX` will not provide timestamps for words containing only numbers (e.g. "1.5" or "2024"): `whisply` fixes those instances through timestamp approximation. Other known limitations of `whisperX` include:
|
|
153
|
+
|
|
154
|
+
* inaccurate speaker diarization if multiple speakers talk at the same time
|
|
155
|
+
* to provide word-level timestamps and annotations `whisperX` uses language specific alignment models; out of the box `whisperX` supports these languages: `en, fr, de, es, it, ja, zh, nl, uk, pt`.
|
|
156
|
+
|
|
157
|
+
Refer to the [whisperX GitHub page](https://github.com/m-bain/whisperX) for more information.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
### Batch processing
|
|
161
|
+
|
|
162
|
+
Instead of providing a file, folder or URL by using the `--files` option you can pass a `.list` with a mix of files, folders and URLs for processing.
|
|
163
|
+
|
|
164
|
+
Example:
|
|
165
|
+
|
|
166
|
+
```shell
|
|
167
|
+
$ cat my_files.list
|
|
168
|
+
|
|
169
|
+
video_01.mp4
|
|
170
|
+
video_02.mp4
|
|
171
|
+
./my_files/
|
|
172
|
+
https://youtu.be/KtOayYXEsN4?si=-0MS6KXbEWXA7dqo
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Using config files for batch processing
|
|
176
|
+
|
|
177
|
+
You can provide a `.json` config file by using the `--config` option which makes batch processing easy. An example config looks like this:
|
|
178
|
+
|
|
179
|
+
```markdown
|
|
180
|
+
{
|
|
181
|
+
"files": "./files/my_files.list", # Path to your files
|
|
182
|
+
"output_dir": "./transcriptions", # Output folder where transcriptions are saved
|
|
183
|
+
"device": "auto", # AUTO, GPU, MPS or CPU
|
|
184
|
+
"model": "large-v3-turbo", # Whisper model to use
|
|
185
|
+
"lang": null, # Null for auto-detection or language codes ("en", "de", ...)
|
|
186
|
+
"annotate": false, # Annotate speakers
|
|
187
|
+
"hf_token": "HuggingFace Access Token", # Your HuggingFace Access Token (needed for annotations)
|
|
188
|
+
"translate": false, # Translate to English
|
|
189
|
+
"subtitle": false, # Subtitle file(s)
|
|
190
|
+
"sub_length": 10, # Length of each subtitle block in number of words
|
|
191
|
+
"verbose": false # Print transcription segments while processing
|
|
192
|
+
}
|
|
193
|
+
```
|
whisply-0.3/setup.cfg
ADDED