correct silence handling in translation

This commit is contained in:
Quentin Fuxa
2025-09-27 11:58:00 +02:00
parent d55490cd27
commit 6caf3e0485
3 changed files with 14 additions and 7 deletions

View File

@@ -368,7 +368,11 @@ class AudioProcessor:
if additional_token is SENTINEL:
sentinel_found = True
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:
self.translation.insert_tokens(tokens_to_process)
self.translated_segments = await asyncio.to_thread(self.translation.process)

View File

@@ -126,7 +126,7 @@ class Line(TimedText):
def to_dict(self):
_dict = {
'speaker': int(self.speaker),
'speaker': abs(int(self.speaker)),
'text': self.text,
'start': format_time(self.start),
'end': format_time(self.end),
@@ -151,7 +151,7 @@ class FrontData():
def to_dict(self):
_dict = {
'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_diarization': self.buffer_diarization,
'remaining_time_transcription': self.remaining_time_transcription,

View File

@@ -416,10 +416,13 @@ function renderLinesWithBuffer(
}
if (item.translation) {
currentLineText += `<div class="label_translation">
${translationIcon}
<span>${item.translation}</span>
</div>`;
currentLineText += `
<div>
<div class="label_translation">
${translationIcon}
<span>${item.translation}</span>
</div>
</div>`;
}
return currentLineText.trim().length > 0 || speakerLabel.length > 0