if no language is set, try without
This commit is contained in:
parent
a4a60537f1
commit
1788f4bac6
1 changed files with 10 additions and 9 deletions
|
@ -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 = 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
|
||||
language = None
|
||||
else:
|
||||
language = ox.iso.langTo2Code(item.data["language"][0])
|
||||
if not item.streams():
|
||||
logger.error("skip item without media %s: %s", item.public_id)
|
||||
return False
|
||||
|
@ -36,13 +34,16 @@ def extract_subtitles(item, user, layer, translate, gpu=False):
|
|||
tmp = tempfile.mkdtemp()
|
||||
cmd = [
|
||||
"/opt/whisper-timestamped/bin/whisper_timestamped",
|
||||
"--language", language,
|
||||
]
|
||||
if translate and language in translate:
|
||||
if language:
|
||||
cmd += [
|
||||
'--task', 'translate'
|
||||
"--language", language
|
||||
]
|
||||
language = 'en'
|
||||
if translate and language in translate:
|
||||
cmd += [
|
||||
'--task', 'translate'
|
||||
]
|
||||
language = 'en'
|
||||
if not gpu:
|
||||
cmd += [
|
||||
"--fp16", "False",
|
||||
|
|
Loading…
Reference in a new issue