The IPython.display.Audio(...)
command only creates a "display" object (in that particular case, an object of the subclass Audio
of the class DisplayObject
).
Afterwards, you may do basic actions with such an object, tied to the class DisplayObject
(and specific stuff tied to the class Audio
). One of those actions consists of displaying it, by using the IPython.display.display
function.
Your particular goal will thus be achieved by the following code:
import IPython
IPython.display.display(IPython.display.Audio(url="https://ccrma.stanford.edu/~urinieto/drop/090412-Incendios.mp3"))
IPython.display.display(IPython.display.Audio(url="https://ccrma.stanford.edu/~urinieto/drop/130224-Undertow.mp3"))
The same mechanism is used to display other types (subclasses) of DisplayObject
objects: HTML
, Markdown
, Math
, SVG
, Javascript
, Video
, Image
, etc. See this for details.
Three things are really confusing when you try to do this for the first time (I was also confused at first):
the name of the command IPython.display.Audio
, which seems to imply that something will be displayed; that isn't the case;
the fact that all those multimedia objects are collectively called "display" objects, while some of them are never really "displayed", just embedded in the DOM tree (e.g., a Javascript
object);
the fact that if you create such an object and don't use IPython.display.display
on it, it will be automatically displayed by the standard IPython interactive mechanism if it's the last thing created in the cell; that's the major source of confusion because it lets people think that you don't need to use any particular function to display a "display object".
IPython.display.display
function repeatedly. See this for an example. – Diverticulitisimport IPython
IPython.display.display(IPython.display.Audio(url="https://ccrma.stanford.edu/~urinieto/drop/090412-Incendios.mp3"))
IPython.display.display(IPython.display.Audio(url="https://ccrma.stanford.edu/~urinieto/drop/130224-Undertow.mp3"))
and it seems to be working (on Windows 7 with python 3.4 + IPython 3.2...) – Diverticulitis