Skip to content

Commit 859f134

Browse files
committed
Use faster-whisper PyPI package instead
1 parent cdd1536 commit 859f134

File tree

14 files changed

+53
-928
lines changed

14 files changed

+53
-928
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.0.0
4+
5+
- Use faster-whisper PyPI package
6+
- `--model` can now be a HuggingFace model like `Systran/faster-distil-whisper-small.en`
7+
38
## 1.1.0
49

510
- Fix enum use for Python 3.11+

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ cd wyoming-faster-whisper
1818
script/setup
1919
```
2020

21-
Download model to data dir
22-
```sh
23-
curl -L -s https://github.com/rhasspy/models/releases/download/v1.0/asr_faster-whisper-tiny-int8.tar.gz | tar -zxvf - -C /data
24-
```
25-
2621
Run a server anyone can connect to:
22+
2723
```sh
2824
script/run --model tiny-int8 --language en --uri 'tcp://0.0.0.0:10300' --data-dir /data --download-dir /data
2925
```
3026

27+
The `--model` can also be a HuggingFace model like `Systran/faster-distil-whisper-small.en`
28+
3129
## Docker Image
3230

3331
``` sh

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
wyoming==1.5.2
2-
ctranslate2>=3.17,<4
3-
tokenizers==0.15.*
2+
faster-whisper==1.1.0

wyoming_faster_whisper/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
2.0.0

wyoming_faster_whisper/__main__.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
import argparse
33
import asyncio
44
import logging
5+
import re
56
from functools import partial
6-
from pathlib import Path
7-
from typing import Optional
87

8+
import faster_whisper
99
from wyoming.info import AsrModel, AsrProgram, Attribution, Info
1010
from wyoming.server import AsyncServer
1111

1212
from . import __version__
13-
from .const import WHISPER_LANGUAGES
14-
from .download import FasterWhisperModel, download_model, find_model
15-
from .faster_whisper import WhisperModel
1613
from .handler import FasterWhisperEventHandler
1714

1815
_LOGGER = logging.getLogger(__name__)
@@ -24,7 +21,6 @@ async def main() -> None:
2421
parser.add_argument(
2522
"--model",
2623
required=True,
27-
choices=list(v.value for v in FasterWhisperModel),
2824
help="Name of faster-whisper model to use",
2925
)
3026
parser.add_argument("--uri", required=True, help="unix:// or tcp://")
@@ -78,17 +74,13 @@ async def main() -> None:
7874
)
7975
_LOGGER.debug(args)
8076

81-
# Look for model
82-
model = FasterWhisperModel(args.model)
83-
model_dir: Optional[Path] = None
84-
for data_dir in args.data_dir:
85-
model_dir = find_model(model, data_dir)
86-
if model_dir is not None:
87-
break
88-
89-
if model_dir is None:
90-
_LOGGER.info("Downloading %s to %s", model, args.download_dir)
91-
model_dir = download_model(model, args.download_dir)
77+
model_name = args.model
78+
match = re.match(r"^(tiny|base|small|medium)[.-]int8$", args.model)
79+
if match:
80+
# Original models re-uploaded to huggingface
81+
model_size = match.group(1)
82+
model_name = f"{model_size}-int8"
83+
args.model = f"rhasspy/faster-whisper-{model_name}"
9284

9385
if args.language == "auto":
9486
# Whisper does not understand "auto"
@@ -107,25 +99,26 @@ async def main() -> None:
10799
version=__version__,
108100
models=[
109101
AsrModel(
110-
name=model.value,
111-
description=model.value,
102+
name=model_name,
103+
description=model_name,
112104
attribution=Attribution(
113-
name="rhasspy",
114-
url="https://github.com/rhasspy/models/",
105+
name="Systran",
106+
url="https://huggingface.co/Systran",
115107
),
116108
installed=True,
117-
languages=WHISPER_LANGUAGES,
118-
version="1.0",
109+
languages=faster_whisper.tokenizer._LANGUAGE_CODES, # pylint: disable=protected-access
110+
version=faster_whisper.__version__,
119111
)
120112
],
121113
)
122114
],
123115
)
124116

125-
# Load converted faster-whisper model
126-
_LOGGER.debug("Loading %s", model_dir)
127-
whisper_model = WhisperModel(
128-
str(model_dir),
117+
# Load model
118+
_LOGGER.debug("Loading %s", args.model)
119+
whisper_model = faster_whisper.WhisperModel(
120+
args.model,
121+
download_root=args.download_dir,
129122
device=args.device,
130123
compute_type=args.compute_type,
131124
)

wyoming_faster_whisper/const.py

Lines changed: 0 additions & 101 deletions
This file was deleted.

wyoming_faster_whisper/download.py

Lines changed: 0 additions & 142 deletions
This file was deleted.

wyoming_faster_whisper/faster_whisper/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)