Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions whisper_streaming_custom/online_asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def process_iter(self) -> Transcript:
def chunk_completed_sentence(self):
"""
If the committed tokens form at least two sentences, chunk the audio
buffer at the end time of the penultimate sentence.
buffer at the end time of the ultimate sentence.
"""
if not self.committed:
return
Expand All @@ -225,10 +225,8 @@ def chunk_completed_sentence(self):
logger.debug(f"\tSentence: {sentence.text}")
if len(sentences) < 2:
return
# Keep the last two sentences.
while len(sentences) > 2:
sentences.pop(0)
chunk_time = sentences[-2].end
# Keep the last sentences.
chunk_time = sentences[-1].end
logger.debug(f"--- Sentence chunked at {chunk_time:.2f}")
self.chunk_at(chunk_time)

Expand Down Expand Up @@ -313,6 +311,7 @@ def words_to_sentences(self, tokens: List[ASRToken]) -> List[Sentence]:
)
sentences.append(sentence)
return sentences

def finish(self) -> Transcript:
"""
Flush the remaining transcript when processing ends.
Expand Down