Skip to content

Commit 9adfd25

Browse files
committed
feat: display elapsed time after subtitle generation in CLI and WebUI #173
1 parent 77ce727 commit 9adfd25

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/subsai/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
import argparse
88
import importlib.metadata
9+
import time
910
from typing import List
1011

1112
__author__ = "abdeladim-s"
@@ -115,6 +116,7 @@ def run(media_file_arg: List[str],
115116

116117

117118
def main():
119+
start_time = time.time()
118120
print(__header__)
119121
parser = argparse.ArgumentParser(description="", allow_abbrev=True)
120122
# Positional args
@@ -157,6 +159,12 @@ def main():
157159
translation_target_lang=args.translation_target_lang,
158160
output_suffix=args.output_suffix)
159161

162+
end_time = time.time()
163+
elapsed_time = end_time - start_time
164+
mins = int(elapsed_time // 60)
165+
secs = int(elapsed_time % 60)
166+
print(f"\nDone in {mins:02d}:{secs:02d}")
167+
160168

161169
if __name__ == '__main__':
162170
main()

src/subsai/webui.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import shutil
1313
import sys
1414
import tempfile
15+
import time
1516
from base64 import b64encode
1617
from pathlib import Path
1718

@@ -321,6 +322,8 @@ def webui() -> None:
321322
transcribe_loading_placeholder = st.empty()
322323

323324
if transcribe_button:
325+
start_time = time.time()
326+
transcribe_loading_placeholder.info('Transcribing...', icon="⏳")
324327
config_schema = SubsAI.config_schema(stt_model_name)
325328
if configs_mode == 'Manual':
326329
model_config = _get_config_from_session_state(stt_model_name, config_schema, notification_placeholder)
@@ -329,7 +332,13 @@ def webui() -> None:
329332
model_config = json.load(f)
330333
subs = _transcribe(file_path, stt_model_name, model_config)
331334
st.session_state['transcribed_subs'] = subs
332-
transcribe_loading_placeholder.success('Done!', icon="✅")
335+
336+
end_time = time.time()
337+
elapsed_time = end_time - start_time
338+
mins = int(elapsed_time // 60)
339+
secs = int(elapsed_time % 60)
340+
341+
transcribe_loading_placeholder.success(f'Done in {mins:02d}:{secs:02d}!', icon="✅")
333342

334343
with st.expander('Post Processing Tools', expanded=False):
335344
basic_tool = st.selectbox('Basic tools', options=['', 'Set time', 'Shift'],

0 commit comments

Comments
 (0)