Spaces:
Running
on
Zero
Running
on
Zero
change seconds format
Browse filesSigned-off-by: monica-sekoyan <msekoyan@nvidia.com>
app.py
CHANGED
|
@@ -11,6 +11,7 @@ import os
|
|
| 11 |
import gradio.themes as gr_themes
|
| 12 |
import csv
|
| 13 |
from supported_languages import SUPPORTED_LANGS_MAP
|
|
|
|
| 14 |
|
| 15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 16 |
MODEL_NAME="nvidia/canary-1b-v2"
|
|
@@ -41,6 +42,9 @@ def end_session(request: gr.Request):
|
|
| 41 |
|
| 42 |
print(f"Session with hash {session_hash} ended.")
|
| 43 |
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
def update_src_lang_dropdown(selected_value):
|
| 46 |
if selected_value == DEFAULT_SRC_LANG:
|
|
@@ -174,7 +178,7 @@ def get_transcripts_and_raw_times(audio_path, session_dir, source_lang, target_l
|
|
| 174 |
|
| 175 |
segment_timestamps = output[0].timestamp['segment']
|
| 176 |
csv_headers = ["Start (s)", "End (s)", "Segment"]
|
| 177 |
-
vis_data = [[f"{ts['start']
|
| 178 |
raw_times_data = [[ts['start'], ts['end']] for ts in segment_timestamps]
|
| 179 |
|
| 180 |
# Default button update (hidden) in case CSV writing fails
|
|
|
|
| 11 |
import gradio.themes as gr_themes
|
| 12 |
import csv
|
| 13 |
from supported_languages import SUPPORTED_LANGS_MAP
|
| 14 |
+
from datetime import timedelta, datetime
|
| 15 |
|
| 16 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 17 |
MODEL_NAME="nvidia/canary-1b-v2"
|
|
|
|
| 42 |
|
| 43 |
print(f"Session with hash {session_hash} ended.")
|
| 44 |
|
| 45 |
+
def sec_to_hrs(seconds):
|
| 46 |
+
seconds = round(seconds)
|
| 47 |
+
return str(timedelta(seconds=seconds))
|
| 48 |
|
| 49 |
def update_src_lang_dropdown(selected_value):
|
| 50 |
if selected_value == DEFAULT_SRC_LANG:
|
|
|
|
| 178 |
|
| 179 |
segment_timestamps = output[0].timestamp['segment']
|
| 180 |
csv_headers = ["Start (s)", "End (s)", "Segment"]
|
| 181 |
+
vis_data = [[f"{sec_to_hrs(ts['start'])}", f"{sec_to_hrs(ts['end'])}", ts['segment']] for ts in segment_timestamps]
|
| 182 |
raw_times_data = [[ts['start'], ts['end']] for ts in segment_timestamps]
|
| 183 |
|
| 184 |
# Default button update (hidden) in case CSV writing fails
|