jhj0517 commited on
Commit
db355d3
·
1 Parent(s): df6fc6f

Add `as_list()` to use in gradio function

Browse files
Files changed (1) hide show
  1. modules/whisper/data_classes.py +11 -12
modules/whisper/data_classes.py CHANGED
@@ -274,7 +274,9 @@ class WhisperParams(BaseModel):
274
  def to_gradio_inputs(cls,
275
  defaults: Optional[Dict] = None,
276
  only_advanced: Optional[bool] = True,
277
- whisper_type: Optional[WhisperImpl] = None):
 
 
278
  defaults = {} if defaults is None else defaults
279
  whisper_type = WhisperImpl.FASTER_WHISPER if whisper_type is None else whisper_type
280
 
@@ -318,8 +320,8 @@ class WhisperParams(BaseModel):
318
  ),
319
  gr.Dropdown(
320
  label="Compute Type",
321
- choices=["float16", "int8", "int16"],
322
- value=defaults.get("compute_type", cls.compute_type),
323
  info="Computation type for transcription"
324
  ),
325
  gr.Number(
@@ -483,12 +485,9 @@ class TranscriptionPipelineParams(BaseModel):
483
  }
484
  return data
485
 
486
- # def as_list(self) -> list:
487
- # """
488
- # Converts the data class attributes into a list
489
- #
490
- # Returns
491
- # ----------
492
- # A list of Whisper parameters
493
- # """
494
- # return [getattr(self, f.name) for f in fields(self)]
 
274
  def to_gradio_inputs(cls,
275
  defaults: Optional[Dict] = None,
276
  only_advanced: Optional[bool] = True,
277
+ whisper_type: Optional[WhisperImpl] = None,
278
+ available_compute_types: Optional[List] = None,
279
+ compute_type: Optional[str] = None):
280
  defaults = {} if defaults is None else defaults
281
  whisper_type = WhisperImpl.FASTER_WHISPER if whisper_type is None else whisper_type
282
 
 
320
  ),
321
  gr.Dropdown(
322
  label="Compute Type",
323
+ choices=["float16", "int8", "int16"] if available_compute_types is None else available_compute_types,
324
+ value=defaults.get("compute_type", compute_type),
325
  info="Computation type for transcription"
326
  ),
327
  gr.Number(
 
485
  }
486
  return data
487
 
488
+ def as_list(self) -> List:
489
+ whisper_list = [value for key, value in self.whisper.to_dict().items()]
490
+ vad_list = [value for key, value in self.vad.to_dict().items()]
491
+ diarization_list = [value for key, value in self.vad.to_dict().items()]
492
+ bgm_sep_list = [value for key, value in self.bgm_separation.to_dict().items()]
493
+ return whisper_list + vad_list + diarization_list + bgm_sep_list