Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial_prompt easily accessible #283

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ client = TranscriptionClient(
use_vad=False,
save_output_recording=True, # Only used for microphone input, False by Default
output_recording_filename="./output_recording.wav", # Only used for microphone input
options={
'initial_prompt': None, #To add context replace None with any context for the model like this: 'Jane Doe context'
},
max_clients=4,
max_connection_time=600
)
Expand Down
7 changes: 6 additions & 1 deletion whisper_live/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
srt_file_path="output.srt",
use_vad=True,
log_transcription=True,
options=None,
max_clients=4,
max_connection_time=600,
):
Expand Down Expand Up @@ -61,9 +62,11 @@ def __init__(
self.last_segment = None
self.last_received_segment = None
self.log_transcription = log_transcription
self.options = options
self.max_clients = max_clients
self.max_connection_time = max_connection_time


if translate:
self.task = "translate"

Expand Down Expand Up @@ -204,6 +207,7 @@ def on_open(self, ws):
"task": self.task,
"model": self.model,
"use_vad": self.use_vad,
"options": self.options,
"max_clients": self.max_clients,
"max_connection_time": self.max_connection_time,
}
Expand Down Expand Up @@ -687,12 +691,13 @@ def __init__(
output_recording_filename="./output_recording.wav",
output_transcription_path="./output.srt",
log_transcription=True,
options=None,
max_clients=4,
max_connection_time=600,
):
self.client = Client(
host, port, lang, translate, model, srt_file_path=output_transcription_path,
use_vad=use_vad, log_transcription=log_transcription, max_clients=max_clients,
use_vad=use_vad, log_transcription=log_transcription, options=options, max_clients=max_clients,
max_connection_time=max_connection_time
)

Expand Down
4 changes: 2 additions & 2 deletions whisper_live/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def initialize_client(
task=options["task"],
client_uid=options["uid"],
model=options["model"],
initial_prompt=options.get("initial_prompt"),
vad_parameters=options.get("vad_parameters"),
initial_prompt=options["options"].get("initial_prompt"),
vad_parameters=options["options"].get("vad_parameters"),
use_vad=self.use_vad,
single_model=self.single_model,
)
Expand Down
Loading