Spaces:
Sleeping
Sleeping
css
Browse files
README.md
CHANGED
|
@@ -4,9 +4,10 @@ emoji: 📚
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
|
|
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.8.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
+
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1153,70 +1153,181 @@ def generate_key_moments(formatted_simple_transcript, formatted_transcript):
|
|
| 1153 |
return key_moments
|
| 1154 |
|
| 1155 |
def get_key_moments_html(key_moments):
|
| 1156 |
-
"""
|
| 1157 |
-
Generates HTML for key moments with a left-side gallery and right-side text.
|
| 1158 |
-
"""
|
| 1159 |
css = """
|
| 1160 |
<style>
|
| 1161 |
-
|
| 1162 |
-
|
| 1163 |
-
.gallery-container {
|
| 1164 |
display: flex;
|
| 1165 |
align-items: center;
|
| 1166 |
margin-bottom: 20px;
|
| 1167 |
}
|
| 1168 |
-
|
|
|
|
| 1169 |
position: relative;
|
| 1170 |
-
|
| 1171 |
flex: 1;
|
| 1172 |
}
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
display: block;
|
| 1176 |
-
margin: 0 auto; /* Center the image */
|
| 1177 |
-
}
|
| 1178 |
-
.text-content {
|
| 1179 |
flex: 2;
|
| 1180 |
margin-left: 20px;
|
| 1181 |
}
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1185 |
position: absolute;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1186 |
top: 50%;
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1193 |
}
|
| 1194 |
-
.arrow-prev { left: 0; }
|
| 1195 |
-
.arrow-next { right: 0; }
|
| 1196 |
</style>
|
| 1197 |
"""
|
| 1198 |
|
| 1199 |
-
key_moments_html =
|
| 1200 |
|
| 1201 |
for i, moment in enumerate(key_moments):
|
| 1202 |
-
start_time = moment['start']
|
| 1203 |
-
end_time = moment['end']
|
| 1204 |
-
text = moment['text']
|
| 1205 |
-
transcript = moment['transcript']
|
| 1206 |
images = moment['images']
|
| 1207 |
-
image_elements = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1208 |
|
| 1209 |
key_moments_html += f"""
|
| 1210 |
-
<div class="gallery-container">
|
| 1211 |
-
<div
|
| 1212 |
-
<
|
| 1213 |
-
|
| 1214 |
-
|
| 1215 |
</div>
|
| 1216 |
-
<div
|
| 1217 |
-
<h3>{
|
| 1218 |
-
<p><strong
|
| 1219 |
-
<p
|
| 1220 |
</div>
|
| 1221 |
</div>
|
| 1222 |
"""
|
|
|
|
| 1153 |
return key_moments
|
| 1154 |
|
| 1155 |
def get_key_moments_html(key_moments):
|
|
|
|
|
|
|
|
|
|
| 1156 |
css = """
|
| 1157 |
<style>
|
| 1158 |
+
#gallery-main {
|
|
|
|
|
|
|
| 1159 |
display: flex;
|
| 1160 |
align-items: center;
|
| 1161 |
margin-bottom: 20px;
|
| 1162 |
}
|
| 1163 |
+
|
| 1164 |
+
#gallery {
|
| 1165 |
position: relative;
|
| 1166 |
+
width: 50%;
|
| 1167 |
flex: 1;
|
| 1168 |
}
|
| 1169 |
+
|
| 1170 |
+
#text-content {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1171 |
flex: 2;
|
| 1172 |
margin-left: 20px;
|
| 1173 |
}
|
| 1174 |
+
|
| 1175 |
+
|
| 1176 |
+
#gallery #gallery-container{
|
| 1177 |
+
position: relative;
|
| 1178 |
+
width: 100%;
|
| 1179 |
+
height: 0px;
|
| 1180 |
+
padding-bottom: 56.7%; /* 16/9 ratio */
|
| 1181 |
+
background-color: blue;
|
| 1182 |
+
}
|
| 1183 |
+
#gallery #gallery-container #gallery-content{
|
| 1184 |
+
position: absolute;
|
| 1185 |
+
top: 0px;
|
| 1186 |
+
right: 0px;
|
| 1187 |
+
bottom: 0px;
|
| 1188 |
+
left: 0px;
|
| 1189 |
+
height: 100%;
|
| 1190 |
+
display: flex;
|
| 1191 |
+
scroll-snap-type: x mandatory;
|
| 1192 |
+
overflow-x: scroll;
|
| 1193 |
+
scroll-behavior: smooth;
|
| 1194 |
+
}
|
| 1195 |
+
#gallery #gallery-container #gallery-content .gallery__item{
|
| 1196 |
+
width: 100%;
|
| 1197 |
+
height: 100%;
|
| 1198 |
+
flex-shrink: 0;
|
| 1199 |
+
scroll-snap-align: start;
|
| 1200 |
+
scroll-snap-stop: always;
|
| 1201 |
+
position: relative;
|
| 1202 |
+
}
|
| 1203 |
+
#gallery #gallery-container #gallery-content .gallery__item img{
|
| 1204 |
+
display: block;
|
| 1205 |
+
width: 100%;
|
| 1206 |
+
height: 100%;
|
| 1207 |
+
object-fit: contain;
|
| 1208 |
+
background-color: white;
|
| 1209 |
+
}
|
| 1210 |
+
|
| 1211 |
+
.click-zone{
|
| 1212 |
+
position: absolute;
|
| 1213 |
+
width: 20%;
|
| 1214 |
+
height: 100%;
|
| 1215 |
+
z-index: 3;
|
| 1216 |
+
}
|
| 1217 |
+
.click-zone.click-zone-prev{
|
| 1218 |
+
left: 0px;
|
| 1219 |
+
}
|
| 1220 |
+
.click-zone.click-zone-next{
|
| 1221 |
+
right: 0px;
|
| 1222 |
+
}
|
| 1223 |
+
#gallery:not(:hover) .arrow{
|
| 1224 |
+
opacity: 0.8;
|
| 1225 |
+
}
|
| 1226 |
+
.arrow{
|
| 1227 |
+
text-align: center;
|
| 1228 |
+
z-index: 3;
|
| 1229 |
position: absolute;
|
| 1230 |
+
display: block;
|
| 1231 |
+
width: 25px;
|
| 1232 |
+
height: 25px;
|
| 1233 |
+
line-height: 25px;
|
| 1234 |
+
background-color: black;
|
| 1235 |
+
border-radius: 50%;
|
| 1236 |
+
text-decoration: none;
|
| 1237 |
+
color: black;
|
| 1238 |
+
opacity: 0.8;
|
| 1239 |
+
transition: opacity 200ms ease;
|
| 1240 |
+
}
|
| 1241 |
+
.arrow:hover{
|
| 1242 |
+
opacity: 1;
|
| 1243 |
+
}
|
| 1244 |
+
.arrow span{
|
| 1245 |
+
position: relative;
|
| 1246 |
+
top: 2px;
|
| 1247 |
+
}
|
| 1248 |
+
.arrow.arrow-prev{
|
| 1249 |
top: 50%;
|
| 1250 |
+
left: 5px;
|
| 1251 |
+
}
|
| 1252 |
+
.arrow.arrow-next{
|
| 1253 |
+
top: 50%;
|
| 1254 |
+
right: 5px;
|
| 1255 |
+
}
|
| 1256 |
+
.arrow.arrow-disabled{
|
| 1257 |
+
opacity:0.8;
|
| 1258 |
+
}
|
| 1259 |
+
|
| 1260 |
+
#text-content {
|
| 1261 |
+
padding: 0px 36px;
|
| 1262 |
+
}
|
| 1263 |
+
#text-content p {
|
| 1264 |
+
margin-top: 10px;
|
| 1265 |
+
}
|
| 1266 |
+
|
| 1267 |
+
body{
|
| 1268 |
+
font-family: sans-serif;
|
| 1269 |
+
margin: 0px;
|
| 1270 |
+
padding: 0px;
|
| 1271 |
+
}
|
| 1272 |
+
main{
|
| 1273 |
+
padding: 0px;
|
| 1274 |
+
margin: 0px;
|
| 1275 |
+
max-width: 900px;
|
| 1276 |
+
margin: auto;
|
| 1277 |
+
}
|
| 1278 |
+
.hidden{
|
| 1279 |
+
border: 0;
|
| 1280 |
+
clip: rect(0 0 0 0);
|
| 1281 |
+
height: 1px;
|
| 1282 |
+
margin: -1px;
|
| 1283 |
+
overflow: hidden;
|
| 1284 |
+
padding: 0;
|
| 1285 |
+
position: absolute;
|
| 1286 |
+
width: 1px;
|
| 1287 |
}
|
|
|
|
|
|
|
| 1288 |
</style>
|
| 1289 |
"""
|
| 1290 |
|
| 1291 |
+
key_moments_html = css
|
| 1292 |
|
| 1293 |
for i, moment in enumerate(key_moments):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1294 |
images = moment['images']
|
| 1295 |
+
image_elements = ""
|
| 1296 |
+
|
| 1297 |
+
for j, image in enumerate(images):
|
| 1298 |
+
current_id = f"img_{i}_{j}"
|
| 1299 |
+
prev_id = f"img_{i}_{j-1}" if j-1 >= 0 else f"img_{i}_{len(images)-1}"
|
| 1300 |
+
next_id = f"img_{i}_{j+1}" if j+1 < len(images) else f"img_{i}_0"
|
| 1301 |
+
|
| 1302 |
+
image_elements += f"""
|
| 1303 |
+
<div id="{current_id}" class="gallery__item">
|
| 1304 |
+
<a href="#{prev_id}" class="click-zone click-zone-prev">
|
| 1305 |
+
<div class="arrow arrow-disabled arrow-prev"> < </div>
|
| 1306 |
+
</a>
|
| 1307 |
+
<a href="#{next_id}" class="click-zone click-zone-next">
|
| 1308 |
+
<div class="arrow arrow-next"> > </div>
|
| 1309 |
+
</a>
|
| 1310 |
+
<img src="{image}">
|
| 1311 |
+
</div>
|
| 1312 |
+
"""
|
| 1313 |
+
|
| 1314 |
+
gallery_content = f"""
|
| 1315 |
+
<div id="gallery-content">
|
| 1316 |
+
{image_elements}
|
| 1317 |
+
</div>
|
| 1318 |
+
"""
|
| 1319 |
|
| 1320 |
key_moments_html += f"""
|
| 1321 |
+
<div class="gallery-container" id="gallery-main">
|
| 1322 |
+
<div id="gallery"><!-- gallery start -->
|
| 1323 |
+
<div id="gallery-container">
|
| 1324 |
+
{gallery_content}
|
| 1325 |
+
</div>
|
| 1326 |
</div>
|
| 1327 |
+
<div id="text-content">
|
| 1328 |
+
<h3>{moment['start']} - {moment['end']}</h3>
|
| 1329 |
+
<p><strong>摘要: {moment['text']} </strong></p>
|
| 1330 |
+
<p>內容: {moment['transcript']}</p>
|
| 1331 |
</div>
|
| 1332 |
</div>
|
| 1333 |
"""
|