How to display multiple audio files in google colab?

Viewed 518

I would like to display multiple audio files in google colab, but I found that only one is possible in one codeblock. Therefore I was thinking, whether I could generate code blocks with a given text.

Something like:

for i in range(0,4):
  create_code_block("display.Audio(str(sound_paths[" + str(i) + "]))")
1 Answers

You mistake display.Audio for displaying. It's just creating Audio objects.

You need this instead.

display.display(display.Audio(filename))

And try to avoid overwrite the display. Don't do this

from IPython import display  # don't do

Because you cannot use the old display anymore.

Normally you can just

display(Audio(...))

Now you would need to use

display.display(display.Audio(...))
Related