Hi all I can not creat a usable audio file in the aiff format. The example code below creates a wav file that I can listen to just fine. However, I just get noise when I listen to the resulting aiff file. Is this a byte order problem? I am using Python 2.5.2 on Windows XP. Any guidance on this issue would be appreciated.
Thanks jym import pyaudio import wave import sys import aifc chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 8000 RECORD_SECONDS = 5 WAVE_OUTPUT_FILENAME = "output" p = pyaudio.PyAudio() stream = p.open(format = FORMAT, channels = CHANNELS, rate = RATE, input = True, frames_per_buffer = chunk) print "* recording" all = [] for i in range(0, RATE / chunk * RECORD_SECONDS): data = stream.read(chunk) all.append(data) print "* done recording" stream.close() p.terminate() #write data to AIFF file data = ''.join(all) af = aifc.open(WAVE_OUTPUT_FILENAME + ".aiff", 'wb') af.setnchannels(CHANNELS) af.setsampwidth(p.get_sample_size(FORMAT)) af.setframerate(RATE) af.writeframes(data) af.close() # write data to WAVE file wf = wave.open(WAVE_OUTPUT_FILENAME + ".wav", 'wb') wf.setnchannels(CHANNELS) wf.setsampwidth(p.get_sample_size(FORMAT)) wf.setframerate(RATE) wf.writeframes(data) wf.close()
-- http://mail.python.org/mailman/listinfo/python-list