correct silence handling in translation
This commit is contained in:
parent
d55490cd27
commit
6caf3e0485
3 changed files with 14 additions and 7 deletions
|
|
@ -368,7 +368,11 @@ class AudioProcessor:
|
||||||
if additional_token is SENTINEL:
|
if additional_token is SENTINEL:
|
||||||
sentinel_found = True
|
sentinel_found = True
|
||||||
break
|
break
|
||||||
tokens_to_process.append(additional_token)
|
elif type(additional_token) is Silence:
|
||||||
|
self.translation.insert_silence(additional_token.duration)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
tokens_to_process.append(additional_token)
|
||||||
if tokens_to_process:
|
if tokens_to_process:
|
||||||
self.translation.insert_tokens(tokens_to_process)
|
self.translation.insert_tokens(tokens_to_process)
|
||||||
self.translated_segments = await asyncio.to_thread(self.translation.process)
|
self.translated_segments = await asyncio.to_thread(self.translation.process)
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ class Line(TimedText):
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
_dict = {
|
_dict = {
|
||||||
'speaker': int(self.speaker),
|
'speaker': abs(int(self.speaker)),
|
||||||
'text': self.text,
|
'text': self.text,
|
||||||
'start': format_time(self.start),
|
'start': format_time(self.start),
|
||||||
'end': format_time(self.end),
|
'end': format_time(self.end),
|
||||||
|
|
@ -151,7 +151,7 @@ class FrontData():
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
_dict = {
|
_dict = {
|
||||||
'status': self.status,
|
'status': self.status,
|
||||||
'lines': [line.to_dict() for line in self.lines],
|
'lines': [line.to_dict() for line in self.lines if line.text],
|
||||||
'buffer_transcription': self.buffer_transcription,
|
'buffer_transcription': self.buffer_transcription,
|
||||||
'buffer_diarization': self.buffer_diarization,
|
'buffer_diarization': self.buffer_diarization,
|
||||||
'remaining_time_transcription': self.remaining_time_transcription,
|
'remaining_time_transcription': self.remaining_time_transcription,
|
||||||
|
|
|
||||||
|
|
@ -416,10 +416,13 @@ function renderLinesWithBuffer(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.translation) {
|
if (item.translation) {
|
||||||
currentLineText += `<div class="label_translation">
|
currentLineText += `
|
||||||
${translationIcon}
|
<div>
|
||||||
<span>${item.translation}</span>
|
<div class="label_translation">
|
||||||
</div>`;
|
${translationIcon}
|
||||||
|
<span>${item.translation}</span>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentLineText.trim().length > 0 || speakerLabel.length > 0
|
return currentLineText.trim().length > 0 || speakerLabel.length > 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue