From 100ab349477b808055efaf24d109c65cd35e80e1 Mon Sep 17 00:00:00 2001 From: Aleksandr Movchan Date: Wed, 22 May 2024 09:19:38 +0000 Subject: [PATCH] Changed faster-whisper dependency --- .github/workflows/python-package.yml | 3 +- aana/cli.py | 7 ++- aana/deployments/whisper_deployment.py | 10 +++- aana/utils/test.py | 4 -- install.sh | 1 + poetry.lock | 68 ++++++-------------------- pyproject.toml | 2 +- 7 files changed, 32 insertions(+), 63 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 34882495..56ec7456 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -28,7 +28,8 @@ jobs: run: echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Install dependencies run: | - poetry install + chmod +x install.sh + ./install.sh sudo apt-get update sudo apt-get install ffmpeg - name: Test with pytest diff --git a/aana/cli.py b/aana/cli.py index 020d17f7..932481ee 100644 --- a/aana/cli.py +++ b/aana/cli.py @@ -63,8 +63,11 @@ def deploy(app_path: str, host: str, port: int, show_logs: bool, ray_address: st @cli.command() @click.argument("app_path", type=str) @click.option( - "--host", default="0.0.0.0", type=str, help="Host address (default: 0.0.0.0)" -) # noqa: S104 + "--host", + default="0.0.0.0", # noqa: S104 + type=str, + help="Host address (default: 0.0.0.0)", +) @click.option( "--port", default=8000, type=int, help="Port to run the application (default: 8000)" ) diff --git a/aana/deployments/whisper_deployment.py b/aana/deployments/whisper_deployment.py index fb9509b6..17a19846 100644 --- a/aana/deployments/whisper_deployment.py +++ b/aana/deployments/whisper_deployment.py @@ -3,7 +3,7 @@ from typing import Any, cast import torch -from faster_whisper import BatchedInferencePipeline, WhisperModel +from faster_whisper import WhisperModel from faster_whisper.tokenizer import Tokenizer from pydantic import BaseModel, Field from ray import serve @@ -296,6 +296,14 @@ async def transcribe_in_chunks( Raises: InferenceException: If the inference fails. """ + try: + from faster_whisper import BatchedInferencePipeline + except ImportError as e: + raise ImportError( # noqa: TRY003 + "Batched version of whisper is not available. " + "Install faster-whisper from https://github.com/mobiusml/faster-whisper" + ) from e + if not params: params = BatchedWhisperParams() diff --git a/aana/utils/test.py b/aana/utils/test.py index ebd7d6d8..d51aca68 100644 --- a/aana/utils/test.py +++ b/aana/utils/test.py @@ -3,7 +3,6 @@ from functools import wraps from importlib import resources from pathlib import Path -from typing import TYPE_CHECKING import rapidfuzz @@ -11,9 +10,6 @@ from aana.utils.general import get_object_hash from aana.utils.json import jsonify -if TYPE_CHECKING: - from aana.deployments.base_deployment import BaseDeployment - def test_cache(func): # noqa: C901 """Decorator for caching and loading the results of a deployment function in testing mode. diff --git a/install.sh b/install.sh index fc2adbe6..666ef6d7 100644 --- a/install.sh +++ b/install.sh @@ -1,2 +1,3 @@ #!/bin/sh poetry install $1 +poetry run pip install git+https://github.com/mobiusml/faster-whisper.git@v1.0.1_mobiusml_v1.1 \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 90d9890e..6cf92663 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1171,36 +1171,26 @@ all = ["email-validator (>=2.0.0)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)" [[package]] name = "faster-whisper" -version = "1.0.1" +version = "1.0.2" description = "Faster Whisper transcription with CTranslate2" optional = false python-versions = ">=3.8" -files = [] -develop = false +files = [ + {file = "faster-whisper-1.0.2.tar.gz", hash = "sha256:54d9fc698f7c665e00a0d5ed65d6e975b72a8862b8214f20a22e79b115c41511"}, + {file = "faster_whisper-1.0.2-py3-none-any.whl", hash = "sha256:d968c289222e766a49ed97eecec24e934bdef405183f57d6d434a364bb3569c1"}, +] [package.dependencies] -av = "==11.*" +av = ">=11.0,<13" ctranslate2 = ">=4.0,<5" -huggingface_hub = ">=0.13" -jsons = ">=1.6.3" +huggingface-hub = ">=0.13" onnxruntime = ">=1.14,<2" -pandas = ">=2.1.4" -pyannote-audio = ">=3.1.1" -tokenizers = ">=0.13,<0.16" -torch = ">=2.1.1" -torchaudio = ">=2.1.2" -transformers = "*" +tokenizers = ">=0.13,<1" [package.extras] conversion = ["transformers[torch] (>=4.23)"] dev = ["black (==23.*)", "flake8 (==6.*)", "isort (==5.*)", "pytest (==7.*)"] -[package.source] -type = "git" -url = "https://github.com/mobiusml/faster-whisper.git" -reference = "v1.0.1_mobiusml_v1.1" -resolved_reference = "0d6c62e2504574731d2eee89ae4ed911f3c76a79" - [[package]] name = "filelock" version = "3.14.0" @@ -2161,23 +2151,6 @@ files = [ {file = "joblib-1.4.2.tar.gz", hash = "sha256:2382c5816b2636fbd20a09e0f4e9dad4736765fdfb7dca582943b9c1366b3f0e"}, ] -[[package]] -name = "jsons" -version = "1.6.3" -description = "For serializing Python objects to JSON (dicts) and back" -optional = false -python-versions = ">=3.5" -files = [ - {file = "jsons-1.6.3-py3-none-any.whl", hash = "sha256:f07f8919316f72a3843c7ca6cc6c900513089f10092626934d1bfe4b5cf15401"}, - {file = "jsons-1.6.3.tar.gz", hash = "sha256:cd5815c7c6790ae11c70ad9978e0aa850d0d08a643a5105cc604eac8b29a30d7"}, -] - -[package.dependencies] -typish = ">=1.9.2" - -[package.extras] -test = ["attrs", "codecov", "coverage", "dataclasses", "pytest", "scons", "tzdata"] - [[package]] name = "jsonschema" version = "4.22.0" @@ -3488,10 +3461,10 @@ files = [ [package.dependencies] numpy = [ + {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, + {version = ">=1.23.5", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, {version = ">=1.21.4", markers = "python_version >= \"3.10\" and platform_system == \"Darwin\" and python_version < \"3.11\""}, {version = ">=1.21.2", markers = "platform_system != \"Darwin\" and python_version >= \"3.10\" and python_version < \"3.11\""}, - {version = ">=1.23.5", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, - {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, ] [[package]] @@ -3674,9 +3647,9 @@ files = [ [package.dependencies] numpy = [ - {version = ">=1.22.4", markers = "python_version < \"3.11\""}, - {version = ">=1.23.2", markers = "python_version == \"3.11\""}, {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, + {version = ">=1.23.2", markers = "python_version == \"3.11\""}, + {version = ">=1.22.4", markers = "python_version < \"3.11\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -4944,8 +4917,8 @@ grpcio = ">=1.41.0" grpcio-tools = ">=1.41.0" httpx = {version = ">=0.20.0", extras = ["http2"]} numpy = [ - {version = ">=1.21", markers = "python_version >= \"3.8\" and python_version < \"3.12\""}, {version = ">=1.26", markers = "python_version >= \"3.12\""}, + {version = ">=1.21", markers = "python_version >= \"3.8\" and python_version < \"3.12\""}, ] portalocker = ">=2.7.0,<3.0.0" pydantic = ">=1.10.8" @@ -6749,19 +6722,6 @@ files = [ {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, ] -[[package]] -name = "typish" -version = "1.9.3" -description = "Functionality for types" -optional = false -python-versions = "*" -files = [ - {file = "typish-1.9.3-py3-none-any.whl", hash = "sha256:03cfee5e6eb856dbf90244e18f4e4c41044c8790d5779f4e775f63f982e2f896"}, -] - -[package.extras] -test = ["codecov", "coverage", "mypy", "nptyping (>=1.3.0)", "numpy", "pycodestyle", "pylint", "pytest"] - [[package]] name = "tzdata" version = "2024.1" @@ -7265,4 +7225,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = ">=3.10" -content-hash = "d3c7b4998faee5e5a06d598aca1263866040941c594bf0e1bbd9561ec5f91582" +content-hash = "ca2cadd14e22220ee17ccede2f4cfa4f27ae14dadb84713110e9bc47dfa9b8ec" diff --git a/pyproject.toml b/pyproject.toml index 484c5db4..5e315f25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ decord = "^0.6.0" deepdiff = "^6.7.0" diffusers = "^0.23.1" fastapi = "^0.104.0" -faster-whisper = { git = "https://github.com/mobiusml/faster-whisper.git", tag = "v1.0.1_mobiusml_v1.1" } +faster-whisper = ">=1.0.1" hf-transfer = "^0.1.6" onnxruntime = "1.16.1" opencv-python = "^4.8.1.78"