Update modules/whisper/whisper_base.py
Browse files670 unmodified lines671672673674675676677678679680681682683684685686670 unmodified lines@staticmethoddef cache_parameters(whisper_params: WhisperValues,add_timestamp: bool):"""cache parameters to the yaml file"""cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)cached_whisper_param = whisper_params.to_yaml()cached_yaml = {**cached_params, **cached_whisper_param}cached_yaml["whisper"]["add_timestamp"] = add_timestampsave_yaml(cached_yaml, DEFAULT_PARAMETERS_CONFIG_PATH)@staticmethoddef resample_audio(audio: Union[str, np.ndarray],670 unmodified lines671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703670 unmodified lines@staticmethoddef cache_parameters(params: WhisperValues,file_format: str = "SRT",add_timestamp: bool = True):"""Cache parameters to the yaml file"""cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)param_to_cache = params.to_dict()cached_yaml = {**cached_params, **param_to_cache}cached_yaml["whisper"]["add_timestamp"] = add_timestampcached_yaml["whisper"]["file_format"] = file_formatsuppress_token = cached_yaml["whisper"].get("suppress_tokens", None)if suppress_token and isinstance(suppress_token, list):cached_yaml["whisper"]["suppress_tokens"] = str(suppress_token)if cached_yaml["whisper"].get("lang", None) is None:cached_yaml["whisper"]["lang"] = AUTOMATIC_DETECTION.unwrap()else:language_dict = whisper.tokenizer.LANGUAGEScached_yaml["whisper"]["lang"] = language_dict[cached_yaml["whisper"]["lang"]]if cached_yaml["vad"].get("max_speech_duration_s", float('inf')) == float('inf'):cached_yaml["vad"]["max_speech_duration_s"] = GRADIO_NONE_NUMBER_MAXif cached_yaml is not None and cached_yaml:save_yaml(cached_yaml, DEFAULT_PARAMETERS_CONFIG_PATH)@staticmethoddef resample_audio(audio: Union[str, np.ndarray],
modules/whisper/whisper_base.py+23-6