Spaces:
Running
Running
Merge pull request #135 from jhj0517/fix/refactor
Browse files
modules/faster_whisper_inference.py
CHANGED
|
@@ -246,7 +246,7 @@ class FasterWhisperInference(BaseInterface):
|
|
| 246 |
"""
|
| 247 |
start_time = time.time()
|
| 248 |
|
| 249 |
-
params =
|
| 250 |
|
| 251 |
if params.model_size != self.current_model_size or self.model is None or self.current_compute_type != params.compute_type:
|
| 252 |
self.update_model(params.model_size, params.compute_type, progress)
|
|
|
|
| 246 |
"""
|
| 247 |
start_time = time.time()
|
| 248 |
|
| 249 |
+
params = WhisperValues(*whisper_params)
|
| 250 |
|
| 251 |
if params.model_size != self.current_model_size or self.model is None or self.current_compute_type != params.compute_type:
|
| 252 |
self.update_model(params.model_size, params.compute_type, progress)
|
modules/whisper_Inference.py
CHANGED
|
@@ -236,7 +236,7 @@ class WhisperInference(BaseInterface):
|
|
| 236 |
elapsed time for transcription
|
| 237 |
"""
|
| 238 |
start_time = time.time()
|
| 239 |
-
params =
|
| 240 |
|
| 241 |
if params.model_size != self.current_model_size or self.model is None or self.current_compute_type != params.compute_type:
|
| 242 |
self.update_model(params.model_size, params.compute_type, progress)
|
|
|
|
| 236 |
elapsed time for transcription
|
| 237 |
"""
|
| 238 |
start_time = time.time()
|
| 239 |
+
params = WhisperValues(*whisper_params)
|
| 240 |
|
| 241 |
if params.model_size != self.current_model_size or self.model is None or self.current_compute_type != params.compute_type:
|
| 242 |
self.update_model(params.model_size, params.compute_type, progress)
|
modules/whisper_data_class.py
CHANGED
|
@@ -45,7 +45,8 @@ class WhisperGradioComponents:
|
|
| 45 |
|
| 46 |
def to_list(self) -> list:
|
| 47 |
"""
|
| 48 |
-
Converts the data class attributes into a list, to pass parameters to a
|
|
|
|
| 49 |
|
| 50 |
Returns
|
| 51 |
----------
|
|
@@ -53,23 +54,6 @@ class WhisperGradioComponents:
|
|
| 53 |
"""
|
| 54 |
return [getattr(self, f.name) for f in fields(self)]
|
| 55 |
|
| 56 |
-
@staticmethod
|
| 57 |
-
def to_values(*params):
|
| 58 |
-
"""
|
| 59 |
-
Convert a tuple of parameters into a WhisperValues data class, to use parameters in a function after Gradio pre-processing.
|
| 60 |
-
|
| 61 |
-
Parameters
|
| 62 |
-
----------
|
| 63 |
-
*params: tuple
|
| 64 |
-
This is provided in a tuple because Gradio does not support **kwargs arbitrary.
|
| 65 |
-
Reference : https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140/2
|
| 66 |
-
|
| 67 |
-
Returns
|
| 68 |
-
----------
|
| 69 |
-
A WhisperValues data class
|
| 70 |
-
"""
|
| 71 |
-
return WhisperValues(*params)
|
| 72 |
-
|
| 73 |
|
| 74 |
@dataclass
|
| 75 |
class WhisperValues:
|
|
@@ -83,6 +67,6 @@ class WhisperValues:
|
|
| 83 |
best_of: int
|
| 84 |
patience: float
|
| 85 |
"""
|
| 86 |
-
A data class to use Whisper parameters in
|
| 87 |
See this documentation for more information about Gradio pre-processing: : https://www.gradio.app/docs/components
|
| 88 |
"""
|
|
|
|
| 45 |
|
| 46 |
def to_list(self) -> list:
|
| 47 |
"""
|
| 48 |
+
Converts the data class attributes into a list, to pass parameters to a
|
| 49 |
+
button click event function before Gradio pre-processing.
|
| 50 |
|
| 51 |
Returns
|
| 52 |
----------
|
|
|
|
| 54 |
"""
|
| 55 |
return [getattr(self, f.name) for f in fields(self)]
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
@dataclass
|
| 59 |
class WhisperValues:
|
|
|
|
| 67 |
best_of: int
|
| 68 |
patience: float
|
| 69 |
"""
|
| 70 |
+
A data class to use Whisper parameters in your function after Gradio pre-processing.
|
| 71 |
See this documentation for more information about Gradio pre-processing: : https://www.gradio.app/docs/components
|
| 72 |
"""
|