mirror of
https://github.com/QuentinFuxa/WhisperLiveKit.git
synced 2026-03-21 16:40:35 +00:00
correct silence handling in translation
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user