Jupyter - widget to play audio with playhead on graph - python

Is there any Jupyter widget for visualizing audio synced with a playhead on a time-series plot?
I would like to visualize data derived from an audio sample (e.g. spectrogram and various computed signals), listening to the audio sample while seeing the playhead move across the plots.
I found this old gist https://gist.github.com/deeplycloudy/2152643 which uses pyaudio on the Python backend to play the sound. Any good solutions out there that are a bit less hacky, e.g. ideally entirely JavaScript-based and with playback running fully in the browser?

You can now :). It took me about 10 minutes to put together a demo using Jupyter proxy widget to load a wavesurfer control into a notebook. It works in Chrome but I haven't tested it anywhere else. It should work anywhere wavesurfer and Jupyter work.
Here is a screenshot
See the pastable text from the notebook here:
https://github.com/AaronWatters/jp_doodle/blob/master/notebooks/misc/wavesurfer%20demo.ipynb
For information on jp_proxy widgets look here:
https://github.com/AaronWatters/jp_proxy_widget

In the time since I posted this question, a few new solutions have emerged:
Scott Condron: Building Tools to Interact With Your Data
Building Tools to Interact With Your Data 2020-10-21-interactive-audio-plots-in-jupyter-notebook.ipynb
These solutions use holoview, have a playhead linked between the audio and the plots, and can run fully on the browser.

Related

Python Extracting Camera Video Motion Keyframes (AI tools)

I've been searching for quite some time now, but the only example I've seen where camera motion keyframes (movements) can be extracted from a video is in blender. I'm looking for a script, library, colab notebook, or any recommendation to be able input a video (for example, getting the camera keyframe movements from a video of a drone flying around) and exporting it to any type of file. The main purpose of this is double-sided: I want to be able to take the camera keyframe movements from the drone video and input it into an AI Art Animation and I want to be able to learn and add this python tool or library into a colab notebook of AI tools I've been slowly building over the months. Any help from you masterful wizards will be appreciated. Thanks!
I'm a "hacker", "novice-intermediate" level python coder, meaning I can read code and understand most basic and some advanced type coding. I'm able to read code quite well and manipulate it to my preferences, but I just don't even know where to start when it comes to the request I'm asking, ergo my post to Stack.

Generating animation in the browser using matplotlib

Let me describe the background first:
We have a python package that uses matplotib to create animations.
Currently, we use this package to create gifs, which we embed into our website.
In the future, the number of animations will increase, so that we are looking for a way to create these gifs only dynamically when a user wants to see a gif. Preferably, these animations will be created in the browser using the CPU of the user. I have seen that mpld3 can be used to create visualizations, however, animations are not supported and it is using our CPU.
This leads me to the question: Does someone know about a way to generate animations from matplotlib code in the browser preferably using the CPU of the user (not a must have)? Maybe is there a way of using jupyter notebooks for that?

Create a basic Python interface to save images drawn with a mouse

I am working on the following project and I am having really difficulties in finding the right way of doing that. I would like to build in Python (but I am open to other possibilities) a very basic interface that allows the user to draw with the mouse (or the pen if used on a surface laptop) something and then save the image. Ideally I would like this to work on a website or at least in a jupyter notebook (at least I imagine this to be utterly difficult).
Anyone can point me in the right direction? The goal would be to use the images as input to a neural network model to demonstrate its result with real life examples.
I am looking at tk but I don't seem to find much in terms of examples.
Thanks in advance, Umberto
I'd take a look at pyautogui to capture the mouse location then "draw" it in matplotlib -- should be able to do this in a loop. You'll want to watch the tkinter window size to sync the mouse coordinates with the relative location.
Why not just have your script open create a new blank img and automatically open it with paint - then read it on close? Seems easier than creating a drawing GUI.
Have a look at my Github repository which have exactly what you need.
Link : CanvasDraw Repo
Depending on the complexity you could either use tkinter which is a package for complex GUIs or something from the gaming community like pygames. You have user input and graphical output so libraries made for games will do what you want but provide way more stuff then you need. This site might help you: Drawing Libarys
Also the answere draw-on-python-tkinter-canvas-using-mouse-and-obtain-points-to-a-list might help you.

How to display multiple video stream in one window

I am trying some video processing exercises, and wondering if there is a way to display multiple video streams into one window a la pyplot.subplot command for the images.
I've tried using subplot syntax, but using it freezes the program, so any alternative source would be much appreciated.
It is possible to display multiple videos(e.g 2-videos can be displayed for dual core processor) at a time for that you have use OpenMP. It is possible if your using opencv. And it is pretty easy Only you have to enable OpenMp in your property sheet.

How to embed an interactive matplotlib plot in a webpage

I have been searching how to embed an interactive matplotlib widget (like this one: http://matplotlib.org/examples/widgets/slider_demo.html) in a webpage. The final aim is to make an educational page.
I hope I am not duplicating the question. What google finds is always how to embed the plot as a still-shot, in an image format.
I thought I can do something with ipython notebook or plotly or gjango. But I got confused.
Is it possible at all for intractive plots?
I appreciate your guides to which direction I should think and work on.
Thank you.
In summer 2015, I'm facing a similar task: embed interactive widgets that change their underlying data when the slider is moved. This is very similar to interactive IPython widgets which are interactive when run on a local machine. Examples of what I want can be found jakevdp's blog.
To summarize work done so far:
ipywidgets-static converts interactive IPython widgets to static HTML. However, this library is no longer maintained. Development has moved to ipython/ipywidgets.
IPython is working on ipython/ipywidgets. They have a Github issue to make these widgets static and to be embedded in a standalone HTML file.
HoloViews provides some interactive slider options that can be embedded in a static HTML file (using IPython's nbconvert)
Bokeh plots that rely on interactive sliders require a server.
plot.ly doesn't support sliders/etc. I believe this is true based off this blog post.
mpld3 converts between matplotlib and d3. I believe this library supports panning and zooming, not sliders/interactivity. Here's a related Github issue
There's also blog post titled "Scientific Python in the browser: it's coming!". This post was dated 2014-3-31.
For me, the two most attractive options are ipywidgets and HoloViews but I'm looking forward to when IPython provides static interactive widgets. I expect to see solid support for static interactive widgets quickly and in less that 5 years/2020 (and in 2 years/2017?).
As of Early April 2014 the answer is yes. Based on the work going on in this space, I expect the quality and quantity of such libraries to continue to improve very quickly.
IPython 2.0, specifically the notebook, supports interactive controls, which was covered in some detail by Brian Granger in his talk IPython - The Attributes of Software and How They Affect Our Work (see from 32:25 onward for the bits you're interested in)
There are some amazing projects being worked on at the moment that combine server and client side code for the next generation of python visualisation libraries. At the moment this includes the work on MPLD3 and the ipywidgets library. There are some great interactive plots on Jake Vanderplas' blog Pythonic Perambulations that show demonstrate this.

Categories

Resources