Spaces:
Sleeping
Sleeping
Add timestamps
Browse files
app.py
CHANGED
@@ -11,6 +11,28 @@ from features import FEATURES
|
|
11 |
from utils import check_password, process_olivia_data
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
REPO_URL = "https://huggingface.co/datasets/trevolution/conversation-analytics-comments"
|
15 |
api = HfApi()
|
16 |
|
@@ -111,7 +133,13 @@ def main():
|
|
111 |
st.text('Analytics')
|
112 |
readable_analytics = ''
|
113 |
for i, feature in enumerate(analytics):
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
st.markdown(get_div(readable_analytics), unsafe_allow_html=True)
|
116 |
|
117 |
|
|
|
11 |
from utils import check_password, process_olivia_data
|
12 |
|
13 |
|
14 |
+
def format_seconds(seconds: int) -> str:
|
15 |
+
if seconds == 1:
|
16 |
+
return "1 second"
|
17 |
+
elif seconds < 60:
|
18 |
+
return f"{seconds} seconds"
|
19 |
+
else:
|
20 |
+
minutes = seconds // 60
|
21 |
+
remaining_seconds = seconds % 60
|
22 |
+
|
23 |
+
if minutes == 1:
|
24 |
+
minute_str = "1 minute"
|
25 |
+
else:
|
26 |
+
minute_str = f"{minutes} minutes"
|
27 |
+
|
28 |
+
if remaining_seconds == 1:
|
29 |
+
second_str = "1 second"
|
30 |
+
else:
|
31 |
+
second_str = f"{remaining_seconds} seconds"
|
32 |
+
|
33 |
+
return f"{minute_str} {second_str}"
|
34 |
+
|
35 |
+
|
36 |
REPO_URL = "https://huggingface.co/datasets/trevolution/conversation-analytics-comments"
|
37 |
api = HfApi()
|
38 |
|
|
|
133 |
st.text('Analytics')
|
134 |
readable_analytics = ''
|
135 |
for i, feature in enumerate(analytics):
|
136 |
+
if feature['timestamp']:
|
137 |
+
start_time, end_time = int(feature['timestamp'][0]), int(feature['timestamp'][1])
|
138 |
+
start_time, end_time = format_seconds(start_time), format_seconds(end_time)
|
139 |
+
|
140 |
+
readable_analytics += f"{i+1}. {feature['name']}: {feature['response']}. Quotation: {feature['quotation']}. Timestamp: {start_time}-{end_time}\n\n\n"
|
141 |
+
else:
|
142 |
+
readable_analytics += f"{i+1}. {feature['name']}: {feature['response']}. Quotation: {feature['quotation']}"
|
143 |
st.markdown(get_div(readable_analytics), unsafe_allow_html=True)
|
144 |
|
145 |
|