if no language is set, try without

This commit is contained in:
j 2024-07-08 15:33:03 +01:00
parent a4a60537f1
commit 1788f4bac6

View file

@ -23,11 +23,9 @@ logger = logging.getLogger(__name__)
def extract_subtitles(item, user, layer, translate, gpu=False):
if "language" not in item.data:
logger.error("skip item without language %s", item.public_id)
return False
language = None
else:
language = ox.iso.langTo2Code(item.data["language"][0])
if not language:
logger.error("skip item with unknown language %s: %s", item.public_id, item.data["language"])
return False
if not item.streams():
logger.error("skip item without media %s: %s", item.public_id)
return False
@ -36,7 +34,10 @@ def extract_subtitles(item, user, layer, translate, gpu=False):
tmp = tempfile.mkdtemp()
cmd = [
"/opt/whisper-timestamped/bin/whisper_timestamped",
"--language", language,
]
if language:
cmd += [
"--language", language
]
if translate and language in translate:
cmd += [