Skip to content

Commit

Permalink
catch size limit error #74
Browse files Browse the repository at this point in the history
  • Loading branch information
absadiki committed Oct 18, 2023
1 parent a319a1c commit b0770c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "subsai"
version = "1.2.0"
version = "1.2.1"
authors = [
{name = "abdeladim-s"},
]
Expand Down
14 changes: 12 additions & 2 deletions src/subsai/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def _media_file_base64(file_path, mime='video/mp4', start_time=0):
mime = mimetypes.guess_type(file_path)[0]
except Exception as e:
print(f'Unrecognized video type!')
return [{"type": mime, "src": f"data:{mime};base64,{data}#t={start_time}"}]

return [{"type": mime, "src": f"data:{mime};base64,{data}#t={start_time}"}]

@st.cache_resource
def _create_translation_model(model_name: str):
Expand Down Expand Up @@ -295,6 +295,8 @@ def webui() -> None:
else:
file_path = ""

st.session_state['file_path'] = file_path

stt_model_name = st.selectbox("Select Model", SubsAI.available_models(), index=0,
help='Select an AI model to use for '
'transcription')
Expand Down Expand Up @@ -487,7 +489,15 @@ def webui() -> None:
}}
}

event = st_player(_media_file_base64(file_path), **options, height=500, key="player")
if 'file_path' in st.session_state and st.session_state['file_path'] != '':
if os.path.getsize(file_path) > st.web.server.server.get_max_message_size_bytes():
print(f"Media file cannot be previewed: size exceeds the message size limit of {st.web.server.server.get_max_message_size_bytes() / int(1e6):.2f} MB.")
st.info(f'Media file cannot be previewed: size exceeds the size limit of {st.web.server.server.get_max_message_size_bytes() / int(1e6):.2f} MB.'
f' But you can try to run the transcription as usual.', icon="🚨")
st.info(f' You can increase the limit by running: subsai-webui --server.maxUploadSize Your_desired_limit_in_MB')
st.info(f"If it didn't work, please use the command line interface instead.")
else:
event = st_player(_media_file_base64(st.session_state['file_path']), **options, height=500, key="player")

with st.expander('Export subtitles file'):
media_file = Path(file_path)
Expand Down

0 comments on commit b0770c1

Please sign in to comment.