Skip to content

Commit

Permalink
Merge pull request #92 from hcljsq/main
Browse files Browse the repository at this point in the history
feat: set initial_prompt and vad_parameters in the first message
  • Loading branch information
makaveli10 authored Jan 9, 2024
2 parents 7b2f5cf + 72ead71 commit cafcb04
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions whisper_live/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def recv_audio(self, websocket):
language=options["language"],
task=options["task"],
client_uid=options["uid"],
model_size=options["model_size"]
model_size=options["model_size"],
initial_prompt=options["initial_prompt"],
vad_parameters=options["vad_parameters"]
)

self.clients[websocket] = client
Expand Down Expand Up @@ -190,7 +192,9 @@ def __init__(
multilingual=False,
language=None,
client_uid=None,
model_size="small"
model_size="small",
initial_prompt=None,
vad_parameters=None
):
"""
Initialize a ServeClient instance.
Expand Down Expand Up @@ -218,6 +222,8 @@ def __init__(
self.language = language if self.multilingual else "en"
self.task = task
self.websocket = websocket
self.initial_prompt = initial_prompt
self.vad_parameters = vad_parameters or {"threshold": 0.5}

device = "cuda" if torch.cuda.is_available() else "cpu"

Expand Down Expand Up @@ -352,11 +358,11 @@ def speech_to_text(self):
# whisper transcribe with prompt
result, info = self.transcriber.transcribe(
input_sample,
initial_prompt=None,
initial_prompt=self.initial_prompt,
language=self.language,
task=self.task,
vad_filter=True,
vad_parameters={"threshold": 0.5}
vad_parameters=self.vad_parameters
)

if self.language is None:
Expand Down

0 comments on commit cafcb04

Please sign in to comment.