Exemplo n.º 1
0
def main():
    init()
    parseArgs()
    audio.initAudio(audio.getDeviceIndexByName(micName))
    highlight(None)  # jump to first word
    threshold = 900
    recording = 0
    while True:
        canvas.update()
        try:
            data = audio.getChunk()
        except IOError:
            quit(None)
        L = unpack("<" + ("h" * (len(data) / 2)), data)
        L = array("h", L)
        # print max(L)
        if max(L) > threshold:
            if not recording:
                recording = 40
                all = list()
            all.append(data)
        elif recording:
            recording -= 1
            if not recording:
                fn = os.path.join(recordDir, "%d.%03d.wav" % (p, w - 1))
                if os.path.exists(fn):
                    all = list()
                else:
                    audio.saveToFile("".join(all), fn)
                    audio.restream()
                    highlight(None)
    root.mainloop()
Exemplo n.º 2
0
def init(voice='katie'):
    global recordDir
    audio.initAudio()
    recordDir = path.join(path.dirname(__file__), 'recordings')
    recordDir = path.join(recordDir, voice)