Added separate values to whisperai provider for connection and read timeouts

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
pull/2373/head v1.4.1-beta.20
JayZed 11 months ago committed by GitHub
parent cdf7296dd4
commit 938f6df386
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -228,6 +228,7 @@ validators = [
# whisperai section
Validator('whisperai.endpoint', must_exist=True, default='http://127.0.0.1:9000', is_type_of=str),
Validator('whisperai.response', must_exist=True, default=5, is_type_of=int, gte=1),
Validator('whisperai.timeout', must_exist=True, default=3600, is_type_of=int, gte=1),
Validator('whisperai.loglevel', must_exist=True, default='INFO', is_type_of=str,
is_in=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']),

@ -311,6 +311,7 @@ def get_providers_auth():
},
'whisperai': {
'endpoint': settings.whisperai.endpoint,
'response': settings.whisperai.response,
'timeout': settings.whisperai.timeout,
'ffmpeg_path': _FFMPEG_BINARY,
'loglevel': settings.whisperai.loglevel,

@ -442,6 +442,12 @@ export const ProviderList: Readonly<ProviderInfo[]> = [
defaultValue: "http://127.0.0.1:9000",
name: "Whisper ASR Docker Endpoint",
},
{
type: "text",
key: "response",
defaultValue: 5,
name: "Connection/response timeout in seconds",
},
{
type: "text",
key: "timeout",

@ -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))

Loading…
Cancel
Save