Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

feat(subtitle): make whisper initial_prompt configurable

Andres Paez Ortiz258882171931
diff --git a/app/services/subtitle.py b/app/services/subtitle.py
index 772a04d3..0af875ba 100644
--- a/app/services/subtitle.py
+++ b/app/services/subtitle.py
@@ -15,6 +15,7 @@ from app.utils import utils
model_size = config.whisper.get("model_size", "large-v3")
device = config.whisper.get("device", "cpu")
compute_type = config.whisper.get("compute_type", "int8")
+initial_prompt = config.whisper.get("initial_prompt", "") or None
model = None
@@ -57,6 +58,7 @@ def create(audio_file, subtitle_file: str = ""):
word_timestamps=True,
vad_filter=True,
vad_parameters=dict(min_silence_duration_ms=500),
+ **({"initial_prompt": initial_prompt} if initial_prompt else {}),
)
logger.info(
diff --git a/config.example.toml b/config.example.toml
index eb1d6fd1..8a0142d9 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -284,6 +284,10 @@ model_size = "large-v3"
# "float16" or "int8_float16" for CUDA.
device = "cpu"
compute_type = "int8"
+# Optional prompt that biases Whisper's decoder toward specific vocabulary
+# (brand names, technical terms). Passed as initial_prompt to transcribe().
+# Leave empty to disable.
+# initial_prompt = ""
# =============================================================================
# Material Request Proxy / 素材请求代理