avans06 commited on
Commit
90ee2b3
1 Parent(s): b563d75

When the transcribe whisper language is set to Chinese,

Browse files

the initial prompt is automatically added "繁體: ",
and the initial prompt mode is set to "prepend_all_segments"

Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -102,10 +102,14 @@ class WhisperTranscriber:
102
  vad, vadMergeWindow, vadMaxMergeSize,
103
  word_timestamps: bool = False, highlight_words: bool = False,
104
  progress=gr.Progress()):
105
-
 
 
 
106
  vadOptions = VadOptions(vad, vadMergeWindow, vadMaxMergeSize, self.app_config.vad_padding, self.app_config.vad_prompt_window, self.app_config.vad_initial_prompt_mode)
107
 
108
  return self.transcribe_webui(modelName, languageName, urlData, multipleFiles, microphoneData, task, vadOptions,
 
109
  word_timestamps=word_timestamps, highlight_words=highlight_words, progress=progress)
110
 
111
  # Entry function for the full tab
@@ -140,6 +144,10 @@ class WhisperTranscriber:
140
  else:
141
  temperature = [temperature]
142
 
 
 
 
 
143
  vadOptions = VadOptions(vad, vadMergeWindow, vadMaxMergeSize, vadPadding, vadPromptWindow, vadInitialPromptMode)
144
 
145
  return self.transcribe_webui(modelName, languageName, urlData, multipleFiles, microphoneData, task, vadOptions,
 
102
  vad, vadMergeWindow, vadMaxMergeSize,
103
  word_timestamps: bool = False, highlight_words: bool = False,
104
  progress=gr.Progress()):
105
+ if languageName == "Chinese":
106
+ initial_prompt = "繁體: "
107
+ self.app_config.vad_initial_prompt_mode = "prepend_all_segments"
108
+
109
  vadOptions = VadOptions(vad, vadMergeWindow, vadMaxMergeSize, self.app_config.vad_padding, self.app_config.vad_prompt_window, self.app_config.vad_initial_prompt_mode)
110
 
111
  return self.transcribe_webui(modelName, languageName, urlData, multipleFiles, microphoneData, task, vadOptions,
112
+ initial_prompt=initial_prompt,
113
  word_timestamps=word_timestamps, highlight_words=highlight_words, progress=progress)
114
 
115
  # Entry function for the full tab
 
144
  else:
145
  temperature = [temperature]
146
 
147
+ if languageName == "Chinese":
148
+ initial_prompt = "繁體: " + initial_prompt
149
+ self.app_config.vad_initial_prompt_mode = "prepend_all_segments"
150
+
151
  vadOptions = VadOptions(vad, vadMergeWindow, vadMaxMergeSize, vadPadding, vadPromptWindow, vadInitialPromptMode)
152
 
153
  return self.transcribe_webui(modelName, languageName, urlData, multipleFiles, microphoneData, task, vadOptions,