Skip to main content

FastAPI service plugin for fasr

Project description

fasr-service-fastapi

FastAPI service plugin for fasr. This package provides the concrete online service implementation while the core fasr package keeps only service base classes and registries.

Features

  • Demo web page:
    • GET / (same as GET /demo)
  • Optional batch transcription HTTP endpoints:
    • POST /transcribe
    • POST /inference
  • Optional realtime websocket endpoints:
    • GET /v1/realtime
    • GET /api-ws/v1/realtime
  • Health endpoint:
    • GET /health
  • Config-driven model and router initialization through fasr registries

Registered entry points

Group Name Entry point
fasr_services fastapi.v1 fasr_service_fastapi.service:FastAPIASRService
fasr_service_routers transcribe.v1 fasr_service_fastapi.routers.transcribe:transcribe_entrypoint
fasr_service_routers realtime.v1 fasr_service_fastapi.routers.realtime:realtime_entrypoint

Configuration

The service owns model instances under [service.models]. Each router owns its own model_map, which maps router argument names to model names from [service.models]. Routers are enabled only when their config block exists, so omitting [service.transcribe_router] skips batch HTTP routes and omitting [service.realtime_router] skips realtime websocket routes. Configuring neither router is invalid and fasr serve will fail fast with a clear error.

[service]
@services = "fastapi.v1"
debug_logging = false

[service.models.qwen3_asr]
@asr_models = "qwen3asr"
size = "small"

[service.models.marblenet]
@vad_models = "marblenet"

[service.models.fsmn_online]
@vad_models = "fsmn_online"

[service.transcribe_router]
@service_routers = "transcribe.v1"

[service.transcribe_router.model_map]
vad_model = "marblenet"
asr_model = "qwen3_asr"

[service.realtime_router]
@service_routers = "realtime.v1"

[service.realtime_router.model_map]
vad_model = "fsmn_online"
asr_model = "qwen3_asr"

Set debug_logging = true if you want to keep the service's DEBUG logs during development.

For a transcribe-only service, remove the realtime router block:

[service]
@services = "fastapi.v1"

[service.models.paraformer]
@asr_models = "paraformer"

[service.models.marblenet]
@vad_models = "marblenet"

[service.models.ct_transformer]
@punc_models = "ct_transformer"

[service.transcribe_router]
@service_routers = "transcribe.v1"

[service.transcribe_router.model_map]
vad_model = "marblenet"
asr_model = "paraformer"
punc_model = "ct_transformer"

Router entry points are factory functions. For example, transcribe_entrypoint creates default AudioLoader, VoiceDetector, and SpeechRecognizer instances when the config only provides model_map. This avoids requiring users to spell out internal router components in simple service configs. When punc_model is present in the transcribe router model_map, the router also creates a default SpeechSentencizer and adds it after the recognizer.

CLI

Install the service plugin through the root project extra:

uv sync --extra service

Generate and run a default config:

fasr init --cfg run.cfg
fasr serve --cfg run.cfg

Inspect or write the default config without starting the server:

fasr serve --print_default_config true
fasr serve --write_default_config run.cfg

The same default config is available from:

from fasr_service_fastapi import FastAPIASRService

config = FastAPIASRService.model_construct().get_default_config()

Development

Install from the repository root:

uv sync

Run service tests:

uv run pytest tests/test_online_service.py -q

Build the plugin:

uv build --package fasr-service-fastapi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasr_service_fastapi-0.5.2.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasr_service_fastapi-0.5.2-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file fasr_service_fastapi-0.5.2.tar.gz.

File metadata

  • Download URL: fasr_service_fastapi-0.5.2.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fasr_service_fastapi-0.5.2.tar.gz
Algorithm Hash digest
SHA256 278bab73ed7e3df6f17e39cefff5acc06742e4cede02940c209aedd4646628ea
MD5 7511d31922dce2abf8d46b7d0911d785
BLAKE2b-256 d84cf8e1cbc1ac6194b2e66778a945e86df91ec6d2c974f609e4074ddffaa650

See more details on using hashes here.

File details

Details for the file fasr_service_fastapi-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: fasr_service_fastapi-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fasr_service_fastapi-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 954a334d54d0259d833eaec983de3a27367f43e5412287ff64099852b8039abc
MD5 b7e56137173d905c5643301735553619
BLAKE2b-256 2343a36bf4768705a7a8594f2eca3e052bbcd55f8a4c2fb828327aef395fc382

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page