audio - can the python wave module accept StringIO object -


I am trying to use the module to read wav files in python.

There is no specificity of my applications that I am not using a file or file name, but to read the WAV file, but instead I have a wav file in the buffer is.

And here's what I'm doing

  Import StringIO buffer = StringIO.StringIO () buffer.output (wav_buffer) file = wave.open (buffer, 'r' )  

but I'm getting a EOFError when I run it ...

  file "/ system / library / Framework / Python.framework / version / 2.5 / lib / python2.5 / wave.py /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ ", line 493, open return in Wave_read (f) file "Python2.5 / wave.py", line 163, __init__ in self.initfp (f) file "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/wave.py", line 128, initfp = share in self._file (part Il, bigendian = 0) file "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/chunk.py", line 63, __init__ in lifting EOFError  
< P> I know that the StringIO stuff works for the creation of the wav file and I tried the following and it works

  Import stringgeo buffer = String IO.StringIO () audio_out = wave.open (buffer, 'w') audio_ou t.setframerate (m.getRate ()) audio_out.setsampwidth (2) audio_out.setcomptype ('none', 'no compressed') audio_out. Setnchannels (1) audio_out.writeframes (raw_audio) audio_out.close () buffer.flush () #The work of these lines Hi ... # buffer.output (wav_buffer) #file = wave.open (buffer, 'r') # This file is played in VLC file = open (FILE_NAME + ".wav" plays fine, 'W') file. Write (buffer .getvalue ()) file.close () buffer.coz ()  


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -