Skip to content

Config

config

Defines helpers for environment and capability detection

The capability helpers let the Processor route per capability by checking which optional dependencies are installed (via importlib.util.find_spec) and which environment variables are configured, without importing the heavy packages themselves

Settings dataclass

Resolved, environment-dependent server configuration

Attributes:

Name Type Description
logging_level str

Python logging level name

modal_gpu str

GPU type requested for Modal jobs

modal_image str

Docker image used for Modal containers

srt_sys_msg str

System message for SRT-fixing

breakdown_sys_msg str

System message for word-nuance breakdowns

env_present(*keys)

Check whether every given environment variable (*keys) is set and non-empty

Parameters:

Name Type Description Default
*keys str

Environment variable names to require

()

Returns:

Type Description
bool

True only if all named variables are present and non-empty

get_settings() cached

Resolves environment-dependent settings once, after loading .env

Reads the environment lazily (not at import) so that values reflect a .env loaded at startup + variables that the launcher sets before the process starts. Cached for the process lifetime

Returns:

Type Description
Settings

The resolved Settings

get_system_info()

Uses os, socket, and platform to collect basic information about the system running the program

Returns:

Type Description
dict[str, Any]

dict with information about the system

gpu_available()

Checks whether a CUDA GPU is available to the local transcription engine (CTranslate2, which powers faster-whisper)

Return Values

This function returns a dictionary with the following keys

  • available (bool)True if ctranslate2 is installed and reports at least one usable CUDA device, False otherwise

  • name (str) → the device name from nvidia-smi when it can be queried, '' otherwise

Returns:

Type Description
dict[str, bool | str]

dict with keys "available" and "name"

has_module(name)

Checks whether an importable module is installed without importing it

Parameters:

Name Type Description Default
name str

Top-level module/package name (e.g. "faster_whisper")

required

Returns:

Type Description
bool

True if the module can be located on the import path

nvenc_available(ffmpeg_path)

Checks whether the NVIDIA NVENC H.264 encoder is actually usable by the given FFMPEG build on the current machine

Why A Real Probe
  • A CUDA device being present (gpu_available) does not mean an encoder exists. The data center compute GPUs (A100, H100, Bx00) expose NVDEC for decoding but have no NVENC encoder at all

  • This runs a tiny synthetic encode and checks the exit code, so it reports the true capability of whatever GPU and FFMPEG build are present instead of guessing from a hard-coded GPU list

Where To Call It
  • Run this in the same process that runs the conversion, since that is where FFMPEG actually executes

  • For the local backend that is the host, for the modal backend that is the GPU container

Parameters:

Name Type Description Default
ffmpeg_path str

Path to the system's FFMPEG executable

required

Returns:

Type Description
bool

True if h264_nvenc initialises and encodes a probe frame, False otherwise

transcribe_backend()

Resolves which transcription backend the server should use

Transcribe Backend
  • Reads MIRUMOJI_TRANSCRIBE_BACKEND (auto | local | modal)

  • auto or unset picks modal when Modal tokens are configured, or local when faster-whisper is installed, otherwise none

  • Explicit local or modal overrides are validated and raise when that backend isn't available

Returns:

Type Description
Literal['local', 'modal', 'none']

The resolved backend identifier

Raises:

Type Description
WhisperUnavailableError

If local is forced but faster-whisper isn't installed

ModalError

If modal is forced but Modal tokens aren't configured

ValueError

If the variable holds an unrecognised value

using_modal()

Checks if MODAL_TOKEN_ID and MODAL_TOKEN_SECRET variables are present in the environment

Returns:

Type Description
bool

True if variables are present, False otherwise

whisper_local_available()

Checks whether local Whisper transcription is possible in this deployment

Returns:

Type Description
bool

True if faster-whisper is installed