Compare commits
106 Commits
36160c1e7e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91c8307aa6 | ||
|
|
b024972a56 | ||
|
|
8ae82c8372 | ||
|
|
e0c3a9ed34 | ||
|
|
a67e0e47ae | ||
|
|
1eb9a8004c | ||
|
|
a342b028b7 | ||
|
|
5090cc9d0d | ||
|
|
09cd57e7f3 | ||
|
|
16141e65d9 | ||
|
|
06d32bf0c1 | ||
|
|
30d6043e90 | ||
|
|
22c75d0cc3 | ||
|
|
092067208b | ||
|
|
6ffcbdfbc2 | ||
|
|
52695567c9 | ||
|
|
c6b28ed3a0 | ||
|
|
4ab646035f | ||
|
|
f144e4c83d | ||
|
|
3aec421849 | ||
|
|
64b9f244bd | ||
|
|
00efce1696 | ||
|
|
ad3c83045b | ||
|
|
72ff979a2e | ||
|
|
615de0d2d9 | ||
|
|
44f7e58947 | ||
|
|
ebcfd6b964 | ||
|
|
19329a3611 | ||
|
|
65094b779e | ||
|
|
9641d5f56a | ||
|
|
e1a218fab1 | ||
|
|
3084409633 | ||
|
|
5a0541ea7d | ||
|
|
e94711bb5c | ||
|
|
0048844f54 | ||
|
|
a49097e655 | ||
|
|
81086f6d33 | ||
|
|
f697945691 | ||
|
|
727ab81f31 | ||
|
|
0285d46f6f | ||
|
|
ad388cd394 | ||
|
|
4a41746e55 | ||
|
|
1e6eb967c9 | ||
|
|
f0ff12965a | ||
|
|
5871858a5f | ||
|
|
e87fbf8a49 | ||
|
|
7b271da035 | ||
|
|
1562b02345 | ||
|
|
1ce16652ee | ||
|
|
857be6f621 | ||
|
|
1a1eb1a027 | ||
|
|
5c17de1771 | ||
|
|
0f55c436fe | ||
|
|
e786e26f75 | ||
|
|
687db319e0 | ||
|
|
171d90dd1f | ||
|
|
0e051a5b77 | ||
|
|
2a37390fed | ||
|
|
3b4a6aa1c2 | ||
|
|
c7cb2aa8d4 | ||
|
|
c0d93d0829 | ||
|
|
19c294f978 | ||
|
|
fee52c9229 | ||
|
|
efc4f61d85 | ||
|
|
ad58ba26ab | ||
|
|
20d4e9418b | ||
|
|
d4222da952 | ||
|
|
1bb7e33b93 | ||
|
|
2a00621564 | ||
|
|
a150adcc19 | ||
|
|
ae1e6d9883 | ||
|
|
cf7c021573 | ||
|
|
4db549b800 | ||
|
|
c99feb22dc | ||
|
|
723cb97483 | ||
|
|
6a2da9a95c | ||
|
|
6a1d331d66 | ||
|
|
2d7c984bfc | ||
|
|
8e5c747ab5 | ||
|
|
32b962bed8 | ||
|
|
53d247b0bb | ||
|
|
91f948b0d6 | ||
|
|
5d8f3e2d90 | ||
|
|
d889345e07 | ||
|
|
5d203d2757 | ||
|
|
a3dcb90081 | ||
|
|
89a4c7f1f0 | ||
|
|
6f9d68dd6b | ||
|
|
68df3214ba | ||
|
|
67cce3f552 | ||
|
|
8340e04dc6 | ||
|
|
8cf5d5a4b3 | ||
|
|
32dc625f11 | ||
|
|
e06511f96b | ||
|
|
338a725ff8 | ||
|
|
f893113759 | ||
|
|
2b51a97e61 | ||
|
|
358d373691 | ||
|
|
3adcc12d0f | ||
|
|
2b53dee6b6 | ||
|
|
06d24056e9 | ||
|
|
e9a082dcf2 | ||
|
|
051b3350e5 | ||
|
|
746f2698db | ||
|
|
a5d03e55fa | ||
|
|
9fa1989073 |
14
.gitignore
vendored
14
.gitignore
vendored
@@ -1 +1,15 @@
|
||||
# Byte-compiled / Optimized / DLL Files
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
__pycache__/
|
||||
|
||||
# Distribution / Packaging
|
||||
venv/
|
||||
|
||||
# Unit Test
|
||||
.pytest_cache/
|
||||
|
||||
# Ignore IDE, Editor Files
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
31
CONTRIBUTING.md
Normal file
31
CONTRIBUTING.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Contributing to faster-whisper
|
||||
|
||||
Contributions are welcome! Here are some pointers to help you install the library for development and validate your changes before submitting a pull request.
|
||||
|
||||
## Install the library for development
|
||||
|
||||
We recommend installing the module in editable mode with the `dev` extra requirements:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/SYSTRAN/faster-whisper.git
|
||||
cd faster-whisper/
|
||||
pip install -e .[dev]
|
||||
```
|
||||
|
||||
## Validate the changes before creating a pull request
|
||||
|
||||
1. Make sure the existing tests are still passing (and consider adding new tests as well!):
|
||||
|
||||
```bash
|
||||
pytest tests/
|
||||
```
|
||||
|
||||
2. Reformat and validate the code with the following tools:
|
||||
|
||||
```bash
|
||||
black .
|
||||
isort .
|
||||
flake8 .
|
||||
```
|
||||
|
||||
These steps are also run automatically in the CI when you open the pull request.
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Guillaume Klein
|
||||
Copyright (c) 2023 SYSTRAN
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
include faster_whisper/assets/silero_vad.onnx
|
||||
include requirements.txt
|
||||
include requirements.conversion.txt
|
||||
|
||||
188
README.md
188
README.md
@@ -1,4 +1,4 @@
|
||||
[](https://github.com/guillaumekln/faster-whisper/actions?query=workflow%3ACI) [](https://badge.fury.io/py/faster-whisper)
|
||||
[](https://github.com/SYSTRAN/faster-whisper/actions?query=workflow%3ACI) [](https://badge.fury.io/py/faster-whisper)
|
||||
|
||||
# Faster Whisper transcription with CTranslate2
|
||||
|
||||
@@ -8,11 +8,13 @@ This implementation is up to 4 times faster than [openai/whisper](https://github
|
||||
|
||||
## Benchmark
|
||||
|
||||
### Whisper
|
||||
|
||||
For reference, here's the time and memory usage that are required to transcribe [**13 minutes**](https://www.youtube.com/watch?v=0u7tTptBo9I) of audio using different implementations:
|
||||
|
||||
* [openai/whisper](https://github.com/openai/whisper)@[6dea21fd](https://github.com/openai/whisper/commit/6dea21fd7f7253bfe450f1e2512a0fe47ee2d258)
|
||||
* [whisper.cpp](https://github.com/ggerganov/whisper.cpp)@[3b010f9](https://github.com/ggerganov/whisper.cpp/commit/3b010f9bed9a6068609e9faf52383aea792b0362)
|
||||
* [faster-whisper](https://github.com/guillaumekln/faster-whisper)@[cce6b53e](https://github.com/guillaumekln/faster-whisper/commit/cce6b53e4554f71172dad188c45f10fb100f6e3e)
|
||||
* [faster-whisper](https://github.com/SYSTRAN/faster-whisper)@[cce6b53e](https://github.com/SYSTRAN/faster-whisper/commit/cce6b53e4554f71172dad188c45f10fb100f6e3e)
|
||||
|
||||
### Large-v2 model on GPU
|
||||
|
||||
@@ -36,6 +38,71 @@ For reference, here's the time and memory usage that are required to transcribe
|
||||
|
||||
*Executed with 8 threads on a Intel(R) Xeon(R) Gold 6226R.*
|
||||
|
||||
|
||||
### Distil-whisper
|
||||
|
||||
| Implementation | Precision | Beam size | Time | Gigaspeech WER |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| distil-whisper/distil-large-v2 | fp16 | 4 |- | 10.36 |
|
||||
| [faster-distil-large-v2](https://huggingface.co/Systran/faster-distil-whisper-large-v2) | fp16 | 5 | - | 10.28 |
|
||||
| distil-whisper/distil-medium.en | fp16 | 4 | - | 11.21 |
|
||||
| [faster-distil-medium.en](https://huggingface.co/Systran/faster-distil-whisper-medium.en) | fp16 | 5 | - | 11.21 |
|
||||
|
||||
*Executed with CUDA 11.4 on a NVIDIA 3090.*
|
||||
|
||||
<details>
|
||||
<summary>testing details (click to expand)</summary>
|
||||
|
||||
For `distil-whisper/distil-large-v2`, the WER is tested with code sample from [link](https://huggingface.co/distil-whisper/distil-large-v2#evaluation). for `faster-distil-whisper`, the WER is tested with setting:
|
||||
```python
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
model_size = "distil-large-v2"
|
||||
# model_size = "distil-medium.en"
|
||||
# Run on GPU with FP16
|
||||
model = WhisperModel(model_size, device="cuda", compute_type="float16")
|
||||
segments, info = model.transcribe("audio.mp3", beam_size=5, language="en")
|
||||
```
|
||||
</details>
|
||||
|
||||
## Requirements
|
||||
|
||||
* Python 3.8 or greater
|
||||
|
||||
Unlike openai-whisper, FFmpeg does **not** need to be installed on the system. The audio is decoded with the Python library [PyAV](https://github.com/PyAV-Org/PyAV) which bundles the FFmpeg libraries in its package.
|
||||
|
||||
### GPU
|
||||
|
||||
GPU execution requires the following NVIDIA libraries to be installed:
|
||||
|
||||
* [cuBLAS for CUDA 11](https://developer.nvidia.com/cublas)
|
||||
* [cuDNN 8 for CUDA 11](https://developer.nvidia.com/cudnn)
|
||||
|
||||
There are multiple ways to install these libraries. The recommended way is described in the official NVIDIA documentation, but we also suggest other installation methods below.
|
||||
|
||||
<details>
|
||||
<summary>Other installation methods (click to expand)</summary>
|
||||
|
||||
#### Use Docker
|
||||
|
||||
The libraries are installed in this official NVIDIA Docker image: `nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04`.
|
||||
|
||||
#### Install with `pip` (Linux only)
|
||||
|
||||
On Linux these libraries can be installed with `pip`. Note that `LD_LIBRARY_PATH` must be set before launching Python.
|
||||
|
||||
```bash
|
||||
pip install nvidia-cublas-cu11 nvidia-cudnn-cu11
|
||||
|
||||
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__))'`
|
||||
```
|
||||
|
||||
#### Download the libraries from Purfview's repository (Windows & Linux)
|
||||
|
||||
Purfview's [whisper-standalone-win](https://github.com/Purfview/whisper-standalone-win) provides the required NVIDIA libraries for Windows & Linux in a [single archive](https://github.com/Purfview/whisper-standalone-win/releases/tag/libs). Decompress the archive and place the libraries in a directory included in the `PATH`.
|
||||
|
||||
</details>
|
||||
|
||||
## Installation
|
||||
|
||||
The module can be installed from [PyPI](https://pypi.org/project/faster-whisper/):
|
||||
@@ -44,32 +111,31 @@ The module can be installed from [PyPI](https://pypi.org/project/faster-whisper/
|
||||
pip install faster-whisper
|
||||
```
|
||||
|
||||
**Other installation methods:**
|
||||
<details>
|
||||
<summary>Other installation methods (click to expand)</summary>
|
||||
|
||||
### Install the master branch
|
||||
|
||||
```bash
|
||||
# Install the master branch:
|
||||
pip install --force-reinstall "faster-whisper @ https://github.com/guillaumekln/faster-whisper/archive/refs/heads/master.tar.gz"
|
||||
|
||||
# Install a specific commit:
|
||||
pip install --force-reinstall "faster-whisper @ https://github.com/guillaumekln/faster-whisper/archive/a4f1cc8f11433e454c3934442b5e1a4ed5e865c3.tar.gz"
|
||||
|
||||
# Install for development:
|
||||
git clone https://github.com/guillaumekln/faster-whisper.git
|
||||
pip install -e faster-whisper/
|
||||
pip install --force-reinstall "faster-whisper @ https://github.com/SYSTRAN/faster-whisper/archive/refs/heads/master.tar.gz"
|
||||
```
|
||||
|
||||
### GPU support
|
||||
### Install a specific commit
|
||||
|
||||
GPU execution requires the NVIDIA libraries cuBLAS 11.x and cuDNN 8.x to be installed on the system. Please refer to the [CTranslate2 documentation](https://opennmt.net/CTranslate2/installation.html).
|
||||
```bash
|
||||
pip install --force-reinstall "faster-whisper @ https://github.com/SYSTRAN/faster-whisper/archive/a4f1cc8f11433e454c3934442b5e1a4ed5e865c3.tar.gz"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Usage
|
||||
|
||||
### Library
|
||||
### Faster-whisper
|
||||
|
||||
```python
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
model_size = "large-v2"
|
||||
model_size = "large-v3"
|
||||
|
||||
# Run on GPU with FP16
|
||||
model = WhisperModel(model_size, device="cuda", compute_type="float16")
|
||||
@@ -87,7 +153,33 @@ for segment in segments:
|
||||
print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
|
||||
```
|
||||
|
||||
#### Word-level timestamps
|
||||
**Warning:** `segments` is a *generator* so the transcription only starts when you iterate over it. The transcription can be run to completion by gathering the segments in a list or a `for` loop:
|
||||
|
||||
```python
|
||||
segments, _ = model.transcribe("audio.mp3")
|
||||
segments = list(segments) # The transcription will actually run here.
|
||||
```
|
||||
### Faster Distil-Whisper
|
||||
|
||||
The Distil-Whisper checkpoints are compatible with the Faster-Whisper package. In particular, the latest [distil-large-v3](https://huggingface.co/distil-whisper/distil-large-v3)
|
||||
checkpoint is intrinsically designed to work with the Faster-Whisper transcription algorithm. The following code snippet
|
||||
demonstrates how to run inference with distil-large-v3 on a specified audio file:
|
||||
|
||||
```python
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
model_size = "distil-large-v3"
|
||||
|
||||
model = WhisperModel(model_size, device="cuda", compute_type="float16")
|
||||
segments, info = model.transcribe("audio.mp3", beam_size=5, language="en", condition_on_previous_text=False)
|
||||
|
||||
for segment in segments:
|
||||
print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
|
||||
```
|
||||
|
||||
For more information about the distil-large-v3 model, refer to the original [model card](https://huggingface.co/distil-whisper/distil-large-v3).
|
||||
|
||||
### Word-level timestamps
|
||||
|
||||
```python
|
||||
segments, _ = model.transcribe("audio.mp3", word_timestamps=True)
|
||||
@@ -97,7 +189,7 @@ for segment in segments:
|
||||
print("[%.2fs -> %.2fs] %s" % (word.start, word.end, word.word))
|
||||
```
|
||||
|
||||
#### VAD filter
|
||||
### VAD filter
|
||||
|
||||
The library integrates the [Silero VAD](https://github.com/snakers4/silero-vad) model to filter out parts of the audio without speech:
|
||||
|
||||
@@ -105,33 +197,61 @@ The library integrates the [Silero VAD](https://github.com/snakers4/silero-vad)
|
||||
segments, _ = model.transcribe("audio.mp3", vad_filter=True)
|
||||
```
|
||||
|
||||
The default behavior is conservative and only removes silence longer than 2 seconds. See the available VAD parameters and default values in the function [`get_speech_timestamps`](https://github.com/guillaumekln/faster-whisper/blob/master/faster_whisper/vad.py). They can be customized with the dictionary argument `vad_parameters`:
|
||||
The default behavior is conservative and only removes silence longer than 2 seconds. See the available VAD parameters and default values in the [source code](https://github.com/SYSTRAN/faster-whisper/blob/master/faster_whisper/vad.py). They can be customized with the dictionary argument `vad_parameters`:
|
||||
|
||||
```python
|
||||
segments, _ = model.transcribe("audio.mp3", vad_filter=True, vad_parameters=dict(min_silence_duration_ms=500))
|
||||
segments, _ = model.transcribe(
|
||||
"audio.mp3",
|
||||
vad_filter=True,
|
||||
vad_parameters=dict(min_silence_duration_ms=500),
|
||||
)
|
||||
```
|
||||
|
||||
#### Going further
|
||||
### Logging
|
||||
|
||||
See more model and transcription options in the [`WhisperModel`](https://github.com/guillaumekln/faster-whisper/blob/master/faster_whisper/transcribe.py) class implementation.
|
||||
The library logging level can be configured like this:
|
||||
|
||||
### CLI
|
||||
```python
|
||||
import logging
|
||||
|
||||
You can use [jordimas/whisper-ctranslate2](https://github.com/jordimas/whisper-ctranslate2) to access `faster-whisper` through a CLI interface similar to what is offered by Whisper.
|
||||
logging.basicConfig()
|
||||
logging.getLogger("faster_whisper").setLevel(logging.DEBUG)
|
||||
```
|
||||
|
||||
### Going further
|
||||
|
||||
See more model and transcription options in the [`WhisperModel`](https://github.com/SYSTRAN/faster-whisper/blob/master/faster_whisper/transcribe.py) class implementation.
|
||||
|
||||
## Community integrations
|
||||
|
||||
Here is a non exhaustive list of open-source projects using faster-whisper. Feel free to add your project to the list!
|
||||
|
||||
|
||||
* [WhisperX](https://github.com/m-bain/whisperX) is an award-winning Python library that offers speaker diarization and accurate word-level timestamps using wav2vec2 alignment
|
||||
* [whisper-ctranslate2](https://github.com/Softcatala/whisper-ctranslate2) is a command line client based on faster-whisper and compatible with the original client from openai/whisper.
|
||||
* [whisper-diarize](https://github.com/MahmoudAshraf97/whisper-diarization) is a speaker diarization tool that is based on faster-whisper and NVIDIA NeMo.
|
||||
* [whisper-standalone-win](https://github.com/Purfview/whisper-standalone-win) Standalone CLI executables of faster-whisper for Windows, Linux & macOS.
|
||||
* [asr-sd-pipeline](https://github.com/hedrergudene/asr-sd-pipeline) provides a scalable, modular, end to end multi-speaker speech to text solution implemented using AzureML pipelines.
|
||||
* [Open-Lyrics](https://github.com/zh-plus/Open-Lyrics) is a Python library that transcribes voice files using faster-whisper, and translates/polishes the resulting text into `.lrc` files in the desired language using OpenAI-GPT.
|
||||
* [wscribe](https://github.com/geekodour/wscribe) is a flexible transcript generation tool supporting faster-whisper, it can export word level transcript and the exported transcript then can be edited with [wscribe-editor](https://github.com/geekodour/wscribe-editor)
|
||||
* [aTrain](https://github.com/BANDAS-Center/aTrain) is a graphical user interface implementation of faster-whisper developed at the BANDAS-Center at the University of Graz for transcription and diarization in Windows ([Windows Store App](https://apps.microsoft.com/detail/atrain/9N15Q44SZNS2)) and Linux.
|
||||
* [Whisper-Streaming](https://github.com/ufal/whisper_streaming) implements real-time mode for offline Whisper-like speech-to-text models with faster-whisper as the most recommended back-end. It implements a streaming policy with self-adaptive latency based on the actual source complexity, and demonstrates the state of the art.
|
||||
* [WhisperLive](https://github.com/collabora/WhisperLive) is a nearly-live implementation of OpenAI's Whisper which uses faster-whisper as the backend to transcribe audio in real-time.
|
||||
* [Faster-Whisper-Transcriber](https://github.com/BBC-Esq/ctranslate2-faster-whisper-transcriber) is a simple but reliable voice transcriber that provides a user-friendly interface.
|
||||
|
||||
## Model conversion
|
||||
|
||||
When loading a model from its size such as `WhisperModel("large-v2")`, the correspondig CTranslate2 model is automatically downloaded from the [Hugging Face Hub](https://huggingface.co/guillaumekln).
|
||||
When loading a model from its size such as `WhisperModel("large-v3")`, the corresponding CTranslate2 model is automatically downloaded from the [Hugging Face Hub](https://huggingface.co/Systran).
|
||||
|
||||
We also provide a script to convert any Whisper models compatible with the Transformers library. They could be the original OpenAI models or user fine-tuned models.
|
||||
|
||||
For example the command below converts the [original "large-v2" Whisper model](https://huggingface.co/openai/whisper-large-v2) and saves the weights in FP16:
|
||||
For example the command below converts the [original "large-v3" Whisper model](https://huggingface.co/openai/whisper-large-v3) and saves the weights in FP16:
|
||||
|
||||
```bash
|
||||
pip install transformers[torch]>=4.23
|
||||
|
||||
ct2-transformers-converter --model openai/whisper-large-v2 --output_dir whisper-large-v2-ct2 \
|
||||
--copy_files tokenizer.json --quantization float16
|
||||
ct2-transformers-converter --model openai/whisper-large-v3 --output_dir whisper-large-v3-ct2
|
||||
--copy_files tokenizer.json preprocessor_config.json --quantization float16
|
||||
```
|
||||
|
||||
* The option `--model` accepts a model name on the Hub or a path to a model directory.
|
||||
@@ -139,6 +259,18 @@ ct2-transformers-converter --model openai/whisper-large-v2 --output_dir whisper-
|
||||
|
||||
Models can also be converted from the code. See the [conversion API](https://opennmt.net/CTranslate2/python/ctranslate2.converters.TransformersConverter.html).
|
||||
|
||||
### Load a converted model
|
||||
|
||||
1. Directly load the model from a local directory:
|
||||
```python
|
||||
model = faster_whisper.WhisperModel("whisper-large-v3-ct2")
|
||||
```
|
||||
|
||||
2. [Upload your model to the Hugging Face Hub](https://huggingface.co/docs/transformers/model_sharing#upload-with-the-web-interface) and load it from its name:
|
||||
```python
|
||||
model = faster_whisper.WhisperModel("username/whisper-large-v3-ct2")
|
||||
```
|
||||
|
||||
## Comparing performance against other implementations
|
||||
|
||||
If you are comparing the performance against other Whisper implementations, you should make sure to run the comparison with similar settings. In particular:
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
from faster_whisper.audio import decode_audio
|
||||
from faster_whisper.transcribe import WhisperModel
|
||||
from faster_whisper.utils import download_model, format_timestamp
|
||||
from faster_whisper.utils import available_models, download_model, format_timestamp
|
||||
from faster_whisper.version import __version__
|
||||
|
||||
__all__ = [
|
||||
"available_models",
|
||||
"decode_audio",
|
||||
"WhisperModel",
|
||||
"download_model",
|
||||
"format_timestamp",
|
||||
"__version__",
|
||||
]
|
||||
|
||||
0
faster_whisper/assets/__init__.py
Normal file
0
faster_whisper/assets/__init__.py
Normal file
@@ -6,6 +6,7 @@ system dependencies. FFmpeg does not need to be installed on the system.
|
||||
However, the API is quite low-level so we need to manipulate audio frames directly.
|
||||
"""
|
||||
|
||||
import gc
|
||||
import io
|
||||
import itertools
|
||||
|
||||
@@ -42,7 +43,7 @@ def decode_audio(
|
||||
raw_buffer = io.BytesIO()
|
||||
dtype = None
|
||||
|
||||
with av.open(input_file, metadata_errors="ignore") as container:
|
||||
with av.open(input_file, mode="r", metadata_errors="ignore") as container:
|
||||
frames = container.decode(audio=0)
|
||||
frames = _ignore_invalid_frames(frames)
|
||||
frames = _group_frames(frames, 500000)
|
||||
@@ -53,6 +54,11 @@ def decode_audio(
|
||||
dtype = array.dtype
|
||||
raw_buffer.write(array)
|
||||
|
||||
# It appears that some objects related to the resampler are not freed
|
||||
# unless the garbage collector is manually run.
|
||||
del resampler
|
||||
gc.collect()
|
||||
|
||||
audio = np.frombuffer(raw_buffer.getbuffer(), dtype=dtype)
|
||||
|
||||
# Convert s16 back to f32.
|
||||
@@ -96,3 +102,18 @@ def _resample_frames(frames, resampler):
|
||||
# Add None to flush the resampler.
|
||||
for frame in itertools.chain(frames, [None]):
|
||||
yield from resampler.resample(frame)
|
||||
|
||||
|
||||
def pad_or_trim(array, length: int, *, axis: int = -1):
|
||||
"""
|
||||
Pad or trim the audio array to N_SAMPLES, as expected by the encoder.
|
||||
"""
|
||||
if array.shape[axis] > length:
|
||||
array = array.take(indices=range(length), axis=axis)
|
||||
|
||||
if array.shape[axis] < length:
|
||||
pad_widths = [(0, 0)] * array.ndim
|
||||
pad_widths[axis] = (0, length - array.shape[axis])
|
||||
array = np.pad(array, pad_widths)
|
||||
|
||||
return array
|
||||
|
||||
@@ -142,11 +142,15 @@ class FeatureExtractor:
|
||||
data[f] = np.fft.fft(fft_signal, axis=0)[:num_fft_bins]
|
||||
return data.T
|
||||
|
||||
def __call__(self, waveform, padding=True):
|
||||
def __call__(self, waveform, padding=True, chunk_length=None):
|
||||
"""
|
||||
Compute the log-Mel spectrogram of the provided audio, gives similar results
|
||||
whisper's original torch implementation with 1e-5 tolerance.
|
||||
"""
|
||||
if chunk_length is not None:
|
||||
self.n_samples = chunk_length * self.sampling_rate
|
||||
self.nb_max_frames = self.n_samples // self.hop_length
|
||||
|
||||
if padding:
|
||||
waveform = np.pad(waveform, [(0, self.n_samples)])
|
||||
|
||||
|
||||
@@ -19,15 +19,21 @@ class Tokenizer:
|
||||
self.tokenizer = tokenizer
|
||||
|
||||
if multilingual:
|
||||
if task not in _TASKS:
|
||||
raise ValueError(
|
||||
"'%s' is not a valid task (accepted tasks: %s)"
|
||||
% (task, ", ".join(_TASKS))
|
||||
)
|
||||
|
||||
if language not in _LANGUAGE_CODES:
|
||||
raise ValueError(
|
||||
"'%s' is not a valid language code (accepted language codes: %s)"
|
||||
% (language, ", ".join(_LANGUAGE_CODES))
|
||||
)
|
||||
|
||||
self.task = self.tokenizer.token_to_id("<|%s|>" % task)
|
||||
if self.task is None:
|
||||
raise ValueError("%s is not a valid task" % task)
|
||||
|
||||
self.language_code = language
|
||||
self.language = self.tokenizer.token_to_id("<|%s|>" % language)
|
||||
if self.language is None:
|
||||
raise ValueError("%s is not a valid language code" % language)
|
||||
|
||||
self.language_code = language
|
||||
else:
|
||||
self.task = None
|
||||
self.language = None
|
||||
@@ -102,7 +108,7 @@ class Tokenizer:
|
||||
def split_to_word_tokens(
|
||||
self, tokens: List[int]
|
||||
) -> Tuple[List[str], List[List[int]]]:
|
||||
if self.language_code in {"zh", "ja", "th", "lo", "my"}:
|
||||
if self.language_code in {"zh", "ja", "th", "lo", "my", "yue"}:
|
||||
# These languages don't typically use spaces, so it is difficult to split words
|
||||
# without morpheme analysis. Here, we instead split words at any
|
||||
# position where the tokens are decoded as valid unicode points
|
||||
@@ -125,19 +131,21 @@ class Tokenizer:
|
||||
current_tokens.append(token)
|
||||
decoded = self.decode_with_timestamps(current_tokens)
|
||||
|
||||
if (
|
||||
replacement_char not in decoded
|
||||
or decoded_full[unicode_offset + decoded.index(replacement_char)]
|
||||
== replacement_char
|
||||
try:
|
||||
replacement_char_index = decoded.index(replacement_char)
|
||||
replacement_char_index += unicode_offset
|
||||
except ValueError:
|
||||
replacement_char_index = None
|
||||
|
||||
if replacement_char_index is None or (
|
||||
replacement_char_index < len(decoded_full)
|
||||
and decoded_full[replacement_char_index] == replacement_char
|
||||
):
|
||||
words.append(decoded)
|
||||
word_tokens.append(current_tokens)
|
||||
current_tokens = []
|
||||
unicode_offset += len(decoded)
|
||||
|
||||
if unicode_offset >= len(decoded_full):
|
||||
break
|
||||
|
||||
return words, word_tokens
|
||||
|
||||
def split_tokens_on_spaces(
|
||||
@@ -159,3 +167,112 @@ class Tokenizer:
|
||||
word_tokens[-1].extend(subword_tokens)
|
||||
|
||||
return words, word_tokens
|
||||
|
||||
|
||||
_TASKS = (
|
||||
"transcribe",
|
||||
"translate",
|
||||
)
|
||||
|
||||
_LANGUAGE_CODES = (
|
||||
"af",
|
||||
"am",
|
||||
"ar",
|
||||
"as",
|
||||
"az",
|
||||
"ba",
|
||||
"be",
|
||||
"bg",
|
||||
"bn",
|
||||
"bo",
|
||||
"br",
|
||||
"bs",
|
||||
"ca",
|
||||
"cs",
|
||||
"cy",
|
||||
"da",
|
||||
"de",
|
||||
"el",
|
||||
"en",
|
||||
"es",
|
||||
"et",
|
||||
"eu",
|
||||
"fa",
|
||||
"fi",
|
||||
"fo",
|
||||
"fr",
|
||||
"gl",
|
||||
"gu",
|
||||
"ha",
|
||||
"haw",
|
||||
"he",
|
||||
"hi",
|
||||
"hr",
|
||||
"ht",
|
||||
"hu",
|
||||
"hy",
|
||||
"id",
|
||||
"is",
|
||||
"it",
|
||||
"ja",
|
||||
"jw",
|
||||
"ka",
|
||||
"kk",
|
||||
"km",
|
||||
"kn",
|
||||
"ko",
|
||||
"la",
|
||||
"lb",
|
||||
"ln",
|
||||
"lo",
|
||||
"lt",
|
||||
"lv",
|
||||
"mg",
|
||||
"mi",
|
||||
"mk",
|
||||
"ml",
|
||||
"mn",
|
||||
"mr",
|
||||
"ms",
|
||||
"mt",
|
||||
"my",
|
||||
"ne",
|
||||
"nl",
|
||||
"nn",
|
||||
"no",
|
||||
"oc",
|
||||
"pa",
|
||||
"pl",
|
||||
"ps",
|
||||
"pt",
|
||||
"ro",
|
||||
"ru",
|
||||
"sa",
|
||||
"sd",
|
||||
"si",
|
||||
"sk",
|
||||
"sl",
|
||||
"sn",
|
||||
"so",
|
||||
"sq",
|
||||
"sr",
|
||||
"su",
|
||||
"sv",
|
||||
"sw",
|
||||
"ta",
|
||||
"te",
|
||||
"tg",
|
||||
"th",
|
||||
"tk",
|
||||
"tl",
|
||||
"tr",
|
||||
"tt",
|
||||
"uk",
|
||||
"ur",
|
||||
"uz",
|
||||
"vi",
|
||||
"yi",
|
||||
"yo",
|
||||
"zh",
|
||||
"yue",
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,37 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
|
||||
import huggingface_hub
|
||||
import requests
|
||||
|
||||
from tqdm.auto import tqdm
|
||||
|
||||
_MODELS = (
|
||||
"tiny.en",
|
||||
"tiny",
|
||||
"base.en",
|
||||
"base",
|
||||
"small.en",
|
||||
"small",
|
||||
"medium.en",
|
||||
"medium",
|
||||
"large-v1",
|
||||
"large-v2",
|
||||
)
|
||||
_MODELS = {
|
||||
"tiny.en": "Systran/faster-whisper-tiny.en",
|
||||
"tiny": "Systran/faster-whisper-tiny",
|
||||
"base.en": "Systran/faster-whisper-base.en",
|
||||
"base": "Systran/faster-whisper-base",
|
||||
"small.en": "Systran/faster-whisper-small.en",
|
||||
"small": "Systran/faster-whisper-small",
|
||||
"medium.en": "Systran/faster-whisper-medium.en",
|
||||
"medium": "Systran/faster-whisper-medium",
|
||||
"large-v1": "Systran/faster-whisper-large-v1",
|
||||
"large-v2": "Systran/faster-whisper-large-v2",
|
||||
"large-v3": "Systran/faster-whisper-large-v3",
|
||||
"large": "Systran/faster-whisper-large-v3",
|
||||
"distil-large-v2": "Systran/faster-distil-whisper-large-v2",
|
||||
"distil-medium.en": "Systran/faster-distil-whisper-medium.en",
|
||||
"distil-small.en": "Systran/faster-distil-whisper-small.en",
|
||||
"distil-large-v3": "Systran/faster-distil-whisper-large-v3",
|
||||
}
|
||||
|
||||
|
||||
def available_models() -> List[str]:
|
||||
"""Returns the names of available models."""
|
||||
return list(_MODELS.keys())
|
||||
|
||||
|
||||
def get_assets_path():
|
||||
@@ -25,16 +39,29 @@ def get_assets_path():
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets")
|
||||
|
||||
|
||||
def download_model(size: str, output_dir: Optional[str] = None):
|
||||
def get_logger():
|
||||
"""Returns the module logger."""
|
||||
return logging.getLogger("faster_whisper")
|
||||
|
||||
|
||||
def download_model(
|
||||
size_or_id: str,
|
||||
output_dir: Optional[str] = None,
|
||||
local_files_only: bool = False,
|
||||
cache_dir: Optional[str] = None,
|
||||
):
|
||||
"""Downloads a CTranslate2 Whisper model from the Hugging Face Hub.
|
||||
|
||||
The model is downloaded from https://huggingface.co/guillaumekln.
|
||||
|
||||
Args:
|
||||
size: Size of the model to download (tiny, tiny.en, base, base.en, small, small.en,
|
||||
medium, medium.en, large-v1, or large-v2).
|
||||
size_or_id: Size of the model to download from https://huggingface.co/Systran
|
||||
(tiny, tiny.en, base, base.en, small, small.en medium, medium.en, large-v1, large-v2,
|
||||
large-v3, large), or a CTranslate2-converted model ID from the Hugging Face Hub
|
||||
(e.g. Systran/faster-whisper-large-v3).
|
||||
output_dir: Directory where the model should be saved. If not set, the model is saved in
|
||||
the standard Hugging Face cache directory.
|
||||
the cache directory.
|
||||
local_files_only: If True, avoid downloading the file and return the path to the local
|
||||
cached file if it exists.
|
||||
cache_dir: Path to the folder where cached files are stored.
|
||||
|
||||
Returns:
|
||||
The path to the downloaded model.
|
||||
@@ -42,31 +69,55 @@ def download_model(size: str, output_dir: Optional[str] = None):
|
||||
Raises:
|
||||
ValueError: if the model size is invalid.
|
||||
"""
|
||||
if size not in _MODELS:
|
||||
raise ValueError(
|
||||
"Invalid model size '%s', expected one of: %s" % (size, ", ".join(_MODELS))
|
||||
)
|
||||
if re.match(r".*/.*", size_or_id):
|
||||
repo_id = size_or_id
|
||||
else:
|
||||
repo_id = _MODELS.get(size_or_id)
|
||||
if repo_id is None:
|
||||
raise ValueError(
|
||||
"Invalid model size '%s', expected one of: %s"
|
||||
% (size_or_id, ", ".join(_MODELS.keys()))
|
||||
)
|
||||
|
||||
repo_id = "guillaumekln/faster-whisper-%s" % size
|
||||
kwargs = {}
|
||||
allow_patterns = [
|
||||
"config.json",
|
||||
"preprocessor_config.json",
|
||||
"model.bin",
|
||||
"tokenizer.json",
|
||||
"vocabulary.*",
|
||||
]
|
||||
|
||||
kwargs = {
|
||||
"local_files_only": local_files_only,
|
||||
"allow_patterns": allow_patterns,
|
||||
"tqdm_class": disabled_tqdm,
|
||||
}
|
||||
|
||||
if output_dir is not None:
|
||||
kwargs["local_dir"] = output_dir
|
||||
kwargs["local_dir_use_symlinks"] = False
|
||||
|
||||
allow_patterns = [
|
||||
"config.json",
|
||||
"model.bin",
|
||||
"tokenizer.json",
|
||||
"vocabulary.txt",
|
||||
]
|
||||
if cache_dir is not None:
|
||||
kwargs["cache_dir"] = cache_dir
|
||||
|
||||
return huggingface_hub.snapshot_download(
|
||||
repo_id,
|
||||
allow_patterns=allow_patterns,
|
||||
tqdm_class=disabled_tqdm,
|
||||
**kwargs,
|
||||
)
|
||||
try:
|
||||
return huggingface_hub.snapshot_download(repo_id, **kwargs)
|
||||
except (
|
||||
huggingface_hub.utils.HfHubHTTPError,
|
||||
requests.exceptions.ConnectionError,
|
||||
) as exception:
|
||||
logger = get_logger()
|
||||
logger.warning(
|
||||
"An error occured while synchronizing the model %s from the Hugging Face Hub:\n%s",
|
||||
repo_id,
|
||||
exception,
|
||||
)
|
||||
logger.warning(
|
||||
"Trying to load the model directly from the local cache, if it exists."
|
||||
)
|
||||
|
||||
kwargs["local_files_only"] = True
|
||||
return huggingface_hub.snapshot_download(repo_id, **kwargs)
|
||||
|
||||
|
||||
def format_timestamp(
|
||||
@@ -96,3 +147,10 @@ class disabled_tqdm(tqdm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs["disable"] = True
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def get_end(segments: List[dict]) -> Optional[float]:
|
||||
return next(
|
||||
(w["end"] for s in reversed(segments) for w in reversed(s["words"])),
|
||||
segments[-1]["end"] if segments else None,
|
||||
)
|
||||
|
||||
@@ -3,47 +3,67 @@ import functools
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from typing import List, Optional
|
||||
from typing import List, NamedTuple, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from faster_whisper.utils import get_assets_path
|
||||
|
||||
|
||||
# The code below is adapted from https://github.com/snakers4/silero-vad.
|
||||
class VadOptions(NamedTuple):
|
||||
"""VAD options.
|
||||
|
||||
|
||||
def get_speech_timestamps(
|
||||
audio: np.ndarray,
|
||||
*,
|
||||
threshold: float = 0.5,
|
||||
min_speech_duration_ms: int = 250,
|
||||
max_speech_duration_s: float = float("inf"),
|
||||
min_silence_duration_ms: int = 2000,
|
||||
window_size_samples: int = 1024,
|
||||
speech_pad_ms: int = 200,
|
||||
) -> List[dict]:
|
||||
"""This method is used for splitting long audios into speech chunks using silero VAD.
|
||||
|
||||
Args:
|
||||
audio: One dimensional float array.
|
||||
Attributes:
|
||||
threshold: Speech threshold. Silero VAD outputs speech probabilities for each audio chunk,
|
||||
probabilities ABOVE this value are considered as SPEECH. It is better to tune this
|
||||
parameter for each dataset separately, but "lazy" 0.5 is pretty good for most datasets.
|
||||
min_speech_duration_ms: Final speech chunks shorter min_speech_duration_ms are thrown out.
|
||||
max_speech_duration_s: Maximum duration of speech chunks in seconds. Chunks longer
|
||||
than max_speech_duration_s will be split at the timestamp of the last silence that
|
||||
lasts more than 100s (if any), to prevent agressive cutting. Otherwise, they will be
|
||||
lasts more than 100ms (if any), to prevent aggressive cutting. Otherwise, they will be
|
||||
split aggressively just before max_speech_duration_s.
|
||||
min_silence_duration_ms: In the end of each speech chunk wait for min_silence_duration_ms
|
||||
before separating it
|
||||
window_size_samples: Audio chunks of window_size_samples size are fed to the silero VAD model.
|
||||
WARNING! Silero VAD models were trained using 512, 1024, 1536 samples for 16000 sample rate.
|
||||
Values other than these may affect model perfomance!!
|
||||
Values other than these may affect model performance!!
|
||||
speech_pad_ms: Final speech chunks are padded by speech_pad_ms each side
|
||||
"""
|
||||
|
||||
threshold: float = 0.5
|
||||
min_speech_duration_ms: int = 250
|
||||
max_speech_duration_s: float = float("inf")
|
||||
min_silence_duration_ms: int = 2000
|
||||
window_size_samples: int = 1024
|
||||
speech_pad_ms: int = 400
|
||||
|
||||
|
||||
def get_speech_timestamps(
|
||||
audio: np.ndarray,
|
||||
vad_options: Optional[VadOptions] = None,
|
||||
**kwargs,
|
||||
) -> List[dict]:
|
||||
"""This method is used for splitting long audios into speech chunks using silero VAD.
|
||||
|
||||
Args:
|
||||
audio: One dimensional float array.
|
||||
vad_options: Options for VAD processing.
|
||||
kwargs: VAD options passed as keyword arguments for backward compatibility.
|
||||
|
||||
Returns:
|
||||
List of dicts containing begin and end samples of each speech chunk.
|
||||
"""
|
||||
if vad_options is None:
|
||||
vad_options = VadOptions(**kwargs)
|
||||
|
||||
threshold = vad_options.threshold
|
||||
min_speech_duration_ms = vad_options.min_speech_duration_ms
|
||||
max_speech_duration_s = vad_options.max_speech_duration_s
|
||||
min_silence_duration_ms = vad_options.min_silence_duration_ms
|
||||
window_size_samples = vad_options.window_size_samples
|
||||
speech_pad_ms = vad_options.speech_pad_ms
|
||||
|
||||
if window_size_samples not in [512, 1024, 1536]:
|
||||
warnings.warn(
|
||||
"Unusual window_size_samples! Supported window_size_samples:\n"
|
||||
|
||||
3
faster_whisper/version.py
Normal file
3
faster_whisper/version.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""Version information."""
|
||||
|
||||
__version__ = "1.0.1"
|
||||
@@ -1,5 +1,5 @@
|
||||
av==10.*
|
||||
ctranslate2>=3.10,<4
|
||||
av==11.*
|
||||
ctranslate2>=4.0,<5
|
||||
huggingface_hub>=0.13
|
||||
tokenizers==0.13.*
|
||||
onnxruntime==1.14.* ; python_version < "3.11"
|
||||
tokenizers>=0.13,<0.16
|
||||
onnxruntime>=1.14,<2
|
||||
|
||||
12
setup.py
12
setup.py
@@ -11,6 +11,14 @@ def get_long_description():
|
||||
return readme_file.read()
|
||||
|
||||
|
||||
def get_project_version():
|
||||
version_path = os.path.join(base_dir, "faster_whisper", "version.py")
|
||||
version = {}
|
||||
with open(version_path, encoding="utf-8") as fp:
|
||||
exec(fp.read(), version)
|
||||
return version["__version__"]
|
||||
|
||||
|
||||
def get_requirements(path):
|
||||
with open(path, encoding="utf-8") as requirements:
|
||||
return [requirement.strip() for requirement in requirements]
|
||||
@@ -23,13 +31,13 @@ conversion_requires = get_requirements(
|
||||
|
||||
setup(
|
||||
name="faster-whisper",
|
||||
version="0.4.0",
|
||||
version=get_project_version(),
|
||||
license="MIT",
|
||||
description="Faster Whisper transcription with CTranslate2",
|
||||
long_description=get_long_description(),
|
||||
long_description_content_type="text/markdown",
|
||||
author="Guillaume Klein",
|
||||
url="https://github.com/guillaumekln/faster-whisper",
|
||||
url="https://github.com/SYSTRAN/faster-whisper",
|
||||
classifiers=[
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
|
||||
@@ -3,14 +3,26 @@ import os
|
||||
from faster_whisper import WhisperModel, decode_audio
|
||||
|
||||
|
||||
def test_supported_languages():
|
||||
model = WhisperModel("tiny.en")
|
||||
assert model.supported_languages == ["en"]
|
||||
|
||||
|
||||
def test_transcribe(jfk_path):
|
||||
model = WhisperModel("tiny")
|
||||
segments, info = model.transcribe(jfk_path, word_timestamps=True)
|
||||
assert info.all_language_probs is not None
|
||||
|
||||
assert info.language == "en"
|
||||
assert info.language_probability > 0.9
|
||||
assert info.duration == 11
|
||||
|
||||
# Get top language info from all results, which should match the
|
||||
# already existing metadata
|
||||
top_lang, top_lang_score = info.all_language_probs[0]
|
||||
assert info.language == top_lang
|
||||
assert abs(info.language_probability - top_lang_score) < 1e-16
|
||||
|
||||
segments = list(segments)
|
||||
|
||||
assert len(segments) == 1
|
||||
@@ -27,12 +39,30 @@ def test_transcribe(jfk_path):
|
||||
assert segment.end == segment.words[-1].end
|
||||
|
||||
|
||||
def test_prefix_with_timestamps(jfk_path):
|
||||
model = WhisperModel("tiny")
|
||||
segments, _ = model.transcribe(jfk_path, prefix="And so my fellow Americans")
|
||||
segments = list(segments)
|
||||
|
||||
assert len(segments) == 1
|
||||
|
||||
segment = segments[0]
|
||||
|
||||
assert segment.text == (
|
||||
" And so my fellow Americans ask not what your country can do for you, "
|
||||
"ask what you can do for your country."
|
||||
)
|
||||
|
||||
assert segment.start == 0
|
||||
assert 10 < segment.end < 11
|
||||
|
||||
|
||||
def test_vad(jfk_path):
|
||||
model = WhisperModel("tiny")
|
||||
segments, _ = model.transcribe(
|
||||
segments, info = model.transcribe(
|
||||
jfk_path,
|
||||
vad_filter=True,
|
||||
vad_parameters=dict(min_silence_duration_ms=500),
|
||||
vad_parameters=dict(min_silence_duration_ms=500, speech_pad_ms=200),
|
||||
)
|
||||
segments = list(segments)
|
||||
|
||||
@@ -47,6 +77,9 @@ def test_vad(jfk_path):
|
||||
assert 0 < segment.start < 1
|
||||
assert 10 < segment.end < 11
|
||||
|
||||
assert info.vad_options.min_silence_duration_ms == 500
|
||||
assert info.vad_options.speech_pad_ms == 200
|
||||
|
||||
|
||||
def test_stereo_diarization(data_dir):
|
||||
model = WhisperModel("tiny")
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import os
|
||||
|
||||
from faster_whisper import download_model
|
||||
from faster_whisper import available_models, download_model
|
||||
|
||||
|
||||
def test_available_models():
|
||||
models = available_models()
|
||||
assert isinstance(models, list)
|
||||
assert "tiny" in models
|
||||
|
||||
|
||||
def test_download_model(tmpdir):
|
||||
@@ -15,3 +21,9 @@ def test_download_model(tmpdir):
|
||||
for filename in os.listdir(model_dir):
|
||||
path = os.path.join(model_dir, filename)
|
||||
assert not os.path.islink(path)
|
||||
|
||||
|
||||
def test_download_model_in_cache(tmpdir):
|
||||
cache_dir = str(tmpdir.join("model"))
|
||||
download_model("tiny", cache_dir=cache_dir)
|
||||
assert os.path.isdir(cache_dir)
|
||||
|
||||
Reference in New Issue
Block a user