Skip to content

Commit

Permalink
misc: add vad_filter form field
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi authored and fedirz committed Sep 30, 2024
1 parent 1af5898 commit 7f36990
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/faster_whisper_server/routers/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def translate_file(
response_format: Annotated[ResponseFormat | None, Form()] = None,
temperature: Annotated[float, Form()] = 0.0,
stream: Annotated[bool, Form()] = False,
vad_filter: Annotated[bool, Form()] = False,
) -> Response | StreamingResponse:
if model is None:
model = config.whisper.model
Expand All @@ -147,7 +148,7 @@ def translate_file(
task=Task.TRANSLATE,
initial_prompt=prompt,
temperature=temperature,
vad_filter=True,
vad_filter=vad_filter,
)
segments = TranscriptionSegment.from_faster_whisper_segments(segments)

Expand Down Expand Up @@ -192,6 +193,7 @@ def transcribe_file(
] = ["segment"],
stream: Annotated[bool, Form()] = False,
hotwords: Annotated[str | None, Form()] = None,
vad_filter: Annotated[bool, Form()] = False,
) -> Response | StreamingResponse:
if model is None:
model = config.whisper.model
Expand All @@ -212,7 +214,7 @@ def transcribe_file(
initial_prompt=prompt,
word_timestamps="word" in timestamp_granularities,
temperature=temperature,
vad_filter=True,
vad_filter=vad_filter,
hotwords=hotwords,
)
segments = TranscriptionSegment.from_faster_whisper_segments(segments)
Expand Down Expand Up @@ -263,6 +265,7 @@ async def transcribe_stream(
language: Annotated[Language | None, Query()] = None,
response_format: Annotated[ResponseFormat | None, Query()] = None,
temperature: Annotated[float, Query()] = 0.0,
vad_filter: Annotated[bool, Query()] = False,
) -> None:
if model is None:
model = config.whisper.model
Expand All @@ -274,7 +277,7 @@ async def transcribe_stream(
transcribe_opts = {
"language": language,
"temperature": temperature,
"vad_filter": True,
"vad_filter": vad_filter,
"condition_on_previous_text": False,
}
whisper = model_manager.load_model(model)
Expand Down

0 comments on commit 7f36990

Please sign in to comment.