• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
yjyoon / whisper_server_speaches star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
whisper_server_speachestestsmodel_manager_test.py
Download as .zip file
File name
Commit message
Commit date
.github/workflows
chore(deps): update astral-sh/setup-uv action to v4
2024-12-16
configuration
feat: add instrumentation
2024-12-17
docs
docs: initialize mkdocs
2024-10-03
examples
refactor(example): remove unnecessary dependencies
2024-11-02
scripts
chore: misc changes
2024-10-03
src/speaches
chore: document `sample_rate` param
2024-12-17
tests
fix: piper is imported on ARM
2024-11-01
.dockerignore
chore: update .dockerignore
2024-11-01
.envrc
init
2024-05-20
.gitattributes
chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.7.2
2024-11-02
.gitignore
chore: update .gitignore
2024-07-03
.pre-commit-config.yaml
chore(deps): update pre-commit hook detachhead/basedpyright-pre-commit-mirror to v1.23.0
2024-12-16
Dockerfile.cpu
feat: add instrumentation
2024-12-17
Dockerfile.cuda
feat: add instrumentation
2024-12-17
LICENSE
init
2024-05-20
README.md
Improved readability in README.md
2024-10-09
Taskfile.yaml
feat: add instrumentation
2024-12-17
audio.wav
docs: update README.md
2024-05-27
compose.yaml
feat: add instrumentation
2024-12-17
flake.lock
deps: update flake
2024-11-01
flake.nix
chore(deps): add loki and tempo package to flake
2024-12-17
mkdocs.yml
docs: initialize mkdocs
2024-10-03
observability-compose.yaml
feat: add instrumentation
2024-12-17
pyproject.toml
feat: add instrumentation
2024-12-17
renovate.json
feat: renovate handle pre-commit
2024-11-01
uv.lock
feat: add instrumentation
2024-12-17
File name
Commit message
Commit date
__init__.py
feat: add /v1/models and /v1/model routes #14
2024-06-03
api_model_test.py
chore: auto-fix ruff errors
2024-10-01
api_timestamp_granularities_test.py
chore: auto-fix ruff errors
2024-10-01
conftest.py
feat: tts
2024-11-01
model_manager_test.py
feat: model unloading
2024-10-01
openai_timestamp_granularities_test.py
chore: auto-fix ruff errors
2024-10-01
speech_test.py
fix: piper is imported on ARM
2024-11-01
sse_test.py
chore: auto-fix ruff errors
2024-10-01
Fedir Zadniprovskyi 2024-10-01 dc3d3e7 feat: model unloading UNIX
Raw Open in browser Change history
import asyncio import os import anyio from httpx import ASGITransport, AsyncClient import pytest from faster_whisper_server.main import create_app @pytest.mark.asyncio async def test_model_unloaded_after_ttl() -> None: ttl = 5 model = "Systran/faster-whisper-tiny.en" os.environ["WHISPER__TTL"] = str(ttl) os.environ["ENABLE_UI"] = "false" async with AsyncClient(transport=ASGITransport(app=create_app()), base_url="http://test") as aclient: res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0 await aclient.post(f"/api/ps/{model}") res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 await asyncio.sleep(ttl + 1) res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0 @pytest.mark.asyncio async def test_ttl_resets_after_usage() -> None: ttl = 5 model = "Systran/faster-whisper-tiny.en" os.environ["WHISPER__TTL"] = str(ttl) os.environ["ENABLE_UI"] = "false" async with AsyncClient(transport=ASGITransport(app=create_app()), base_url="http://test") as aclient: await aclient.post(f"/api/ps/{model}") res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 await asyncio.sleep(ttl - 2) res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 async with await anyio.open_file("audio.wav", "rb") as f: data = await f.read() res = ( await aclient.post( "/v1/audio/transcriptions", files={"file": ("audio.wav", data, "audio/wav")}, data={"model": model} ) ).json() res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 await asyncio.sleep(ttl - 2) res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 await asyncio.sleep(3) res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0 # test the model can be used again after being unloaded # this just ensures the model can be loaded again after being unloaded res = ( await aclient.post( "/v1/audio/transcriptions", files={"file": ("audio.wav", data, "audio/wav")}, data={"model": model} ) ).json() @pytest.mark.asyncio async def test_model_cant_be_unloaded_when_used() -> None: ttl = 0 model = "Systran/faster-whisper-tiny.en" os.environ["WHISPER__TTL"] = str(ttl) os.environ["ENABLE_UI"] = "false" async with AsyncClient(transport=ASGITransport(app=create_app()), base_url="http://test") as aclient: async with await anyio.open_file("audio.wav", "rb") as f: data = await f.read() task = asyncio.create_task( aclient.post( "/v1/audio/transcriptions", files={"file": ("audio.wav", data, "audio/wav")}, data={"model": model} ) ) await asyncio.sleep(0.01) res = await aclient.delete(f"/api/ps/{model}") assert res.status_code == 409 await task res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0 @pytest.mark.asyncio async def test_model_cant_be_loaded_twice() -> None: ttl = -1 model = "Systran/faster-whisper-tiny.en" os.environ["ENABLE_UI"] = "false" os.environ["WHISPER__TTL"] = str(ttl) async with AsyncClient(transport=ASGITransport(app=create_app()), base_url="http://test") as aclient: res = await aclient.post(f"/api/ps/{model}") assert res.status_code == 201 res = await aclient.post(f"/api/ps/{model}") assert res.status_code == 409 res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 @pytest.mark.asyncio async def test_model_is_unloaded_after_request_when_ttl_is_zero() -> None: ttl = 0 os.environ["WHISPER__MODEL"] = "Systran/faster-whisper-tiny.en" os.environ["WHISPER__TTL"] = str(ttl) os.environ["ENABLE_UI"] = "false" async with AsyncClient(transport=ASGITransport(app=create_app()), base_url="http://test") as aclient: async with await anyio.open_file("audio.wav", "rb") as f: data = await f.read() res = await aclient.post( "/v1/audio/transcriptions", files={"file": ("audio.wav", data, "audio/wav")}, data={"model": "Systran/faster-whisper-tiny.en"}, ) res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up