jhj0517 commited on
Commit
f8c31ce
β€’
2 Parent(s): be569ea 3a1a0a3

Merge pull request #150 from jhj0517/feature/add-params

Browse files
app.py CHANGED
@@ -8,7 +8,7 @@ from modules.nllb_inference import NLLBInference
8
  from ui.htmls import *
9
  from modules.youtube_manager import get_ytmetas
10
  from modules.deepl_api import DeepLAPI
11
- from modules.whisper_data_class import *
12
 
13
 
14
  class App:
@@ -67,6 +67,7 @@ class App:
67
  nb_patience = gr.Number(label="Patience", value=1, interactive=True)
68
  cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=True, interactive=True)
69
  tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True)
 
70
  with gr.Row():
71
  btn_run = gr.Button("GENERATE SUBTITLE FILE", variant="primary")
72
  with gr.Row():
@@ -85,7 +86,8 @@ class App:
85
  best_of=nb_best_of,
86
  patience=nb_patience,
87
  condition_on_previous_text=cb_condition_on_previous_text,
88
- initial_prompt=tb_initial_prompt)
 
89
  btn_run.click(fn=self.whisper_inf.transcribe_file,
90
  inputs=params + whisper_params.to_list(),
91
  outputs=[tb_indicator, files_subtitles])
@@ -121,6 +123,7 @@ class App:
121
  nb_patience = gr.Number(label="Patience", value=1, interactive=True)
122
  cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=True, interactive=True)
123
  tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True)
 
124
  with gr.Row():
125
  btn_run = gr.Button("GENERATE SUBTITLE FILE", variant="primary")
126
  with gr.Row():
@@ -139,7 +142,8 @@ class App:
139
  best_of=nb_best_of,
140
  patience=nb_patience,
141
  condition_on_previous_text=cb_condition_on_previous_text,
142
- initial_prompt=tb_initial_prompt)
 
143
  btn_run.click(fn=self.whisper_inf.transcribe_youtube,
144
  inputs=params + whisper_params.to_list(),
145
  outputs=[tb_indicator, files_subtitles])
@@ -168,6 +172,7 @@ class App:
168
  nb_patience = gr.Number(label="Patience", value=1, interactive=True)
169
  cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=True, interactive=True)
170
  tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True)
 
171
  with gr.Row():
172
  btn_run = gr.Button("GENERATE SUBTITLE FILE", variant="primary")
173
  with gr.Row():
@@ -186,7 +191,8 @@ class App:
186
  best_of=nb_best_of,
187
  patience=nb_patience,
188
  condition_on_previous_text=cb_condition_on_previous_text,
189
- initial_prompt=tb_initial_prompt)
 
190
  btn_run.click(fn=self.whisper_inf.transcribe_mic,
191
  inputs=params + whisper_params.to_list(),
192
  outputs=[tb_indicator, files_subtitles])
 
8
  from ui.htmls import *
9
  from modules.youtube_manager import get_ytmetas
10
  from modules.deepl_api import DeepLAPI
11
+ from modules.whisper_parameter import *
12
 
13
 
14
  class App:
 
67
  nb_patience = gr.Number(label="Patience", value=1, interactive=True)
68
  cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=True, interactive=True)
69
  tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True)
70
+ sd_temperature = gr.Slider(label="Temperature", value=0, step=0.01, maximum=1.0, interactive=True)
71
  with gr.Row():
72
  btn_run = gr.Button("GENERATE SUBTITLE FILE", variant="primary")
73
  with gr.Row():
 
86
  best_of=nb_best_of,
87
  patience=nb_patience,
88
  condition_on_previous_text=cb_condition_on_previous_text,
89
+ initial_prompt=tb_initial_prompt,
90
+ temperature=sd_temperature)
91
  btn_run.click(fn=self.whisper_inf.transcribe_file,
92
  inputs=params + whisper_params.to_list(),
93
  outputs=[tb_indicator, files_subtitles])
 
123
  nb_patience = gr.Number(label="Patience", value=1, interactive=True)
124
  cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=True, interactive=True)
125
  tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True)
126
+ sd_temperature = gr.Slider(label="Temperature", value=0, step=0.01, maximum=1.0, interactive=True)
127
  with gr.Row():
128
  btn_run = gr.Button("GENERATE SUBTITLE FILE", variant="primary")
129
  with gr.Row():
 
142
  best_of=nb_best_of,
143
  patience=nb_patience,
144
  condition_on_previous_text=cb_condition_on_previous_text,
145
+ initial_prompt=tb_initial_prompt,
146
+ temperature=sd_temperature)
147
  btn_run.click(fn=self.whisper_inf.transcribe_youtube,
148
  inputs=params + whisper_params.to_list(),
149
  outputs=[tb_indicator, files_subtitles])
 
172
  nb_patience = gr.Number(label="Patience", value=1, interactive=True)
173
  cb_condition_on_previous_text = gr.Checkbox(label="Condition On Previous Text", value=True, interactive=True)
174
  tb_initial_prompt = gr.Textbox(label="Initial Prompt", value=None, interactive=True)
175
+ sd_temperature = gr.Slider(label="Temperature", value=0, step=0.01, maximum=1.0, interactive=True)
176
  with gr.Row():
177
  btn_run = gr.Button("GENERATE SUBTITLE FILE", variant="primary")
178
  with gr.Row():
 
191
  best_of=nb_best_of,
192
  patience=nb_patience,
193
  condition_on_previous_text=cb_condition_on_previous_text,
194
+ initial_prompt=tb_initial_prompt,
195
+ temperature=sd_temperature)
196
  btn_run.click(fn=self.whisper_inf.transcribe_mic,
197
  inputs=params + whisper_params.to_list(),
198
  outputs=[tb_indicator, files_subtitles])
modules/faster_whisper_inference.py CHANGED
@@ -14,7 +14,7 @@ import gradio as gr
14
  from .base_interface import BaseInterface
15
  from modules.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
16
  from modules.youtube_manager import get_ytdata, get_ytaudio
17
- from modules.whisper_data_class import *
18
 
19
  # Temporal fix of the issue : https://github.com/jhj0517/Whisper-WebUI/issues/144
20
  os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
@@ -268,7 +268,8 @@ class FasterWhisperInference(BaseInterface):
268
  log_prob_threshold=params.log_prob_threshold,
269
  no_speech_threshold=params.no_speech_threshold,
270
  best_of=params.best_of,
271
- patience=params.patience
 
272
  )
273
  progress(0, desc="Loading audio..")
274
 
 
14
  from .base_interface import BaseInterface
15
  from modules.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
16
  from modules.youtube_manager import get_ytdata, get_ytaudio
17
+ from modules.whisper_parameter import *
18
 
19
  # Temporal fix of the issue : https://github.com/jhj0517/Whisper-WebUI/issues/144
20
  os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
 
268
  log_prob_threshold=params.log_prob_threshold,
269
  no_speech_threshold=params.no_speech_threshold,
270
  best_of=params.best_of,
271
+ patience=params.patience,
272
+ temperature=params.temperature
273
  )
274
  progress(0, desc="Loading audio..")
275
 
modules/whisper_Inference.py CHANGED
@@ -10,7 +10,7 @@ import torch
10
  from .base_interface import BaseInterface
11
  from modules.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
12
  from modules.youtube_manager import get_ytdata, get_ytaudio
13
- from modules.whisper_data_class import *
14
 
15
  DEFAULT_MODEL_SIZE = "large-v3"
16
 
@@ -257,6 +257,7 @@ class WhisperInference(BaseInterface):
257
  fp16=True if params.compute_type == "float16" else False,
258
  best_of=params.best_of,
259
  patience=params.patience,
 
260
  progress_callback=progress_callback)["segments"]
261
  elapsed_time = time.time() - start_time
262
 
 
10
  from .base_interface import BaseInterface
11
  from modules.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
12
  from modules.youtube_manager import get_ytdata, get_ytaudio
13
+ from modules.whisper_parameter import *
14
 
15
  DEFAULT_MODEL_SIZE = "large-v3"
16
 
 
257
  fp16=True if params.compute_type == "float16" else False,
258
  best_of=params.best_of,
259
  patience=params.patience,
260
+ temperature=params.temperature,
261
  progress_callback=progress_callback)["segments"]
262
  elapsed_time = time.time() - start_time
263
 
modules/{whisper_data_class.py β†’ whisper_parameter.py} RENAMED
@@ -16,9 +16,10 @@ class WhisperGradioComponents:
16
  patience: gr.Number
17
  condition_on_previous_text: gr.Checkbox
18
  initial_prompt: gr.Textbox
 
19
  """
20
- A data class to pass Gradio components to the function before Gradio pre-processing.
21
- See this documentation for more information about Gradio pre-processing: https://www.gradio.app/docs/components
22
 
23
  Attributes
24
  ----------
@@ -62,12 +63,16 @@ class WhisperGradioComponents:
62
  Optional text to provide as a prompt for the first window. This can be used to provide, or
63
  "prompt-engineer" a context for transcription, e.g. custom vocabularies or proper nouns
64
  to make it more likely to predict those word correctly.
 
 
 
 
65
  """
66
 
67
  def to_list(self) -> list:
68
  """
69
- Converts the data class attributes into a list, to pass parameters to a
70
- button click event function before Gradio pre-processing.
71
 
72
  Returns
73
  ----------
@@ -89,7 +94,8 @@ class WhisperValues:
89
  patience: float
90
  condition_on_previous_text: bool
91
  initial_prompt: Optional[str]
 
92
  """
93
- A data class to use Whisper parameters in your function after Gradio pre-processing.
94
- See this documentation for more information about Gradio pre-processing: : https://www.gradio.app/docs/components
95
  """
 
16
  patience: gr.Number
17
  condition_on_previous_text: gr.Checkbox
18
  initial_prompt: gr.Textbox
19
+ temperature: gr.Slider
20
  """
21
+ A data class for Gradio components of the Whisper Parameters. Use "before" Gradio pre-processing.
22
+ See more about Gradio pre-processing: https://www.gradio.app/docs/components
23
 
24
  Attributes
25
  ----------
 
63
  Optional text to provide as a prompt for the first window. This can be used to provide, or
64
  "prompt-engineer" a context for transcription, e.g. custom vocabularies or proper nouns
65
  to make it more likely to predict those word correctly.
66
+
67
+ temperature: Temperature for sampling. It can be a tuple of temperatures,
68
+ which will be successively used upon failures according to either
69
+ `compression_ratio_threshold` or `log_prob_threshold`.
70
  """
71
 
72
  def to_list(self) -> list:
73
  """
74
+ Converts the data class attributes into a list. Use "before" Gradio pre-processing.
75
+ See more about Gradio pre-processing: : https://www.gradio.app/docs/components
76
 
77
  Returns
78
  ----------
 
94
  patience: float
95
  condition_on_previous_text: bool
96
  initial_prompt: Optional[str]
97
+ temperature: float
98
  """
99
+ A data class to use Whisper parameters. Use "after" Gradio pre-processing.
100
+ See more about Gradio pre-processing: : https://www.gradio.app/docs/components
101
  """