3

I need to install the Python module audiolab for a research project, and while I have managed to install it and get the module to import in the Python shell, it returns an error in calling one of the most basic functions in the module, wavread().

I am using Python2.7.1 mainly, though I did try backtracking and installing audiolab for Python2.6.6, only to find the same error message after importing and calling the wavread() function.

My operating system is Mac OS X 10.5.8 with an intel processor.

This is generally how it goes:

import numpy                            
import scipy                           
import scikits.audiolab as audio                           
x, fs, nbits = audio.wavread('test.wav')                           

Traceback (most recent call last):

  File "<pyshell#3>", line 1, in <module>                           
    x, fs, nbits = audio.wavread('test.wav')                           
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.3-                           fat.egg/scikits/audiolab/pysndfile/matapi.py", line 91, in basic_reader                           
    hdl = Sndfile(filename, 'r')                           
  File "_sndfile.pyx", line 488, in scikits.audiolab.pysndfile._sndfile.Sndfile.__init__ (scikits/audiolab/pysndfile/_sndfile.c:4251)                                                      
IOError: error while opening test.wav                           
    ->error while opening file test.wav                           
    -> System error : No such file or directory.                           

I installed the libsndfile library (which I believe audiofile is simply a wrapper around) using pip and that seemed to install fine without error. I then tried to install audiolab from the tar.gz file, using the command python setup.py install in Terminal. This is as directed in the documentation, found here under the header 'build'

The documentation also talks about in some cases needing to make a 'site.cfg' file, which from what I saw after some google searching, only really applies to Windows users, though I'm not certain about this.

Any light you could shed on my problem would be much appreciated!!

1 Answer 1

4

The audiolab documentation is somewhat lacking, but wavread() requires an input file. In your code, that input is test.wav. If it doesn't exist in the working directory (usually the location of your python script), you need to provide the full path to the file.

1
  • Thanks for the quick answer, that actually fixed my problem! For some reason I just assumed the package would place the test documents in the proper folder to read them as an input, though this is not the case. Also, I should add that before running any programs, the current working directory was the audiolab folder found with the rest of my installed modules. After running a program, however, the working directory moves, so files in the module directory can no longer be accessed in interactive mode. Just in case anybody runs into this problem in the future... Feb 10, 2011 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.