scottire / fastpages

Apache License 2.0
21 stars 8 forks source link

Building Tools to Interact With Your Data | Scott Condron’s Blog #35

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Building Tools to Interact With Your Data | Scott Condron’s Blog

Creating an interactive audio visualisation tool from the ground up in Jupyter Notebooks using Python.

https://www.scottcondron.com/jupyter/visualisation/audio/2020/10/21/interactive-audio-plots-in-jupyter-notebook.html

AMITKESARI2000 commented 1 year ago

Awesome post! Thank you for this. Also can we change the colour of the vertical line from somewhere?

scottire commented 1 year ago

Thanks, yep. With Holoviews you update styling by passing in opts with the type you want to change to opts. Here is how you would style the VLine:

def update_playhead(x,y,t):
    if x is None:
        return hv.VLine(t).opts(opts.VLine(color='red', linewidth=6))
    else:
        audio.time = x
        return hv.VLine(x).opts(opts.VLine(color='red', linewidth=6))
ThomasHezard commented 1 year ago

Hello,

Thanks for this post, exactly what I was looking for ! 🤗

However, I face two issues, and you may help me resolve it.

I copied you code from All code in one place but I get the following error:

ValueError: Audio pane does not support objects of type 'ndarray'.

I changed the code to send the file path instead of audio data and sample rate to pn.pane.Audio and it executes fine.

However, I don't have any output, nothing get displayed.
FYI, I'm not familiar at all with holoviews (juste discovered it here).

I'm working with Python 3.9.13 in Jupyter with the following version:

IPython          : 8.4.0
ipykernel        : 6.15.1
ipywidgets       : 7.7.1
jupyter_client   : 7.3.4
jupyter_core     : 4.11.1
jupyter_server   : 1.18.1
jupyterlab       : 3.4.4
nbclient         : 0.6.6
nbconvert        : 6.5.0
nbformat         : 5.4.0
notebook         : 6.4.12
qtconsole        : 5.3.1
traitlets        : 5.3.0

Any idea of what is going on here?

ai2ys commented 1 year ago

Thanks for sharing the code, this is what I am looking for. Unfortunately, the "VLine" is not updating its position when pressing the play button. Do you have any idea, why it might not be working?

YuhengHuang42 commented 1 year ago

Hello,

Thanks for this post, exactly what I was looking for ! 🤗

However, I face two issues, and you may help me resolve it.

I copied you code from All code in one place but I get the following error:

ValueError: Audio pane does not support objects of type 'ndarray'.

I changed the code to send the file path instead of audio data and sample rate to pn.pane.Audio and it executes fine.

However, I don't have any output, nothing get displayed. FYI, I'm not familiar at all with holoviews (juste discovered it here).

I'm working with Python 3.9.13 in Jupyter with the following version:

IPython          : 8.4.0
ipykernel        : 6.15.1
ipywidgets       : 7.7.1
jupyter_client   : 7.3.4
jupyter_core     : 4.11.1
jupyter_server   : 1.18.1
jupyterlab       : 3.4.4
nbclient         : 0.6.6
nbconvert        : 6.5.0
nbformat         : 5.4.0
notebook         : 6.4.12
qtconsole        : 5.3.1
traitlets        : 5.3.0

Any idea of what is going on here?

pn.pane.Audio only accepts np.array with int16, you need to transfer your array into the corresponding format, such as:

samples16 = np.int16(samples * 32767)
audio = pn.pane.Audio(samples16, sample_rate=sr, name='Audio', throttle=500)