Enable timestamps for transcripted text

Add `--enable-timestamps` option to `run_client.py`
script to print out transcripted text with timestamps.

Sample output with translation enabled:
```
[0.000 -> 7.440]  And so, my fellow Americans, ask not what your country can do for you.
[7.440 -> 10.300]  Ask what you can do for your country.

TRANSLATION to fr:
[0.000 -> 7.440] Et donc, mes camarades américains, ne demandez pas ce que votre pays peut faire pour vous.
[7.440 -> 10.300] Demandez ce que vous pouvez faire pour votre pays.
```

Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
This commit is contained in:
Jeny Sadadia
2026-02-10 15:16:43 +05:30
parent 6c8142a9d2
commit 5e33aa2a7e
3 changed files with 51 additions and 15 deletions
+9 -5
View File
@@ -11,12 +11,16 @@ def clear_screen():
os.system("cls" if os.name == "nt" else "clear")
def print_transcript(text, translated=False):
def print_transcript(text, translated=False, timestamps=False):
"""Prints formatted transcript text."""
wrapper = textwrap.TextWrapper(width=60)
text=" ".join(text) if translated else "".join(text)
for line in wrapper.wrap(text=text):
print(line)
if timestamps:
for t in text:
print(f'[{t["start"]} -> {t["end"]}] {t["text"]}')
else:
wrapper = textwrap.TextWrapper(width=60)
text=" ".join(text) if translated else "".join(text)
for line in wrapper.wrap(text=text):
print(line)
def format_time(s):