Гугл помощник Picamera командный цикл - PullRequest
0 голосов
/ 11 марта 2019
"""A demo of the Google CloudSpeech recognizer."""
import argparse
import locale
import logging
import picamera
import time

from aiy.board import Board, Led
from aiy.cloudspeech import CloudSpeechClient


def get_hints(language_code):
    if language_code.startswith('en_'):
        return ('turn on the light',
                'turn off the light',
                'blink the light',
                'goodbye')
    return None

def locale_language():
    language, _ = locale.getdefaultlocale()
    return language

def main():
    logging.basicConfig(level=logging.DEBUG)

    parser = argparse.ArgumentParser(description='Assistant service 
 example.')
    parser.add_argument('--language', default=locale_language())
    args = parser.parse_args()

    logging.info('Initializing for language %s...', args.language)
    hints = get_hints(args.language)
    client = CloudSpeechClient()
    with Board() as board:
        while True:
            if hints:
                logging.info('Say something, e.g. %s.' % ', '.join(hints))
            else:
                logging.info('Say something.')
            text = client.recognize(language_code=args.language,
                                hint_phrases=hints)
            if text is None:
                logging.info('You said nothing.')
                continue

            logging.info('You said: "%s"' % text)
            text = text.lower()
            if '불 켜' in text:
            board.led.state = Led.ON

            elif '불 꺼' in text:
                camera = picamera.PiCamera()
                camera.start_preview()
                time.sleep(5)
                camera.capture('/home/pi/cam.jpg')
                camera.stop_preview()

            elif '반짝반짝' in text:
                board.led.state = Led.BLINK
            elif 'goodbye' in text:
                break

if __name__ == '__main__':
    main()

Это мой исходный код.

но этот код выдает ошибку:

mmal: mmal_vc_port_enable: не удалось включить порт vc.null_sink: in: 0 (OPQV): ENOSPC mmal: mmal_port_enable: не удалось включить подключенный порт (vc.null_sink: in: 0 (OPQV)) 0x1424860 (ENOSPC) mmal: mmal_connection_enable: выходной порт не может быть включен Трассировка (последний вызов был последним): файл 78, в main () Файл "cloudspeech_demo.py", строка 66, в основном camera = picamera.PiCamera () Файл "/usr/lib/python3/dist-packages/picamera/camera.py", строка 433, в INIT Файл self._init_preview () "/usr/lib/python3/dist-packages/picamera/camera.py", строка 513, в _init_preview self, self._camera.outputs [self.CAMERA_PREVIEW_PORT]) Файл "/usr/lib/python3/dist-packages/picamera/renderers.py", строка 558, в 1010 * INIT * self.renderer.inputs [0] .connect (source) .enable () Файл "/usr/lib/python3/dist-packages/picamera/mmalobj.py", строка 2212, в
enable prefix = "Не удалось включить соединение") Файл "/usr/lib/python3/dist-packages/picamera/exc.py", строка 184, в mmal_check поднять PiCameraMMALError (status, prefix) picamera.exc.PiCameraMMALError: Не удалось включить соединение: Нет ресурсы

Я хочу сделать повторение команд, но что мне делать?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...