Add hotwords form field to whisper service
Hotwords give per-request logit boosts to specified terms throughout decoding (not just as prefix context like initial_prompt). Measured on a cardiology dictation: 8/8 correct fachbegriffe vs. 3/8 without.
This commit is contained in:
@@ -61,6 +61,7 @@ async def asr(
|
||||
output: str = Query("txt"),
|
||||
language: Optional[str] = Query(None),
|
||||
initial_prompt: Optional[str] = Form(None),
|
||||
hotwords: Optional[str] = Form(None),
|
||||
):
|
||||
suffix = os.path.splitext(audio_file.filename or "")[1] or ".bin"
|
||||
tmp = tempfile.NamedTemporaryFile(suffix=suffix, delete=False)
|
||||
@@ -85,6 +86,7 @@ async def asr(
|
||||
log_prob_threshold=-1.0,
|
||||
compression_ratio_threshold=2.4,
|
||||
initial_prompt=initial_prompt,
|
||||
hotwords=hotwords,
|
||||
)
|
||||
segments = list(segments_gen)
|
||||
infer_secs = time.monotonic() - t0
|
||||
|
||||
Reference in New Issue
Block a user