从gpio事件返回

时间:2015-05-01 11:40:19

标签: python return return-value gpio

最后,我能够使用gpio.add_event_detect的程序修复this,但是当我获得音频文件时,我需要将其发送到其他函数并获取该函数返回的文本。这是我的剧本

while auto_recognition==False:
    import RPi.GPIO as gpio
    from manual_recorder import Recorder
    gpio.setmode(gpio.BCM)

    gpio.setup(4, gpio.IN, pull_up_down=gpio.PUD_UP)

    def rising(channel):
        global recfile
        gpio.remove_event_detect(4)
        print 'Button up'
        gpio.add_event_detect(4, gpio.FALLING, callback=falling, bouncetime=10)
        recfile.stop_recording()
        recfile.close()
        print stt.stt_google_wav(filename, profile.language)

    def falling(channel):
        global recfile
        gpio.remove_event_detect(4)
        print 'Button down'
        gpio.add_event_detect(4, gpio.RISING, callback=rising, bouncetime=10)
        rec = Recorder(channels=1)
        recfile = rec.open(filename, 'wb') 
        recfile.start_recording()

    filename='output_'+str(int(time.time()))+'.wav'
    gpio.add_event_detect(4, gpio.FALLING, callback=falling, bouncetime=10)

    gpio.cleanup()

我需要上升才能返回最后一行,现在打印的是什么。我尝试了return stt.stt_google_wav(filename, profile.language)然后print gpio.add_event_detect(4, gpio.FALLING, callback=falling, bouncetime=10),但它不起作用。我该怎么办?

0 个答案:

没有答案