Created option for text viewer by adding BUZZ_PARAGRAPH_SPLIT_TIME environment variable (#1246)

Co-authored-by: Raivis Dejus <orvils@gmail.com>
This commit is contained in:
David Olowomeye 2025-09-20 08:51:47 +01:00 committed by GitHub
commit 44e962d1e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View file

@ -166,8 +166,10 @@ def write_output(
combined_text = ""
previous_end_time = None
paragraph_split_time = int(os.getenv("BUZZ_PARAGRAPH_SPLIT_TIME", "2000"))
for segment in segments:
if previous_end_time is not None and (segment.start - previous_end_time) >= 2000:
if previous_end_time is not None and (segment.start - previous_end_time) >= paragraph_split_time:
combined_text += "\n\n"
combined_text += getattr(segment, segment_key).strip() + " "
previous_end_time = segment.end

View file

@ -1,3 +1,4 @@
import os
import logging
from typing import Optional
from uuid import UUID
@ -825,8 +826,10 @@ class TranscriptionViewerWidget(QWidget):
combined_text = ""
previous_end_time = None
paragraph_split_time = int(os.getenv("BUZZ_PARAGRAPH_SPLIT_TIME", "2000"))
for segment in segments:
if previous_end_time is not None and (segment.start_time - previous_end_time) >= 2000:
if previous_end_time is not None and (segment.start_time - previous_end_time) >= paragraph_split_time:
combined_text += "\n\n"
combined_text += segment.text.strip() + " "
previous_end_time = segment.end_time

View file

@ -119,3 +119,4 @@ Example of data collected by telemetry:
```
Buzz: 1.3.0, locale: ('lv_LV', 'UTF-8'), system: Linux, release: 6.14.0-27-generic, machine: x86_64, version: #27~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 17:38:49 UTC 2,
```
**BUZZ_PARAGRAPH_SPLIT_TIME** - Time in milliseconds of silence to split paragraphs in transcript and add two newlines when exporting the transcripts as text. Default is `2000` or 2 seconds. Available since `1.3.0`