einanao commited on
Commit
218c37d
1 Parent(s): 42a21dd

fix tooltip

Browse files
Files changed (2) hide show
  1. app.py +25 -9
  2. example.png +2 -2
app.py CHANGED
@@ -217,23 +217,33 @@ def strike(url, speedup_factor, min_speedup, max_speedup, max_num_segments):
217
  max_time = segments[-1]["end"] / 60
218
  lines = (
219
  alt.Chart(df, title="information rate")
220
- .mark_line(color="gray", opacity=0.5)
221
  .encode(
222
  x=alt.X(cols[0], scale=alt.Scale(domain=(min_time, max_time))),
223
  y=cols[1],
224
  )
225
  )
226
- dots = (
 
 
 
 
 
 
 
227
  alt.Chart(df)
228
- .mark_circle(size=50, opacity=1)
229
  .encode(
230
  x=alt.X(cols[0], scale=alt.Scale(domain=(min_time, max_time))),
231
  y=cols[1],
232
- tooltip=["transcript"],
 
233
  )
 
234
  )
235
- st.altair_chart((lines + dots).interactive(), use_container_width=True)
236
- st.info("hover over the dots in the plot above this message to read the transcript")
 
237
 
238
  st.write("sped-up audio:")
239
  st.audio(output_path)
@@ -288,9 +298,15 @@ with st.form("my_form"):
288
  url = st.text_input(
289
  "youtube url", value="https://www.youtube.com/watch?v=_3MBQm7GFIM"
290
  )
291
- speedup_factor = st.slider("overall speedup for entire file", min_value=0.5, max_value=5.0, value=1.5)
292
- min_speedup = st.slider("minimum speedup per segment", min_value=0.5, max_value=5.0, value=1.0)
293
- max_speedup = st.slider("maximum speedup per segment", min_value=0.5, max_value=5.0, value=2.0)
 
 
 
 
 
 
294
  max_num_segments = st.slider(
295
  "variance in speedup across segments", min_value=2, max_value=100, value=20
296
  )
 
217
  max_time = segments[-1]["end"] / 60
218
  lines = (
219
  alt.Chart(df, title="information rate")
220
+ .mark_line(color="gray")
221
  .encode(
222
  x=alt.X(cols[0], scale=alt.Scale(domain=(min_time, max_time))),
223
  y=cols[1],
224
  )
225
  )
226
+ hover = alt.selection_single(
227
+ fields=cols[:1],
228
+ nearest=True,
229
+ on="mouseover",
230
+ empty="none",
231
+ )
232
+ points = lines.transform_filter(hover).mark_circle(size=65, color="orange")
233
+ tooltips = (
234
  alt.Chart(df)
235
+ .mark_rule(color="orange")
236
  .encode(
237
  x=alt.X(cols[0], scale=alt.Scale(domain=(min_time, max_time))),
238
  y=cols[1],
239
+ opacity=alt.condition(hover, alt.value(1), alt.value(0)),
240
+ tooltip=[alt.Tooltip("transcript", title="transcript")],
241
  )
242
+ .add_selection(hover)
243
  )
244
+ chart = (lines + points + tooltips).interactive()
245
+ st.altair_chart(chart, use_container_width=True)
246
+ st.info("hover over the plot above this message to read the transcript")
247
 
248
  st.write("sped-up audio:")
249
  st.audio(output_path)
 
298
  url = st.text_input(
299
  "youtube url", value="https://www.youtube.com/watch?v=_3MBQm7GFIM"
300
  )
301
+ speedup_factor = st.slider(
302
+ "overall speedup for entire file", min_value=0.5, max_value=5.0, value=1.5
303
+ )
304
+ min_speedup = st.slider(
305
+ "minimum speedup per segment", min_value=0.5, max_value=5.0, value=1.0
306
+ )
307
+ max_speedup = st.slider(
308
+ "maximum speedup per segment", min_value=0.5, max_value=5.0, value=2.0
309
+ )
310
  max_num_segments = st.slider(
311
  "variance in speedup across segments", min_value=2, max_value=100, value=20
312
  )
example.png CHANGED

Git LFS Details

  • SHA256: a8e2dc0ec6abbcf8ae7af071749ff0c94939e786c627fbaf84edfcd16d8eb2ce
  • Pointer size: 132 Bytes
  • Size of remote file: 1.36 MB

Git LFS Details

  • SHA256: 7ddfadaf157ed6fb6b1fbdf53b2301f82900760c1ea36349a14edc2e4194d173
  • Pointer size: 132 Bytes
  • Size of remote file: 1.29 MB