This commit is contained in:
Yuta Hayashibe 2022-10-08 23:47:20 +09:00
parent c8baed9df0
commit 77808b1182
5 changed files with 95 additions and 5 deletions

View file

@ -1,4 +1,6 @@
SHELL=/bin/bash
all: lint_node lint_python
TARGET_DIRS:=./whispering
@ -16,7 +18,10 @@ yamllint:
find . \( -name node_modules -o -name .venv \) -prune -o -type f -name '*.yml' -print \
| xargs yamllint --no-warnings
lint_python: flake8 black isort pydocstyle
version_check:
git tag | python ./scripts/check_version.py --toml pyproject.toml -i README.md --tags /dev/stdin
lint_python: flake8 black isort pydocstyle version_check
pyright:

View file

@ -14,7 +14,7 @@ Enough machine power is needed to transcribe in real time.
## Setup
```bash
pip install -U git+https://github.com/shirayu/whispering.git
pip install -U git+https://github.com/shirayu/whispering.git@v0.5.0
# If you use GPU, install proper torch and torchaudio
# Check https://pytorch.org/get-started/locally/

14
poetry.lock generated
View file

@ -373,6 +373,14 @@ python-versions = "*"
docs = ["setuptools-rust", "sphinx", "sphinx-rtd-theme"]
testing = ["datasets", "numpy", "pytest", "requests"]
[[package]]
name = "toml"
version = "0.10.2"
description = "Python Library for Tom's Obvious, Minimal Language"
category = "dev"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "tomli"
version = "2.0.1"
@ -539,7 +547,7 @@ resolved_reference = "9e653bd0ea0f1e9493cb4939733e9de249493cfb"
[metadata]
lock-version = "1.1"
python-versions = ">=3.8,<3.11"
content-hash = "e03ed06253a5fa7329768e3c8ebb0874055f4cfe06ac1bd5e5b79e06157ba37e"
content-hash = "79ea5b667ca678b6ae4f8dc3c5ad0ee5a852c1805d7bafd62f5181db87536c86"
[metadata.files]
black = [
@ -970,6 +978,10 @@ tokenizers = [
{file = "tokenizers-0.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:2158baf80cbc09259bfd6e0e0fc4597b611e7a72ad5443dad63918a90f1dd304"},
{file = "tokenizers-0.12.1.tar.gz", hash = "sha256:070746f86efa6c873db341e55cf17bb5e7bdd5450330ca8eca542f5c3dab2c66"},
]
toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},

View file

@ -1,9 +1,14 @@
[misc]
stable_version = "0.5.0"
[tool.poetry]
name = "whispering"
version = "0.1.0"
description = ""
version = "0.5.0"
description = "Streaming transcriber with whisper"
license = "MIT"
authors = ["Yuta Hayashibe <yuta@hayashibe.jp>"]
readme = "README.md"
repository = "https://github.com/shirayu/whispering.git"
packages = [{include = "whispering"}]
[tool.poetry.dependencies]
@ -22,6 +27,7 @@ black = ">=22.8.0"
isort = ">=5.10.1"
flake8 = ">=5.0.4"
pydocstyle = ">=6.1.1"
toml = "^0.10.2"
[build-system]
requires = ["poetry-core"]
@ -30,3 +36,10 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
whispering = "whispering.cli:main"
[tool.pyright]
pythonVersion = "3.8"
typeCheckingMode = "basic"
exclude = [".venv", "**/node_modules", "**/__pycache__",]
reportPrivateImportUsage = "information"
reportUnusedVariable="warning"

60
scripts/check_version.py Normal file
View file

@ -0,0 +1,60 @@
#!/usr/bin/env python3
import argparse
import sys
from pathlib import Path
from typing import Final, Tuple
import toml
def get_stable_version(obj) -> str:
stable_version: Final[str] = obj["misc"]["stable_version"]
return f"v{stable_version}"
def check_version(path_in: Path, path_pyproject_toml: Path) -> Tuple[bool, str]:
with path_pyproject_toml.open() as f:
obj = toml.load(f)
stable_version: Final[str] = get_stable_version(obj)
repository: Final[str] = obj["tool"]["poetry"]["repository"]
cmd: Final[str] = f"pip install -U git+{repository}@{stable_version}"
with path_in.open() as f:
for line in f:
if line.strip() == cmd:
return True, stable_version
sys.stderr.write(f"The following command not found in {path_in}: {cmd}\n")
return False, stable_version
def get_opts() -> argparse.Namespace:
oparser = argparse.ArgumentParser()
oparser.add_argument("--input", "-i", type=Path)
oparser.add_argument("--toml", "-t", type=Path, required=True)
oparser.add_argument("--tags", type=Path)
return oparser.parse_args()
def main() -> None:
opts = get_opts()
assert opts.input is not None
ok, stable_version = check_version(opts.input, opts.toml)
if not ok:
sys.exit(1)
if opts.tags:
tags = []
with opts.tags.open() as f:
for line in f:
tags.append(line[:-1])
if stable_version not in tags:
sys.stderr.write(f"Tag {stable_version} not in git tags: {tags}\n")
sys.exit(1)
if __name__ == "__main__":
main()