def getAudio(parent, encode=True):
 r = Recorder()
 mb = QMessageBox(parent)
 restoreGeom(mb, 'audioRecorder')
 mb.setWindowTitle('Anki')
 mb.setIconPixmap(QPixmap(':/icons/media-record.png'))
 but = QPushButton(_('  Stop'))
 but.setIcon(QIcon(':/icons/media-playback-stop.png'))
 mb.addButton(but, QMessageBox.RejectRole)
 t = time.time()
 r.start()
 QApplication.instance().processEvents()
 while (not mb.clickedButton()):
  txt = _('Recording...<br>Time: %0.1f')
  mb.setText((txt % (time.time() - t)))
  mb.show()
  QApplication.instance().processEvents()
 saveGeom(mb, 'audioRecorder')
 while ((time.time() - t) < 1):
  time.sleep(0.1)
 r.stop()
 r.postprocess(encode)
 return r.file()

def getAudio ( parent , encode = True ) : r = Recorder ( ) mb = QMessageBox ( parent ) restoreGeom ( mb , 'audioRecorder' ) mb . setWindowTitle ( 'Anki' ) mb . setIconPixmap ( QPixmap ( ':/icons/media-record.png' ) ) but = QPushButton ( _ ( '  Stop' ) ) but . setIcon ( QIcon ( ':/icons/media-playback-stop.png' ) ) mb . addButton ( but , QMessageBox . RejectRole ) t = time . time ( ) r . start ( ) QApplication . instance ( ) . processEvents ( ) while ( not mb . clickedButton ( ) ) : txt = _ ( 'Recording...<br>Time: %0.1f' ) mb . setText ( ( txt % ( time . time ( ) - t ) ) ) mb . show ( ) QApplication . instance ( ) . processEvents ( ) saveGeom ( mb , 'audioRecorder' ) while ( ( time . time ( ) - t ) < 1 ) : time . sleep ( 0.1 ) r . stop ( ) r . postprocess ( encode ) return r . file ( )
record and return filename .