Compare commits
No commits in common. "eb2d12a905464ffe3b67361279c4ef89c77c5a98" and "d2da5ae581925b98d5b28a3c278d71f68618a171" have entirely different histories.
eb2d12a905
...
d2da5ae581
1 changed files with 8 additions and 17 deletions
|
|
@ -21,7 +21,6 @@ from user.models import User
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
TARGET_LENGTH = getattr(settings, 'TRANSCRIBE_TARGET_LENGTH', 200)
|
||||
|
||||
def prepare_annotations(result, join_sentences=False):
|
||||
if join_sentences:
|
||||
|
|
@ -38,7 +37,7 @@ def prepare_annotations(result, join_sentences=False):
|
|||
return annotations
|
||||
|
||||
|
||||
def prepare_joint_annotations(result, target_length=TARGET_LENGTH):
|
||||
def prepare_joint_annotations(result, target_length=200):
|
||||
abbrevs = ["Mr.", "Mrs.", "Dr."]
|
||||
ignore = []
|
||||
phrase_sounds = []
|
||||
|
|
@ -150,23 +149,15 @@ def extract_subtitles(item, user, layer, translate, gpu=False, join_sentences=Fa
|
|||
if not item.streams():
|
||||
logger.error("skip item without media %s: %s", item.public_id)
|
||||
return False
|
||||
|
||||
offset = 0
|
||||
annotations = []
|
||||
for stream in item.streams():
|
||||
src = stream.media.path
|
||||
response = run_whisper(src, language, translate, gpu, model)
|
||||
if not response:
|
||||
logger.error("extract failed for %s", item.public_id)
|
||||
return False
|
||||
for annotation in prepare_annotations(response, join_sentences=join_sentences):
|
||||
if offset:
|
||||
annotation['in'] += offset
|
||||
annotation['out'] += offset
|
||||
annotations.append(annotation)
|
||||
offset += stream.duration
|
||||
src = item.streams()[0].media.path
|
||||
response = run_whisper(src, language, translate, gpu, model)
|
||||
if not response:
|
||||
logger.error("extract failed for %s", item.public_id)
|
||||
return False
|
||||
annotations = prepare_annotations(response, join_sentences=join_sentences)
|
||||
if not annotations:
|
||||
return False
|
||||
|
||||
if language and language != "en":
|
||||
for annotation in annotations:
|
||||
annotation["value"] = '<span lang="%s">%s</span>' % (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue