added multilingual support for whisper

This commit is contained in:
Concedo 2025-01-09 23:28:52 +08:00
parent 0cb599546e
commit 91b6e29af3
6 changed files with 49 additions and 8 deletions

View file

@ -273,6 +273,7 @@ class whisper_generation_inputs(ctypes.Structure):
_fields_ = [("prompt", ctypes.c_char_p),
("audio_data", ctypes.c_char_p),
("suppress_non_speech", ctypes.c_bool),
("langcode", ctypes.c_char_p),
("quiet", ctypes.c_bool)]
class whisper_generation_outputs(ctypes.Structure):
@ -1252,6 +1253,9 @@ def whisper_generate(genparams):
inputs.prompt = prompt.encode("UTF-8")
inputs.audio_data = audio_data.encode("UTF-8")
inputs.quiet = is_quiet
lc = genparams.get("langcode", "auto")
lc = lc.strip().lower() if (lc and lc.strip().lower()!="") else "auto"
inputs.langcode = lc.encode("UTF-8")
inputs.suppress_non_speech = genparams.get("suppress_non_speech", False)
ret = handle.whisper_generate(inputs)
outstr = ""