From a85dc3c6c04b40a4ecc1ffac469ffee65fd4bd6f Mon Sep 17 00:00:00 2001 From: jhj0517 <97279763+jhj0517@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:51:24 +0900 Subject: [PATCH 1/4] Add defaults to the function --- modules/whisper/whisper_base.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/whisper/whisper_base.py b/modules/whisper/whisper_base.py index 34e2a8df..354690a5 100644 --- a/modules/whisper/whisper_base.py +++ b/modules/whisper/whisper_base.py @@ -53,7 +53,7 @@ def __init__(self, @abstractmethod def transcribe(self, audio: Union[str, BinaryIO, np.ndarray], - progress: gr.Progress, + progress: gr.Progress = gr.Progress(), *whisper_params, ): """Inference whisper model to transcribe""" @@ -63,7 +63,7 @@ def transcribe(self, def update_model(self, model_size: str, compute_type: str, - progress: gr.Progress + progress: gr.Progress = gr.Progress() ): """Initialize whisper model""" pass @@ -171,10 +171,10 @@ def run(self, return result, elapsed_time def transcribe_file(self, - files: list, - input_folder_path: str, - file_format: str, - add_timestamp: bool, + files: Optional[List] = None, + input_folder_path: Optional[str] = None, + file_format: str = "SRT", + add_timestamp: bool = True, progress=gr.Progress(), *whisper_params, ) -> list: @@ -250,8 +250,8 @@ def transcribe_file(self, def transcribe_mic(self, mic_audio: str, - file_format: str, - add_timestamp: bool, + file_format: str = "SRT", + add_timestamp: bool = True, progress=gr.Progress(), *whisper_params, ) -> list: @@ -306,8 +306,8 @@ def transcribe_mic(self, def transcribe_youtube(self, youtube_link: str, - file_format: str, - add_timestamp: bool, + file_format: str = "SRT", + add_timestamp: bool = True, progress=gr.Progress(), *whisper_params, ) -> list: @@ -411,11 +411,12 @@ def generate_and_write_file(file_name: str, else: output_path = os.path.join(output_dir, f"{file_name}") - if file_format == "SRT": + file_format = file_format.strip().lower() + if file_format == "srt": content = get_srt(transcribed_segments) output_path += '.srt' - elif file_format == "WebVTT": + elif file_format == "webvtt": content = get_vtt(transcribed_segments) output_path += '.vtt' From 4495187b66e3f31ca45f46439d737520324bc3bb Mon Sep 17 00:00:00 2001 From: jhj0517 <97279763+jhj0517@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:51:30 +0900 Subject: [PATCH 2/4] Add defaults to the function --- modules/whisper/faster_whisper_inference.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/whisper/faster_whisper_inference.py b/modules/whisper/faster_whisper_inference.py index 519c92c3..89d09c9f 100644 --- a/modules/whisper/faster_whisper_inference.py +++ b/modules/whisper/faster_whisper_inference.py @@ -40,7 +40,7 @@ def __init__(self, def transcribe(self, audio: Union[str, BinaryIO, np.ndarray], - progress: gr.Progress, + progress: gr.Progress = gr.Progress(), *whisper_params, ) -> Tuple[List[dict], float]: """ @@ -126,7 +126,7 @@ def transcribe(self, def update_model(self, model_size: str, compute_type: str, - progress: gr.Progress + progress: gr.Progress = gr.Progress() ): """ Update current model setting From 732a962f7a850266caeda9679171316ece07a305 Mon Sep 17 00:00:00 2001 From: jhj0517 <97279763+jhj0517@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:52:10 +0900 Subject: [PATCH 3/4] Add defaults to the function --- modules/whisper/insanely_fast_whisper_inference.py | 4 ++-- modules/whisper/whisper_Inference.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/whisper/insanely_fast_whisper_inference.py b/modules/whisper/insanely_fast_whisper_inference.py index dc3334e4..577ef3dc 100644 --- a/modules/whisper/insanely_fast_whisper_inference.py +++ b/modules/whisper/insanely_fast_whisper_inference.py @@ -39,7 +39,7 @@ def __init__(self, def transcribe(self, audio: Union[str, np.ndarray, torch.Tensor], - progress: gr.Progress, + progress: gr.Progress = gr.Progress(), *whisper_params, ) -> Tuple[List[dict], float]: """ @@ -98,7 +98,7 @@ def transcribe(self, def update_model(self, model_size: str, compute_type: str, - progress: gr.Progress, + progress: gr.Progress = gr.Progress(), ): """ Update current model setting diff --git a/modules/whisper/whisper_Inference.py b/modules/whisper/whisper_Inference.py index 623c56f0..f87fbe5d 100644 --- a/modules/whisper/whisper_Inference.py +++ b/modules/whisper/whisper_Inference.py @@ -28,7 +28,7 @@ def __init__(self, def transcribe(self, audio: Union[str, np.ndarray, torch.Tensor], - progress: gr.Progress, + progress: gr.Progress = gr.Progress(), *whisper_params, ) -> Tuple[List[dict], float]: """ @@ -79,7 +79,7 @@ def progress_callback(progress_value): def update_model(self, model_size: str, compute_type: str, - progress: gr.Progress, + progress: gr.Progress = gr.Progress(), ): """ Update current model setting From aa11c4706a95b82765fad6719af94ac4c4eec708 Mon Sep 17 00:00:00 2001 From: jhj0517 <97279763+jhj0517@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:53:01 +0900 Subject: [PATCH 4/4] Add defaults to the function --- modules/translation/nllb_inference.py | 2 +- modules/translation/translation_base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/translation/nllb_inference.py b/modules/translation/nllb_inference.py index c48aa977..bfd89fec 100644 --- a/modules/translation/nllb_inference.py +++ b/modules/translation/nllb_inference.py @@ -35,7 +35,7 @@ def update_model(self, model_size: str, src_lang: str, tgt_lang: str, - progress: gr.Progress + progress: gr.Progress = gr.Progress() ): if model_size != self.current_model_size or self.model is None: print("\nInitializing NLLB Model..\n") diff --git a/modules/translation/translation_base.py b/modules/translation/translation_base.py index 7545ae07..77db9f80 100644 --- a/modules/translation/translation_base.py +++ b/modules/translation/translation_base.py @@ -37,7 +37,7 @@ def update_model(self, model_size: str, src_lang: str, tgt_lang: str, - progress: gr.Progress + progress: gr.Progress = gr.Progress() ): pass