Skip to content

Commit 9b7da19

Browse files
authored
Merge pull request #45 from wasertech/v0.0.21-gm
Version 0.0.21-GM
2 parents d10ee32 + 20818c1 commit 9b7da19

File tree

8 files changed

+88
-26
lines changed

8 files changed

+88
-26
lines changed

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-20.04, macos-10.15, windows-2019]
12-
pyver: ['3.6', '3.7', '3.8', '3.9', '3.10']
12+
pyver: ['3.7', '3.8', '3.9', '3.10']
1313
fail-fast: false
1414
runs-on: ${{ matrix.os }}
1515
steps:
@@ -48,7 +48,7 @@ jobs:
4848
runs-on: ubuntu-20.04
4949
strategy:
5050
matrix:
51-
pyver: ['3.6', '3.7', '3.8', '3.9', '3.10']
51+
pyver: ['3.7', '3.8', '3.9', '3.10']
5252
steps:
5353
- uses: actions/checkout@v2
5454
- uses: actions/setup-python@v2

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contribution guidelines
2+
3+
Welcome to the 🐸STT communuty! We are excited to see your interest, and appreciate your support!
4+
5+
This repository is governed by the Contributor Covenant Code of Conduct. For more details, see the [`CODE_OF_CONDUCT.md`](./CODE_OF_CONDUCT.md)
6+
7+
## How to Make a Good Pull Request
8+
9+
Here's some guidelines on how to make a good PR to 🐸STT.
10+
11+
### Bug-fix PR
12+
13+
You've found a bug and you were able to squash it! Great job! Please write a short but clear commit message describing the bug, and how you fixed it. This makes review much easier. Also, please name your branch something related to the bug-fix.
14+
15+
### New Feature PR
16+
17+
You've made some core changes to 🐸STT, and you would like to share them back with the community -- great! First things first: if you're planning to add a feature (not just fix a bug or docs) let the 🐸STT team know ahead of time and get some feedback early. A quick check-in with the team can save time during code-review, and also ensure that your new feature fits into the project.
18+
19+
The 🐸STT codebase is made of many connected parts. There is Python code for training 🐸STT, core C++ code for running inference on trained models, and multiple language bindings to the C++ core so you can use 🐸STT in your favorite language.
20+
21+
Whenever you add a new feature to 🐸STT and what to contribute that feature back to the project, here are some things to keep in mind:
22+
23+
1. You've made changes to the Python code. Make sure you run a linter (described below).
24+
25+
## Requesting review on your PR
26+
27+
Generally, a code owner will be notified of your pull request and will either review it or ask some other code owner for their review. If you'd like to proactively request review as you open the PR, see the the CODE_OWNERS.rst file which describes who's an appropriate reviewer depending on which parts of the code you're changing.
28+
29+
30+
## Code linting
31+
32+
We use [pre-commit](https://pre-commit.com/) to manage pre-commit hooks that take care of checking your changes for code style violations. Before committing changes, make sure you have the hook installed in your setup by running, in the virtual environment you use for running the code:
33+
34+
```bash
35+
$ # Create and activate virtualenv:
36+
$ python -m venv /tmp/venv
37+
$ /tmp/venv/bin/activate
38+
$ # Install package in editable mode:
39+
$ make dev_install
40+
$ # Install pre-commit hooks for development:
41+
$ make install_pre_commit_hooks
42+
```
43+
44+
This will install a git pre-commit hook which will check your commits and let you know about any style violations that need fixing.

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Coqui STT Model manager
22

3+
![](./images/cover-1.png)
4+
35
🐸STT Model Manager is a tool for installing and trying out Coqui STT models from the [Coqui Model Zoo](https://coqui.ai/models/).
46

57
# Usage
@@ -21,6 +23,8 @@ $ pip install coqui_stt_model_manager
2123
$ stt-model-manager
2224
```
2325

26+
![](./images/cover-2.png)
27+
2428
# Build and install from source
2529

2630
Build dependencies:
@@ -42,15 +46,7 @@ $ make install
4246

4347
# Development installation (editable, with pre-commit hooks)
4448

45-
```bash
46-
$ # Create and activate virtualenv:
47-
$ python -m venv /tmp/venv
48-
$ /tmp/venv/bin/activate
49-
$ # Install package in editable mode:
50-
$ make dev_install
51-
$ # Install pre-commit hooks for development:
52-
$ make install_pre_commit_hooks
53-
```
49+
See [`CONTRIBUTING`](./CONTRIBUTING.md).
5450

5551
# Running in development mode (watching file changes and rebuilding automatically)
5652

@@ -77,4 +73,5 @@ For now you have to reload the browser manually. We'd gladly welcome a PR adding
7773
```bash
7874
$ make package
7975
$ ll dist/
76+
$ pip install dist/*.whl
8077
```

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.20
1+
0.0.21

coqui_stt_model_manager/modelmanager.py

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
import math
34
import os
45
import shutil
@@ -13,6 +14,8 @@
1314
from coqpit import Coqpit
1415
from xdg import BaseDirectory as xdg
1516

17+
logging.basicConfig(level=logging.DEBUG)
18+
1619

1720
@dataclass
1821
class ModelCard(Coqpit): # pylint: disable=too-many-instance-attributes
@@ -34,6 +37,13 @@ class ModelCard(Coqpit): # pylint: disable=too-many-instance-attributes
3437
default=None, metadata={"help": "path to downloaded scorer, if available"}
3538
)
3639

40+
@property
41+
def is_installed(self) -> bool:
42+
return self.installed
43+
44+
def __repr__(self):
45+
return f"{self.language}/{self.creator}/{self.version}/{self.name}"
46+
3747

3848
@dataclass
3949
class ModelIndex(Coqpit):
@@ -47,31 +57,33 @@ class ModelIndex(Coqpit):
4757
def _download_one(url: str, dest_path: Path):
4858
if dest_path.exists():
4959
yield 100
50-
print("Skipped, file already exists")
60+
logging.debug("Skipped, file already exists")
5161
return
5262

5363
response = requests.get(url, stream=True)
5464
total_length = response.headers.get("Content-Length")
5565

5666
with open(dest_path, "wb") as fout:
5767
if total_length is None:
58-
print(f"Unknown download size for {url}. Downloading...")
68+
logging.debug("Unknown download size for %s. Downloading...", url)
5969
yield 0
6070
fout.write(response.content)
6171
yield 100
62-
print("Done")
72+
logging.debug("Done")
6373
else:
6474
total_bytes = int(total_length)
6575
done_bytes = 0
66-
print(f"File is {total_bytes} bytes large for {url}, downloading...")
76+
logging.debug(
77+
"File is %d bytes large for %s, downloading...", total_bytes, url
78+
)
6779
for chunk in response.iter_content(chunk_size=5 * 2**20):
6880
done_bytes += len(chunk)
69-
print(f"{done_bytes} out of {total_bytes} downloaded")
81+
logging.debug("%d out of %d downloaded", done_bytes, total_bytes)
7082
fout.write(chunk)
7183
done_pct = math.ceil((done_bytes / total_bytes) * 100)
7284
yield done_pct
7385
yield 100
74-
print("Done")
86+
logging.debug("Done")
7587

7688

7789
class ModelInstallTask(Thread): # pylint: disable=too-many-instance-attributes
@@ -176,9 +188,17 @@ def __init__(self, install_dir: Optional[Path] = None):
176188
else:
177189
self.installed_models = ModelIndex()
178190
self.persist_index_to_disk()
179-
print(f"Installed models: {self.installed_models}")
191+
if not self.list_models():
192+
logging.debug("No installed models.")
193+
else:
194+
logging.debug("Installed models:")
195+
for model_card in self.list_models():
196+
logging.debug(model_card.__repr__())
180197
self.install_tasks: Dict[str, ModelInstallTask] = {}
181198

199+
def __repr__(self):
200+
return f"ModelManager:{self.model_index_path}"
201+
182202
def read_index_from_disk(self):
183203
with open(self.model_index_path) as fin:
184204
self.installed_models = ModelIndex.new_from_dict(json.load(fin))
@@ -188,7 +208,7 @@ def persist_index_to_disk(self):
188208
fout.write(self.installed_models.to_json())
189209

190210
def list_models(self) -> List[ModelCard]:
191-
return self.installed_models.models
211+
return [m for m in self.installed_models.models if m.is_installed]
192212

193213
def models_dict(self) -> Dict[str, ModelCard]:
194214
return {m.name: m for m in self.installed_models.models}
@@ -260,7 +280,7 @@ def download_model(self, model_card: dict):
260280
scorer_path=output_scorer,
261281
)
262282
self.set_install_task_state(install_id, install_task)
263-
print("Starting install thread...")
283+
logging.debug("Starting install thread...")
264284
install_task.start()
265285
return install_id
266286

@@ -281,8 +301,9 @@ def maybe_upgrade_protobuf(self):
281301
m for m in self.list_models() if m.acoustic_path.endswith(".pbmm")
282302
]
283303
if pbmm_models:
284-
print(
285-
f"Found {len(pbmm_models)} installed protobuf models, upgrading to TFLite if available or removing..."
304+
logging.debug(
305+
"Found %d installed protobuf models, upgrading to TFLite if available or removing...",
306+
len(pbmm_models),
286307
)
287308
for model in pbmm_models:
288309
self.uninstall_model(model.name)
@@ -296,8 +317,8 @@ def maybe_upgrade_protobuf(self):
296317
os.remove(model.acoustic_path)
297318
self.download_model(model.to_dict())
298319
except: # pylint: disable=bare-except
299-
print(
300-
f"Couldn't automatically upgrade {model.name}, uninstalling..."
320+
logging.warning(
321+
"Couldn't automatically upgrade %s, uninstalling...", model.name
301322
)
302323
model_base_path = self.install_dir / model.name
303324
shutil.rmtree(model_base_path)

images/cover-1.png

123 KB
Loading

images/cover-2.png

134 KB
Loading

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install_requires =
2929
webrtcvad==2.0.10
3030
stt<2.0.0
3131
requests==2.25.1
32-
python_requires = >=3.6,<3.11
32+
python_requires = >=3.7,<3.11
3333

3434
[options.package_data]
3535
coqui_stt_model_manager = templates/*, static/build/*, static/build/static/js/*, static/build/static/css/*

0 commit comments

Comments
 (0)