• 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_speachessrcfaster_whisper_serverconfig.py
Download as .zip file
File name
Commit message
Commit date
.github/workflows
chore(deps): update astral-sh/setup-uv action to v3
2024-10-13
docs
docs: initialize mkdocs
2024-10-03
examples
Update script.sh
2024-09-03
scripts
chore: misc changes
2024-10-03
src/speaches
chore: include line number in log messages
2024-11-01
tests
feat: model unloading
2024-10-01
.dockerignore
chore: ignore .env
2024-05-27
.envrc
init
2024-05-20
.gitattributes
docs: add live-transcription demo
2024-05-28
.gitignore
chore: update .gitignore
2024-07-03
.pre-commit-config.yaml
fix: pre-commit basedpyright not checking all files
2024-10-01
Dockerfile.cpu
chore(deps): update ghcr.io/astral-sh/uv docker tag to v0.4.20
2024-10-13
Dockerfile.cuda
chore(deps): update ghcr.io/astral-sh/uv docker tag to v0.4.20
2024-10-13
LICENSE
init
2024-05-20
README.md
Improved readability in README.md
2024-10-09
Taskfile.yaml
feat: dependency injection
2024-09-22
audio.wav
docs: update README.md
2024-05-27
compose.yaml
chore: format compose
2024-09-11
flake.lock
deps: update flake
2024-10-01
flake.nix
Add `pre-commit` to pyproject.toml
2024-10-13
mkdocs.yml
docs: initialize mkdocs
2024-10-03
pyproject.toml
chore: pytest ignore deprecation warnings
2024-11-01
renovate.json
Add renovate.json
2024-10-13
uv.lock
deps: minor python package updates
2024-11-01
File name
Commit message
Commit date
routers
chore: misc changes
2024-10-03
__init__.py
feat: use `uv` package manager, pin dependencies
2024-09-08
api_models.py
refactor: update response model names and module name
2024-10-01
asr.py
refactor: update response model names and module name
2024-10-01
audio.py
feat: dependency injection
2024-09-22
config.py
feat: model unloading
2024-10-01
dependencies.py
feat: model unloading
2024-10-01
gradio_app.py
chore: fix some ruff errors
2024-10-01
hf_utils.py
feat: dependency injection
2024-09-22
logger.py
chore: include line number in log messages
2024-11-01
main.py
feat: dependency injection
2024-09-22
model_manager.py
feat: model unloading
2024-10-01
text_utils.py
refactor: update response model names and module name
2024-10-01
text_utils_test.py
refactor: update response model names and module name
2024-10-01
transcriber.py
refactor: update response model names and module name
2024-10-01
Fedir Zadniprovskyi 2024-10-01 94cc919 feat: model unloading UNIX
Raw Open in browser Change history
import enum from pydantic import BaseModel, Field from pydantic_settings import BaseSettings, SettingsConfigDict SAMPLES_PER_SECOND = 16000 BYTES_PER_SAMPLE = 2 BYTES_PER_SECOND = SAMPLES_PER_SECOND * BYTES_PER_SAMPLE # 2 BYTES = 16 BITS = 1 SAMPLE # 1 SECOND OF AUDIO = 32000 BYTES = 16000 SAMPLES # https://platform.openai.com/docs/api-reference/audio/createTranscription#audio-createtranscription-response_format class ResponseFormat(enum.StrEnum): TEXT = "text" JSON = "json" VERBOSE_JSON = "verbose_json" SRT = "srt" VTT = "vtt" class Device(enum.StrEnum): CPU = "cpu" CUDA = "cuda" AUTO = "auto" # https://github.com/OpenNMT/CTranslate2/blob/master/docs/quantization.md class Quantization(enum.StrEnum): INT8 = "int8" INT8_FLOAT16 = "int8_float16" INT8_BFLOAT16 = "int8_bfloat16" INT8_FLOAT32 = "int8_float32" INT16 = "int16" FLOAT16 = "float16" BFLOAT16 = "bfloat16" FLOAT32 = "float32" DEFAULT = "default" class Language(enum.StrEnum): AF = "af" AM = "am" AR = "ar" AS = "as" AZ = "az" BA = "ba" BE = "be" BG = "bg" BN = "bn" BO = "bo" BR = "br" BS = "bs" CA = "ca" CS = "cs" CY = "cy" DA = "da" DE = "de" EL = "el" EN = "en" ES = "es" ET = "et" EU = "eu" FA = "fa" FI = "fi" FO = "fo" FR = "fr" GL = "gl" GU = "gu" HA = "ha" HAW = "haw" HE = "he" HI = "hi" HR = "hr" HT = "ht" HU = "hu" HY = "hy" ID = "id" IS = "is" IT = "it" JA = "ja" JW = "jw" KA = "ka" KK = "kk" KM = "km" KN = "kn" KO = "ko" LA = "la" LB = "lb" LN = "ln" LO = "lo" LT = "lt" LV = "lv" MG = "mg" MI = "mi" MK = "mk" ML = "ml" MN = "mn" MR = "mr" MS = "ms" MT = "mt" MY = "my" NE = "ne" NL = "nl" NN = "nn" NO = "no" OC = "oc" PA = "pa" PL = "pl" PS = "ps" PT = "pt" RO = "ro" RU = "ru" SA = "sa" SD = "sd" SI = "si" SK = "sk" SL = "sl" SN = "sn" SO = "so" SQ = "sq" SR = "sr" SU = "su" SV = "sv" SW = "sw" TA = "ta" TE = "te" TG = "tg" TH = "th" TK = "tk" TL = "tl" TR = "tr" TT = "tt" UK = "uk" UR = "ur" UZ = "uz" VI = "vi" YI = "yi" YO = "yo" YUE = "yue" ZH = "zh" class Task(enum.StrEnum): TRANSCRIBE = "transcribe" TRANSLATE = "translate" class WhisperConfig(BaseModel): """See https://github.com/SYSTRAN/faster-whisper/blob/master/faster_whisper/transcribe.py#L599.""" model: str = Field(default="Systran/faster-whisper-small") """ Default Huggingface model to use for transcription. Note, the model must support being ran using CTranslate2. This model will be used if no model is specified in the request. Models created by authors of `faster-whisper` can be found at https://huggingface.co/Systran You can find other supported models at https://huggingface.co/models?p=2&sort=trending&search=ctranslate2 and https://huggingface.co/models?sort=trending&search=ct2 """ inference_device: Device = Field(default=Device.AUTO) device_index: int | list[int] = 0 compute_type: Quantization = Field(default=Quantization.DEFAULT) cpu_threads: int = 0 num_workers: int = 1 ttl: int = Field(default=300, ge=-1) """ Time in seconds until the model is unloaded if it is not being used. -1: Never unload the model. 0: Unload the model immediately after usage. """ class Config(BaseSettings): """Configuration for the application. Values can be set via environment variables. Pydantic will automatically handle mapping uppercased environment variables to the corresponding fields. To populate nested, the environment should be prefixed with the nested field name and an underscore. For example, the environment variable `LOG_LEVEL` will be mapped to `log_level`, `WHISPER__MODEL`(note the double underscore) to `whisper.model`, to set quantization to int8, use `WHISPER__COMPUTE_TYPE=int8`, etc. """ # noqa: E501 model_config = SettingsConfigDict(env_nested_delimiter="__") log_level: str = "debug" host: str = Field(alias="UVICORN_HOST", default="0.0.0.0") port: int = Field(alias="UVICORN_PORT", default=8000) allow_origins: list[str] | None = None """ https://docs.pydantic.dev/latest/concepts/pydantic_settings/#parsing-environment-variable-values Usage: `export ALLOW_ORIGINS='["http://localhost:3000", "http://localhost:3001"]'` `export ALLOW_ORIGINS='["*"]'` """ enable_ui: bool = True """ Whether to enable the Gradio UI. You may want to disable this if you want to minimize the dependencies. """ default_language: Language | None = None """ Default language to use for transcription. If not set, the language will be detected automatically. It is recommended to set this as it will improve the performance. """ default_response_format: ResponseFormat = ResponseFormat.JSON whisper: WhisperConfig = WhisperConfig() preload_models: list[str] = Field( default_factory=list, examples=[ ["Systran/faster-whisper-small"], ["Systran/faster-whisper-medium.en", "Systran/faster-whisper-small.en"], ], ) """ List of models to preload on startup. By default, the model is first loaded on first request. """ max_no_data_seconds: float = 1.0 """ Max duration to wait for the next audio chunk before transcription is finilized and connection is closed. """ min_duration: float = 1.0 """ Minimum duration of an audio chunk that will be transcribed. """ word_timestamp_error_margin: float = 0.2 max_inactivity_seconds: float = 2.5 """ Max allowed audio duration without any speech being detected before transcription is finilized and connection is closed. """ # noqa: E501 inactivity_window_seconds: float = 5.0 """ Controls how many latest seconds of audio are being passed through VAD. Should be greater than `max_inactivity_seconds` """

          
        
    
    
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