Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import re
|
3 |
+
|
4 |
+
# Define the function to remove timestamps
|
5 |
+
def remove_timestamps(text):
|
6 |
+
# Pattern to match timestamps in the format [HH:MM:SS.mmm -> HH:MM:SS.mmm]
|
7 |
+
pattern = r"\[\d{2}:\d{2}:\d{2}\.\d{3} -> \d{2}:\d{2}:\d{2}\.\d{3}\]\s*"
|
8 |
+
# Replace the matched patterns with an empty string
|
9 |
+
cleaned_text = re.sub(pattern, "", text)
|
10 |
+
return cleaned_text
|
11 |
+
|
12 |
+
# Create Streamlit UI elements
|
13 |
+
st.title("Whisper Remove Timestamps")
|
14 |
+
st.write("For API use please visit [this space](https://huggingface.co/spaces/Lenylvt/Whisper_Timestamps_Remover-API)")
|
15 |
+
|
16 |
+
# Text area for user input
|
17 |
+
user_input = st.text_area("βοΈ Enter text with timestamps", height=300)
|
18 |
+
|
19 |
+
# Button to remove timestamps
|
20 |
+
if st.button('π Remove Timestamps'):
|
21 |
+
# Display the cleaned text
|
22 |
+
result = remove_timestamps(user_input)
|
23 |
+
st.text_area("π Cleaned Text", value=result, height=300, key="result")
|