alexa-pi / AlexaPiDEPRECATED

DEPRECATED - Use https://github.com/alexa-pi/AlexaPi instead ...Turn a Raspberry Pi into an Alexa Client
https://github.com/alexa-pi/AlexaPi
MIT License
587 stars 442 forks source link

After Alexa starts, alsaaudio.ALSAAudioError: Input/output error #133

Closed sikkz closed 7 years ago

sikkz commented 7 years ago

Hello, I receive the "Hello" from Alexa and the green LED flashes 3 times. But after pushing (and holding) the button, I only receive this output:

Checking Internet Connection Connection OK Traceback (most recent call last): File "main.py", line 156, in start() File "main.py", line 130, in start l, data = inp.read() alsaaudio.ALSAAudioError: Input/output error

I googled the error, and checked the Issues page here, but can't find a solution. I am using a Raspberry Pi 3 and a Webcam with integrated microphone. If anybody has a solution, please try to explain it well, because I am just starting to learn programming.

Thanks for your help in advance!

YOUN3SS commented 7 years ago

You are not calling correctly the microphone, check the solution here it may work for you: https://github.com/sammachin/AlexaPi/issues/135

sikkz commented 7 years ago

First, thank you for your reply! I ran the arecord -L command. Because of the results, I changed: "plughw:1 to plughw:Camera=Device,DEV=0" But still I only receive the "hello" and three green flashes. When I press the button, say something, and release it, nothing happens. After 5secs or something, the main.py closes itself.

The alexa.log file says:

Starting Alexa...
pysthon can't open file '/root/AlexaPi/main.py': [Errno 2] No such file or directory

EDIT: I googled this error, and changed the directory in the initd_alexa.sh file from "/root/AlexaPi/" to "/home/pi/Downlaods/AlexaPi/main.py"

Still doesn't work. May I have to change the directory in another file? Or should I move the whole AlexaPi folder from downloads to root? If yes, how can I move it? Sorry if this post is kinda unorganised, I am actually trying to solve the problem, and am updating this post everytime I get another hint.

Heres the arecord -L output:

pi@raspberrypi:~/Downloads/AlexaPi $ arecord -L                                 null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=Camera
    USB Video Camera, USB Audio
    Default Audio Device
front:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    Front speakers
surround21:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    Direct sample mixing device
dsnoop:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    Direct sample snooping device
hw:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Camera,DEV=0
    USB Video Camera, USB Audio
    Hardware device with all software conversions

And heres the main.py's content:

#! /usr/bin/env python

import os
import random
import time
import RPi.GPIO as GPIO
import alsaaudio
import wave
import random
from creds import *
import requests
import json
import re
from memcache import Client

#Settings
button = 18 #GPIO Pin with button connected
lights = [24, 25] # GPIO Pins with LED's conneted
device = "plughw:CARD=Camera,DEV=0" # Name of your microphone/soundcard in arec$

#Setup
recorded = False
servers = ["127.0.0.1:11211"]
mc = Client(servers, debug=1)
path = os.path.realpath(__file__).rstrip(os.path.basename(__file__))

def internet_on():
    print "Checking Internet Connection"
    try:
        r =requests.get('https://api.amazon.com/auth/o2/token')
        print "Connection OK"
        return True
    except:
        print "Connection Failed"
        return False

def gettoken():
        token = mc.get("access_token")
        refresh = refresh_token
        if token:
                return token
        elif refresh:
renekliment commented 7 years ago

Can you try the new upstream (https://github.com/alexa-pi/AlexaPi)? The installation over there is more robust and it might be therefore easier to get it to work. Just follow the installation guide. Thanks!

renekliment commented 7 years ago

This project is now deprecated in favor of the new AlexaPi (https://github.com/alexa-pi/AlexaPi) which has all the features of this project and much more, such as:

Please switch over to the new project and if your issue persists there, file an issue in the new repo's issue tracker. Thank you.