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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user