Spaces:
Runtime error
Runtime error
nahue-passano
commited on
Commit
•
9bdb941
1
Parent(s):
80f5b87
update: main streamlit app
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
import pandas as pd
|
4 |
|
5 |
from utils.files import (
|
@@ -7,7 +7,7 @@ from utils.files import (
|
|
7 |
save_temp_file,
|
8 |
compress_utterances_folder,
|
9 |
)
|
10 |
-
from utils.text import get_sentence_data, get_word_data, generate_transcriptions_splits
|
11 |
from utils.audio import generate_audio_splits
|
12 |
|
13 |
STAMP_TYPES = {"Sentence-level": "sentence", "Word-level": "word"}
|
@@ -62,9 +62,11 @@ def main_app():
|
|
62 |
model = load_model(model_size)
|
63 |
|
64 |
timestamps_df = pd.DataFrame()
|
|
|
65 |
temp_dir = create_temp_directory()
|
66 |
utterances_folder = temp_dir / "utterances_segments"
|
67 |
utterances_folder.mkdir(exist_ok=True)
|
|
|
68 |
for audio_i in audio_file:
|
69 |
with st.spinner(f"Processing audio: {audio_i.name}"):
|
70 |
tmp_audio = save_temp_file(audio_i)
|
@@ -78,10 +80,12 @@ def main_app():
|
|
78 |
# Stamp level
|
79 |
if timestamp_type == "Sentence-level":
|
80 |
audio_i_df = get_sentence_data(audio_i.name, timestamp_result)
|
|
|
|
|
81 |
|
82 |
if timestamp_type == "Word-level":
|
83 |
audio_i_df = get_word_data(audio_i.name, timestamp_result)
|
84 |
-
|
85 |
# Timestamps in dataframe
|
86 |
timestamps_df = pd.concat(
|
87 |
[timestamps_df, audio_i_df], ignore_index=True
|
@@ -89,6 +93,7 @@ def main_app():
|
|
89 |
|
90 |
generate_audio_splits(tmp_audio, audio_i_df, utterances_folder)
|
91 |
generate_transcriptions_splits(tmp_audio, audio_i_df, utterances_folder)
|
|
|
92 |
st.divider()
|
93 |
st.markdown(
|
94 |
"<h3 style='text-align: center;'>Timestamps</h3>",
|
@@ -119,4 +124,3 @@ def main_app():
|
|
119 |
|
120 |
if __name__ == "__main__":
|
121 |
main_app()
|
122 |
-
|
|
|
1 |
import streamlit as st
|
2 |
+
import whisper_transcriber as whisper
|
3 |
import pandas as pd
|
4 |
|
5 |
from utils.files import (
|
|
|
7 |
save_temp_file,
|
8 |
compress_utterances_folder,
|
9 |
)
|
10 |
+
from utils.text import get_sentence_data, get_word_data, generate_transcriptions_splits, check_ut_min_duration
|
11 |
from utils.audio import generate_audio_splits
|
12 |
|
13 |
STAMP_TYPES = {"Sentence-level": "sentence", "Word-level": "word"}
|
|
|
62 |
model = load_model(model_size)
|
63 |
|
64 |
timestamps_df = pd.DataFrame()
|
65 |
+
|
66 |
temp_dir = create_temp_directory()
|
67 |
utterances_folder = temp_dir / "utterances_segments"
|
68 |
utterances_folder.mkdir(exist_ok=True)
|
69 |
+
|
70 |
for audio_i in audio_file:
|
71 |
with st.spinner(f"Processing audio: {audio_i.name}"):
|
72 |
tmp_audio = save_temp_file(audio_i)
|
|
|
80 |
# Stamp level
|
81 |
if timestamp_type == "Sentence-level":
|
82 |
audio_i_df = get_sentence_data(audio_i.name, timestamp_result)
|
83 |
+
# Checks utterance duration
|
84 |
+
audio_i_df = check_ut_min_duration(audio_i_df)
|
85 |
|
86 |
if timestamp_type == "Word-level":
|
87 |
audio_i_df = get_word_data(audio_i.name, timestamp_result)
|
88 |
+
|
89 |
# Timestamps in dataframe
|
90 |
timestamps_df = pd.concat(
|
91 |
[timestamps_df, audio_i_df], ignore_index=True
|
|
|
93 |
|
94 |
generate_audio_splits(tmp_audio, audio_i_df, utterances_folder)
|
95 |
generate_transcriptions_splits(tmp_audio, audio_i_df, utterances_folder)
|
96 |
+
|
97 |
st.divider()
|
98 |
st.markdown(
|
99 |
"<h3 style='text-align: center;'>Timestamps</h3>",
|
|
|
124 |
|
125 |
if __name__ == "__main__":
|
126 |
main_app()
|
|