All pastes #834824 Raw Edit

Untitled

public python v1 · immutable
#834824 ·published 2007-12-28 14:22 UTC
rendered paste body
#!/usr/bin/pythonimport mad, ao, sysdef play(fileName):	mf = mad.MadFile(fileName)	dev = ao.AudioDevice('alsa',rate=mf.samplerate())	while 1:		buf = mf.read()		if buf is None:			break		dev.play(buf, len(buf))	def on_btnSpeak_clicked(self):		f=open("audio.mp3","wb")		f.write(self.dic.extractAudio(self._offset, self._length))		f.close()		if os.name == 'posix':			import audio_linux as audio		elif os.name == 'nt':			import audio_windows as audio		else:			print "Sorry. Audio isn't supported on this platform. :)"			return		audio.play("audio.mp3")