Skip to content

Commit

Permalink
Added switch to control passing of video filename in whisper provider…
Browse files Browse the repository at this point in the history
… modal
  • Loading branch information
JaiZed authored Nov 19, 2024
1 parent 48cdc8b commit e298d15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions bazarr/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def check_parser_binary(value):
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.pass_video_name', must_exist=True, default=False, is_type_of=bool),
Validator('whisperai.loglevel', must_exist=True, default='INFO', is_type_of=str,
is_in=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']),

Expand Down
1 change: 1 addition & 0 deletions bazarr/app/get_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def get_providers_auth():
'timeout': settings.whisperai.timeout,
'ffmpeg_path': _FFMPEG_BINARY,
'loglevel': settings.whisperai.loglevel,
'pass_video_name': settings.whisperai.pass_video_name,
},
"animetosho": {
'search_threshold': settings.animetosho.search_threshold,
Expand Down
10 changes: 8 additions & 2 deletions custom_libs/subliminal_patch/providers/whisperai.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class WhisperAIProvider(Provider):

video_types = (Episode, Movie)

def __init__(self, endpoint=None, response=None, timeout=None, ffmpeg_path=None, loglevel=None):
def __init__(self, endpoint=None, response=None, timeout=None, ffmpeg_path=None, pass_video_name=None, loglevel=None):
set_log_level(loglevel)
if not endpoint:
raise ConfigurationError('Whisper Web Service Endpoint must be provided')
Expand All @@ -246,12 +246,16 @@ def __init__(self, endpoint=None, response=None, timeout=None, ffmpeg_path=None,

if not ffmpeg_path:
raise ConfigurationError("ffmpeg path must be provided")

if pass_video_name is None:
raise ConfigurationError('Whisper Web Service Pass Video Name option must be provided')

self.endpoint = endpoint.rstrip("/")
self.response = int(response)
self.timeout = int(timeout)
self.session = None
self.ffmpeg_path = ffmpeg_path
self.pass_video_name = pass_video_name

def initialize(self):
self.session = Session()
Expand Down Expand Up @@ -369,9 +373,11 @@ def download_subtitle(self, subtitle: WhisperAISubtitle):

logger.info(f'Starting WhisperAI {subtitle.task} to {language_from_alpha3(output_language)} for {subtitle.video.original_path}')
startTime = time.time()
video_name = subtitle.video.original_path if self.pass_video_name else None

r = self.session.post(f"{self.endpoint}/asr",
params={'task': subtitle.task, 'language': input_language, 'output': 'srt', 'encode': 'false'},
params={'task': subtitle.task, 'language': input_language, 'output': 'srt', 'encode': 'false',
'video_file': {video_name}},
files={'audio_file': out},
timeout=(self.response, self.timeout))

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/pages/Settings/Providers/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,12 @@ export const ProviderList: Readonly<ProviderInfo[]> = [
name: "Logging level",
options: logLevelOptions,
},
{
type: "switch",
key: "pass_video_name",
name: "Pass video filename to Whisper (for logging)",
defaultValue: false,
},
{
type: "testbutton",
key: "whisperai",
Expand Down

0 comments on commit e298d15

Please sign in to comment.