Hello everyone,
I am working on a speech analytic app that makes use of the progress bar.
Once in a while, I get the following error and I am not sure what the issue is.
Progressbar error: StreamlitAPIException: Progress Value has invalid value [0.0, 1.0]: 1.100000
Here is my code:
a
and line 96 is
sleep_duration = 0.01
Thanks in advance for your help.
st.title("Speech to Text, made simple")
st.header("Transcribe audio to text")
# st.markdown("<h2 style='text-align: left; color:black;'>Automatic audio to text transcriptions</h2>",
# unsafe_allow_html=True)
fileObject = st.file_uploader(
label="Please upload your audio file", type=["mp3"])
if fileObject is not None:
# st.write(type(fileObject))
file_details = {"filename": fileObject.name,
"filetype": fileObject.type, "filesize": fileObject.size}
st.write(file_details)
audio_bytes = fileObject.getvalue()
st.audio(audio_bytes, format='audio/mp3')
token, t_id = upload_file(fileObject)
result = {}
print(result)
# polling
sleep_duration = 1
percent_complete = 0
progress_bar = st.progress(percent_complete)
st.text("Processing...")
while result.get("status") != "processing":
percent_complete += sleep_duration
time.sleep(sleep_duration)
progress_bar.progress(percent_complete/10)
result = get_text(token, t_id)
sleep_duration = 0.01
for percent in range(percent_complete, 101):
time.sleep(sleep_duration)
progress_bar.progress(percent)
with st.spinner("Grab a coffee while we transcribe your file....."):
while result.get("status") != 'completed':
result = get_text(token, t_id)
# st.balloons()
# st.header("Transcribed Text")
# st.subheader(result['text'])
nlp = spacy.load("en_core_web_sm")
# DEFAULT_TEXT = result['text']
CONFIDENCE = result['confidence']
if CONFIDENCE > 0.90:
st.write("Audio quality is pretty good with", round(
CONFIDENCE, 2), "percentage confidence level")
else:
st.write("Audio quality could be better", round(
CONFIDENCE, 2), "percentage confidence level")
AUDIO_DURATION = time.strftime(
"%M:%S", time.localtime(result['audio_duration']))
# AUDIO_DURATION = round(result['audio_duration']/60, 2)
# print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
st.write("Audio file is:", AUDIO_DURATION, "(minutes, seconds) long")
DEFAULT_TEXT = result['text']
ALL_WORDS = result['utterances']