2012-04-17 2 views
1

이것이 가능합니까 ?? 내가 추측하고있어TIMIT 데이터베이스의 Nist Wav 파일을 파이썬 numpy 배열로 읽어들입니다.

x86_64.egg/scikits/audiolab/pysndfile/matapi.pyc in basic_reader(filename, last, first) 
    93    if not hdl.format.file_format == filetype: 
    94     raise ValueError, "%s is not a %s file (is %s)" \ 
---> 95      % (filename, filetype, hdl.format.file_format) 
    96 
    97    fs = hdl.samplerate 

ValueError: si762.wav is not a wav file (is nist) 

는 NIST의 wav 파일을 읽을 수 있지만 쉽게 NumPy와 배열로 읽을 수있는 또 다른 방법이있다 : 나는 scikits.audiolab에서 wavread를 사용할 때이 오류가 발생하는 것? 그렇지 않은 경우 데이터를 읽는 가장 좋은 방법은 무엇입니까?

아마도 nist 헤더를 인식하기 위해 audiolab wavread를 다시 작성 하시겠습니까 ??

답변

3

알아 냈으므로 내 자신의 질문에 답하십시오. 그러나 libsndfile에 따라 읽기 및 쓰기 파일 형식을 다양하게 지원하는 scikits.audiolab의 Sndfile 클래스를 사용할 수 있습니다. 그런 다음 당신은 그냥 사용 scikits.audiolab를 사용할 때 전체 파일, 프레임 아니라 지정된 번호를 읽으려면

from scikits.audiolab import Sndfile, play 
f = Sndfile(filename, 'r') 
data = f.read_frames(10000) 
play(data) # Just to test the read data 
1

는, J SPEN의 대답에 확장하려면, 당신은 Sndfile 클래스의 nframes 매개 변수를 사용할 수 있습니다 모든 것을 읽을 수 있습니다. 예를 들어 :

from scikits.audiolab import Sndfile, play 
f = Sndfile(filename, 'r') 
data = f.read_frames(f.nframes) 
play(data) # Just to test the read data 

나는 문서에서이에 대한 참조를 찾을 수 있지만 소스에있다.

관련 문제