Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Making recordings with OpenSesame, the first 500ms is blank

Hi all,

I tried to make recordings in OpenSesame. I display word on the screen, start the recording, end recording until key press, and head to the next word. I find that I am able to make recordings, but the first 500ms of all sound files is blank.

Can anyone help? That 500ms is really important to me. Thank you so much!

In what follows is the code I use.

----------------------

recording_path = 'C:\\Users\\Jia\\Desktop\\recording\\'

chunk=1024

FORMAT = pyaudio.paInt16

CHANNELS=1

RATE=44100


WAVE_OUTPUT_FILENAME= "%d_%d.wav" % (self.get('subject_nr'), var.item_num)


p = pyaudio.PyAudio()


stream = p.open(format=FORMAT,

channels = CHANNELS,

rate = RATE,

input = True,

frames_per_buffer = chunk)

print "* record until keypress"

my_keyboard = keyboard(exp,timeout=2)

all = []


while my_keyboard.get_key()[0]==None:

data = stream.read(chunk)

all.append(data)

print "* done recording"


stream.close()

p.terminate()


# write data to WAVE file

data = ''.join(all)

wf = wave.open(recording_path+WAVE_OUTPUT_FILENAME, 'wb')

wf.setnchannels(CHANNELS)

wf.setsampwidth(p.get_sample_size(FORMAT))

wf.setframerate(RATE)

wf.writeframes(data)

wf.close()

Comments

Sign In or Register to comment.