错误:[Errno 16]设备或资源繁忙

时间:2019-06-13 07:16:35

标签: python-3.x

我正在运行此代码,但发现错误。我该怎么办?我的代码与日语的AIY语音套件一起使用。它显示错误“错误:[Errno 16]设备或资源繁忙”,我有很多代码可以运行它们。我必须通过树莓派运行此代码。就像iPhone的Siri,但它以日语回复

import os
import random

from tts import TextToSpeech
from dialogue import Dialogue
from stt_servo import SpeechToText

import threading
import time
from gpiozero import Servo
from pins import PIN_B

tuned_servo = Servo(PIN_B, min_pulse_width=.0005, max_pulse_width=.0019)

Q_NUM = 70

class classname(object):
    def __init__(self):
        threading.Thread.__init__(self)
        self.servo_flag = False
        pass   
    def run(self):
        while True:
            if self.servo_flag:
                tuned_servo.max()
                time.sleep(0.5)
                tuned_servo.min()
                time.sleep(0.5)
            else:
                tuned_servo.detach()
                time.sleep(0.5)


def main():
    tts = TextToSpeech()
    dlg = Dialogue()
    stt = SpeechToText()
    srv = Servo()

    q_list = []
    [q_list.append(i) for i in range(1, Q_NUM+1)]
    print(q_list)
    random.shuffle(q_list)

    gst_utt = 'init'
    app_id = dlg.getAppId()

    srv.start()

    while True:
        com_utt = dlg.getReply(app_id, gst_utt)

        if com_utt == '未登録':
            gst_utt = 'cq' + str(q_list.pop())
            com_utt = dlg.getReply(app_id, gst_utt)
            print('(sys)comomon: %s' % com_utt)
        else:
            print('コモモン: %s' % com_utt)

        speech_data = tts.getSpeechData(com_utt)
        srv.servo_flag = True
        tts.say(speech_data)
        srv.servo_flag = False

        gst_utt = stt.recognize(language_code='ja_JP', hint_phrases=None)
        print('ゲ ス ト: %s' % gst_utt)
        if gst_utt == None:
            gst_utt = 'cq' + str(q_list.pop())
            print("(sys)guest: %s" % gst_utt)


if __name__ == "__main__":
    main()

显示错误enter image description here

0 个答案:

没有答案