Configuration
Note
Also checkout customizing HuggingFace behaviour
Bases: 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__INFERENCE_DEVICE
(note the double underscore) to whisper.inference_device
, to set quantization to int8, use WHISPER__COMPUTE_TYPE=int8
, etc.
Source code in src/speaches/config.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
api_key
api_key: SecretStr | None = None
If set, the API key will be required for all requests.
log_level
log_level: str = 'debug'
Logging level. One of: 'debug', 'info', 'warning', 'error', 'critical'.
host
host: str = Field(alias='UVICORN_HOST', default='0.0.0.0')
port
port: int = Field(alias='UVICORN_PORT', default=8000)
allow_origins
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
enable_ui: bool = True
Whether to enable the Gradio UI. You may want to disable this if you want to minimize the dependencies and slightly improve the startup time.
loopback_host_url
loopback_host_url: str | None = None
If set this is the URL that the gradio app will use to connect to the API server hosting speaches. If not set the gradio app will use the url that the user connects to the gradio app on.
chat_completion_base_url
chat_completion_base_url: str = 'http://localhost:11434/v1'
chat_completion_api_key
chat_completion_api_key: SecretStr = SecretStr(
"cant-be-empty"
)
Bases: BaseModel
See https://github.com/SYSTRAN/faster-whisper/blob/master/faster_whisper/transcribe.py#L599.
Source code in src/speaches/config.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
ttl: int = Field(default=300, ge=-1)
class-attribute
instance-attribute
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.
use_batched_mode: bool = False
class-attribute
instance-attribute
Whether to use batch mode(introduced in 1.1.0 faster-whisper
release) for inference. This will likely become the default in the future and the configuration option will be removed.