O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Repeating audio fragments

As we saw in Chapter 2, Advanced Indexing and Array Concepts, we can do neat things with WAV files. It's just a matter of downloading the file with the urllib2 standard Python module and loading it with SciPy. Let's download a WAV file and repeat it three times. We will skip some of the steps that we've already seen in Chapter 2, Advanced Indexing and Array Concepts.

How to do it...

  1. Although NumPy has a repeat() function, in this case, it is more appropriate to use the tile() function. The repeat() function would have the effect of enlarging the array by repeating individual elements and not repeating the contents of it. The following IPython session should clarify the difference between these functions:
    In: x = array([1, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required