diff options
author | JayZed <[email protected]> | 2024-01-28 21:09:37 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-28 21:09:37 -0500 |
commit | 938f6df386c0f50568f7a6c04ed4ae58e440af04 (patch) | |
tree | a5a3a110b9a7c60d2f66723743bc6b946209b3e5 /libs | |
parent | cdf7296dd41fe6fb46d7abe49c684e03680a278c (diff) | |
download | bazarr-938f6df386c0f50568f7a6c04ed4ae58e440af04.tar.gz bazarr-938f6df386c0f50568f7a6c04ed4ae58e440af04.zip |
Added separate values to whisperai provider for connection and read timeoutsv1.4.1-beta.20
Added "response" key with default value of 5 to pair with existing "timeout" key which has a default of 3600 sec.
Both values can be updated in WhisperAI settings dialog by user.
More information about these timeouts here: https://reqbin.com/code/python/3zdpeao1/python-requests-timeout-example
Diffstat (limited to 'libs')
-rw-r--r-- | libs/subliminal_patch/providers/whisperai.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libs/subliminal_patch/providers/whisperai.py b/libs/subliminal_patch/providers/whisperai.py index 1cf6e5ff0..33421f201 100644 --- a/libs/subliminal_patch/providers/whisperai.py +++ b/libs/subliminal_patch/providers/whisperai.py @@ -213,18 +213,22 @@ class WhisperAIProvider(Provider): video_types = (Episode, Movie) - def __init__(self, endpoint=None, timeout=None, ffmpeg_path=None, loglevel=None): + def __init__(self, endpoint=None, response=None, timeout=None, ffmpeg_path=None, loglevel=None): set_log_level(loglevel) if not endpoint: raise ConfigurationError('Whisper Web Service Endpoint must be provided') + if not response: + raise ConfigurationError('Whisper Web Service Connection/response timeout must be provided') + if not timeout: - raise ConfigurationError('Whisper Web Service Timeout must be provided') + raise ConfigurationError('Whisper Web Service Transcription/translation timeout must be provided') if not ffmpeg_path: raise ConfigurationError("ffmpeg path must be provided") self.endpoint = endpoint + self.response = int(response) self.timeout = int(timeout) self.session = None self.ffmpeg_path = ffmpeg_path @@ -248,7 +252,7 @@ class WhisperAIProvider(Provider): r = self.session.post(f"{self.endpoint}/detect-language", params={'encode': 'false'}, files={'audio_file': out}, - timeout=(self.timeout, self.timeout)) + timeout=(self.response, self.timeout)) logger.debug(f"Whisper detected language of {path} as {r.json()['detected_language']}") @@ -326,7 +330,7 @@ class WhisperAIProvider(Provider): r = self.session.post(f"{self.endpoint}/asr", params={'task': subtitle.task, 'language': whisper_get_language_reverse(subtitle.audio_language), 'output': 'srt', 'encode': 'false'}, files={'audio_file': out}, - timeout=(self.timeout, self.timeout)) + timeout=(self.response, self.timeout)) endTime = time.time() elapsedTime = timedelta(seconds=round(endTime - startTime)) |