alexa-pi / AlexaPi

Alexa client for all your devices! # No active development. PRs welcome # consider https://github.com/respeaker/avs instead
MIT License
1.33k stars 396 forks source link

Raspberry PI 4B , Alexa says hello Ok, but No audio playback with status code 400 #489

Open IamHussain503 opened 4 years ago

IamHussain503 commented 4 years ago

Thank you for reporting an issue with AlexaPi.

Make sure you are running the latest version of AlexaPi, and look through issues before submitting.

Check out our Wiki, and make sure to look at Debugging, and Audio debugging in particular before filing an issue.

In order to help troubleshooting, be sure to include the following information:

Output of the audio debugging script.

!!################################ !!ALSA Information Script v 0.4.64 !!################################

!!Script ran on: Sat Mar 7 21:43:32 UTC 2020

!!Linux Distribution !!------------------

ID_LIKE=debian

!!DMI Information !!---------------

Manufacturer:
Product Name:
Product Version:
Firmware Version:

!!Kernel Information !!------------------

Kernel release: 4.19.97-v7l Operating System: GNU/Linux Architecture: armv7l Processor: unknown SMP Enabled: Yes

!!ALSA Version !!------------

Driver version: k4.19.97-v7l Library version: 1.1.8 Utilities version: 1.1.8

!!Loaded ALSA modules !!-------------------

snd_bcm2835 snd_usb_audio

!!Sound Servers on this system !!----------------------------

Pulseaudio: Installed - Yes (/usr/bin/pulseaudio) Running - Yes

Jack: Installed - Yes (/usr/bin/jackd) Running - No

!!Soundcards recognised by ALSA !!-----------------------------

0 [ALSA ]: bcm2835_alsa - bcm2835 ALSA bcm2835 ALSA 1 [Headset ]: USB-Audio - Logitech USB Headset Logitech Logitech USB Headset at usb-0000:01:00.0-1.1, full speed

!!PCI Soundcards installed in the system !!--------------------------------------

!!Advanced information - PCI Vendor/Device/Subsystem ID's !!-------------------------------------------------------

!!Modprobe options (Sound related) !!--------------------------------

snd_pcsp: index=-2 snd_usb_audio: index=-2 snd_atiixp_modem: index=-2 snd_intel8x0m: index=-2 snd_via82xx_modem: index=-2

!!Loaded sound module options !!---------------------------

!!Module: snd_bcm2835 enable_compat_alsa : Y enable_hdmi : N enable_headphones : N force_bulk : N

!!Module: snd_usb_audio autoclock : Y device_setup : 0,0,0,0,0,0,0,0 enable : Y,Y,Y,Y,Y,Y,Y,Y id : (null),(null),(null),(null),(null),(null),(null),(null) ignore_ctl_error : N index : -2,-1,-1,-1,-1,-1,-1,-1 pid : -1,-1,-1,-1,-1,-1,-1,-1 quirk_alias : (null),(null),(null),(null),(null),(null),(null),(null) use_vmalloc : Y vid : -1,-1,-1,-1,-1,-1,-1,-1

!!USB Mixer information !!--------------------- --startcollapse--

USB Mixer: usb_id=0x046d0a0b, ctrlif=0, ctlerr=0 Card: Logitech Logitech USB Headset at usb-0000:01:00.0-1.1, full speed Unit: 1 Control: name="Headphone Playback Volume", index=0 Info: id=1, control=2, cmask=0x3, channels=2, type="S16" Volume: min=-10496, max=768, dBmin=-4100, dBmax=300 Unit: 1 Control: name="Headphone Playback Switch", index=0 Info: id=1, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN" Volume: min=0, max=1, dBmin=0, dBmax=0 Unit: 2 Control: name="Mic Capture Volume", index=0 Info: id=2, control=2, cmask=0x0, channels=1, type="S16" Volume: min=4096, max=7424, dBmin=1600, dBmax=2900 Unit: 2 Control: name="Mic Capture Switch", index=0 Info: id=2, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN" Volume: min=0, max=1, dBmin=0, dBmax=0 Unit: 6 Control: name="Mic Playback Volume", index=0 Info: id=6, control=2, cmask=0x0, channels=1, type="S16" Volume: min=-10496, max=-3072, dBmin=-4100, dBmax=-1200 Unit: 6 Control: name="Mic Playback Switch", index=0 Info: id=6, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN" Volume: min=0, max=1, dBmin=0, dBmax=0 --endcollapse--

!!ALSA Device nodes !!-----------------

crw-rw---- 1 root audio 116, 0 Mar 7 16:26 /dev/snd/controlC0 crw-rw---- 1 root audio 116, 32 Mar 7 16:30 /dev/snd/controlC1 crw-rw---- 1 root audio 116, 16 Mar 7 16:26 /dev/snd/pcmC0D0p crw-rw---- 1 root audio 116, 17 Mar 7 16:26 /dev/snd/pcmC0D1p crw-rw---- 1 root audio 116, 18 Mar 7 16:26 /dev/snd/pcmC0D2p crw-rw---- 1 root audio 116, 56 Mar 7 16:30 /dev/snd/pcmC1D0c crw-rw---- 1 root audio 116, 48 Mar 7 21:37 /dev/snd/pcmC1D0p crw-rw---- 1 root audio 116, 1 Mar 7 16:26 /dev/snd/seq crw-rw---- 1 root audio 116, 33 Mar 7 16:26 /dev/snd/timer

/dev/snd/by-id: total 0 drwxr-xr-x 2 root root 60 Mar 7 16:30 . drwxr-xr-x 4 root root 260 Mar 7 16:30 .. lrwxrwxrwx 1 root root 12 Mar 7 16:30 usb-Logitech_Logitech_USB_Headset-00 -> ../controlC1

/dev/snd/by-path: total 0 drwxr-xr-x 2 root root 80 Mar 7 16:30 . drwxr-xr-x 4 root root 260 Mar 7 16:30 .. lrwxrwxrwx 1 root root 12 Mar 7 16:30 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0 -> ../controlC1 lrwxrwxrwx 1 root root 12 Mar 7 16:26 platform-soc:audio -> ../controlC0

!!Aplay/Arecord output !!--------------------

APLAY

List of PLAYBACK Hardware Devices card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA] Subdevices: 7/7 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0

ARECORD

List of CAPTURE Hardware Devices card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0

!!Amixer output !!-------------

!!-------Mixer controls for card 0 [ALSA]

Card hw:0 'ALSA'/'bcm2835 ALSA' Mixer name : 'Broadcom Mixer' Components : '' Controls : 5 Simple ctrls : 1 Simple mixer control 'PCM',0 Capabilities: pvolume pvolume-joined pswitch pswitch-joined Playback channels: Mono Limits: Playback -10239 - 400 Mono: Playback -10239 [0%] [-99999.99dB] [on]

!!-------Mixer controls for card 1 [Headset]

Card hw:1 'Headset'/'Logitech Logitech USB Headset at usb-0000:01:00.0-1.1, full speed' Mixer name : 'USB Mixer' Components : 'USB046d:0a0b' Controls : 9 Simple ctrls : 2 Simple mixer control 'Headphone',0 Capabilities: pvolume pswitch pswitch-joined Playback channels: Front Left - Front Right Limits: Playback 0 - 44 Mono: Front Left: Playback 43 [98%] [2.00dB] [on] Front Right: Playback 43 [98%] [2.00dB] [on] Simple mixer control 'Mic',0 Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined Playback channels: Mono Capture channels: Mono Limits: Playback 0 - 29 Capture 0 - 13 Mono: Playback 0 [0%] [-41.00dB] [off] Capture 13 [100%] [29.00dB] [on]

!!Alsactl output !!--------------

--startcollapse-- state.ALSA { control.1 { iface MIXER name 'PCM Playback Volume' value -10239 comment { access 'read write' type INTEGER count 1 range '-10239 - 400' dbmin -9999999 dbmax 400 dbvalue.0 -9999999 } } control.2 { iface MIXER name 'PCM Playback Switch' value true comment { access 'read write' type BOOLEAN count 1 } } control.3 { iface MIXER name 'PCM Playback Route' value 0 comment { access 'read write' type INTEGER count 1 range '0 - 3' } } control.4 { iface PCM name 'IEC958 Playback Default' value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' comment { access 'read write' type IEC958 count 1 } } control.5 { iface PCM name 'IEC958 Playback Con Mask' value '0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' comment { access read type IEC958 count 1 } } } state.Headset { control.1 { iface PCM name 'Playback Channel Map' value.0 0 value.1 0 comment { access read type INTEGER count 2 range '0 - 36' } } control.2 { iface PCM name 'Capture Channel Map' value 2 comment { access read type INTEGER count 1 range '0 - 36' } } control.3 { iface MIXER name 'Mic Playback Switch' value false comment { access 'read write' type BOOLEAN count 1 } } control.4 { iface MIXER name 'Mic Playback Volume' value 0 comment { access 'read write' type INTEGER count 1 range '0 - 29' dbmin -4100 dbmax -1200 dbvalue.0 -4100 } } control.5 { iface MIXER name 'Headphone Playback Switch' value true comment { access 'read write' type BOOLEAN count 1 } } control.6 { iface MIXER name 'Headphone Playback Volume' value.0 43 value.1 43 comment { access 'read write' type INTEGER count 2 range '0 - 44' dbmin -4100 dbmax 300 dbvalue.0 200 dbvalue.1 200 } } control.7 { iface MIXER name 'Mic Capture Switch' value true comment { access 'read write' type BOOLEAN count 1 } } control.8 { iface MIXER name 'Mic Capture Volume' value 13 comment { access 'read write' type INTEGER count 1 range '0 - 13' dbmin 1600 dbmax 2900 dbvalue.0 2900 } } control.9 { iface CARD name 'Keep Interface' value false comment { access 'read write' type BOOLEAN count 1 } } } --endcollapse--

!!All Loaded Modules !!------------------

Module nfnetlink_queue nfnetlink_log nfnetlink rfcomm bnep hci_uart btbcm serdev bluetooth ecdh_generic fuse 8021q garp stp llc evdev brcmfmac brcmutil vc4 sha256_generic drm_kms_helper cfg80211 rfkill snd_soc_core raspberrypi_hwmon hwmon snd_compress snd_pcm_dmaengine syscopyarea sysfillrect snd_usb_audio sysimgblt fb_sys_fops snd_hwdep i2c_bcm2835 snd_usbmidi_lib snd_rawmidi snd_seq_device v3d gpu_sched bcm2835_codec bcm2835_v4l2 v4l2_mem2mem bcm2835_mmal_vchiq v4l2_common videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common drm videodev drm_panel_orientation_quirks media ir_rc6_decoder rpivid_mem vc_sm_cma uio_pdrv_genirq gpio_ir_tx gpio_ir_recv uio i2c_dev snd_bcm2835 snd_pcm snd_timer snd ip_tables x_tables ipv6

!!ALSA/HDA dmesg !!--------------

[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 1011008 [ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 cma=64M cma=256M video=HDMI-A-1:720x576M@50,margin_left=32,margin_right=32,margin_top=32,margin_bottom=32 smsc95xx.macaddr=DC:A6:32:74:36:35 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 console=tty1 root=PARTUUID=5e3da3da-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles [ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)

[ 2.104563] systemd[1]: Mounting POSIX Message Queue File System... [ 2.255459] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned. [ 2.261926] bcm2835_audio soc:audio: card created with 8 channels

[ 3.715314] [drm] Initialized v3d 1.0.0 20180419 for fec00000.v3d on minor 0 [ 4.074989] usbcore: registered new interface driver snd-usb-audio [ 4.167435] cfg80211: Loading compiled-in X.509 certificates for regulatory database

Your OS (including version) where you are running AlexaPi: Note: Raspbian older than Stretch is not supported!

Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

Your hardware platform and model you are running on:

Raspberry Pi4B

Python release (python3 --version):

Python 3.7.3

Description of problem:

Alexa  can hello and it can also say  'yes' , but  either does not listen to my question or my PI can not decode the message with a status code 400

Expected:

Alexa should answer my question

Problem-relevant config.yaml entries:

# See https://github.com/alexa-pi/AlexaPi/wiki/Audio-setup-&-debugging
# to get a better idea of how to set things in here

# Level of log output
# default: INFO
# set to DEBUG for verbose logging
logging: INFO

sound:
  # Name of your microphone device: "raspberrypi"
  # leave empty for default
  input_device: ""

  playback_handler: "vlc"

  # you can go here with alsa, pulse or others
  # keep blank for the best audio output selected by the underlying code
  output: "alsa"
  # output device: "raspberrypi"
  # currently supports ALSA only
  output_device: "default"

  # if left empty, won't be passed to the underlying library / command if it supports it
  # if it doesn't 100% will be used
  default_volume: 80

  # Means the same as above, but is used for media (playing music for example)
  # Leave blank to use the same setting as for speech content
  media_output:
  media_output_device:
  media_default_volume:

  # Some device: "raspberrypi"
  # value is the number of seconds of silence to pad the beginning and end of the audio. Only
  # the sox handler supports this configuration option.
  playback_padding: 0

# Amazon Alexa settings
alexa:

# See https://github.com/alexa-pi/AlexaPi/wiki/Triggers for the description of these options
triggers:
  platform:
    enabled: true
    voice_confirm: false

    # one of: oneshot-vad, continuous, continuous-vad
    event_type: "oneshot-vad"

    # only for "continuous" event_types
    long_press:
      # system command to run after pressing the button for _duration_ number of seconds
      # empty to disable
      command: ""

      # duration in seconds
      duration: 10

      # CURRENTLY DISABLED
      # optional audio file to play before executing the command
      # you might wanna use full path to make sure AlexaPi finds it
      # you can use {resources_path} for the path to the AlexaPi "resources" directory
      audio_file: ""

  pocketsphinx:
    enabled: true
    voice_confirm: true

    phrase: "alexa"
    threshold: 1e-10

  snowboy:
    enabled: false
    voice_confirm: true

    # Use your own model or a file from the default snowboy distribution:
    #
    # {distribution}/alexa.umdl
    # {distribution}/snowboy.umdl
    # {distribution}/alexa/alexa_02092017.umdl
    # {distribution}/alexa/alexa-avs-sample-app/alexa.umdl

    model: "{distribution}/alexa/alexa_02092017.umdl"
    sensitivity: 0.5

# Commands to run before and after an interaction begins. Leave empty to disable.
event_commands:

  # Example used to lower shairport-sync volume during interaction with alexa
  #     startup: "amixer set shairportvolume 100%"
  #     pre_interaction: "amixer set shairportvolume 10%-""
  #     post_interaction: "amixer set shairportvolume 10%+""
  # Note this assumes you have redirected shairport-syncs audio to a seperate softdevice
  # with control "shairportvolume". Example asound.conf avalible in the scripts folder

  # Command to run at the start of AlexaPi
  startup: ""

  # Command to run after a trigger is detected but before an interaction begins
  pre_interaction: ""

  # Command to run after the interaction has completed
  post_interaction: ""

  # Command to run during a clean shutdown of AlexaPi
  shutdown: ""

platform:
  # Name of your platform, e.g. raspberrypi, orangepi, desktop
  device: "raspberrypi"

platforms:
  # common config for all platforms (if they support the options)
  # can be overriden in the the respective platform sections
  common:

  chip:
    # GPIO Pin with button connected
    button: XIO-P1
    # GPIO Pin for the playback/activity light
    plb_light: XIO-P3
    # GPIO Pin for the recording light
    rec_light: XIO-P5

  raspberrypi:
    # GPIO Pin with button connected
    button: 18
    # GPIO Pin for the playback/activity light
    plb_light: 24
    # GPIO Pin for the recording light
    rec_light: 25

  orangepi:
    # GPIO Pin with button connected
    button: 20
    # GPIO Pin for the playback/activity light
    plb_light: 9
    # GPIO Pin for the recording light
    rec_light: 8

  desktop:
    min_seconds_to_record: 3

  dummy:

  magicmirror:
    # Magic Mirror - github.com/MichMich/MagicMirror
    # Integrates with MMM-AlexaPi module (github.com/dgonano/MMM-AlexaPi) to display listening, playback, etc status
    # Hostname of the AlexaPi HTTP server, leave empty for any name
    hostname: ""
    # Port the ALexaPi HTTTP server binds to
    port: 5055
    # Hostname of the Magic Mirror
    mm_hostname: "localhost"
    # Port of the Magic Mirror
    mm_port: "8080"
    # How ofter the Hearbeat fires in seconds
    hb_timer: 5

  hyperion:
    # Hostname of the Hyperion node's JSON server
    hyperion_json_host: "127.0.0.1"
    # Port of the Hyperion node's JSON server
    hyperion_json_port: 19444
    # Visual status as static 'color' or 'effect'
    # Overridden by 'hyperion_flash_state_xxx'
    hyperion_mode: "effect"
    # Running speed when visualizing as 'effect'
    hyperion_effect_speed: 1
    hyperion_priority: 1
    color_playback: [80, 213, 35]
    color_processing: [35,169,213]
    color_recording: [168, 35, 213]
    flash_duration: 500
    flash_frequency: 8
    # Use Strobe effect instead of default effect or static color
    flash_state_playback: true
    flash_state_processing: false
    flash_state_recording: false
    # Visualize playback state
    indicate_playback: true
    #Also print json request/response when in debug mode
    verbose: false

  serial:
    port: "/dev/ttyACM0"
    baudrate: 9600
    messages:
      trigger: ""
      playback_start: "g"
      playback_end: "x"
      recording_start: ""
      recording_end: ""
      processing_start: ""
      processing_end: ""
      failure: ""
      success: ""

Steps to reproduce:

Traceback (if applicable):

Additional info:

# /opt/AlexaPi/src/main.py -d

2020-03-07 21:06:00 INFO: Triggered: pocketsphinx
2020-03-07 21:06:00 DEBUG: Stopping audio play
2020-03-07 21:06:00 DEBUG: Playing audio: /opt/AlexaPi/src/resources/alexayes.mp3
2020-03-07 21:06:00 DEBUG: Player State: State.Opening
2020-03-07 21:06:00 DEBUG: Player State: State.Playing
2020-03-07 21:06:00 DEBUG: Started play. 
2020-03-07 21:06:00 DEBUG: Player State: State.Ended
2020-03-07 21:06:00 DEBUG: Finished play. 
2020-03-07 21:06:00 DEBUG: Recording: Setting up
2020-03-07 21:06:00 DEBUG: Recording: Start
2020-03-07 21:06:00 DEBUG: Starting new HTTPS connection (1): access-alexa-na.amazon.com:443
2020-03-07 21:06:02 DEBUG: Start sending speech to Alexa Voice Service
2020-03-07 21:06:08 DEBUG: Recording: End
2020-03-07 21:06:08 DEBUG: Finished sending speech to Alexa Voice Service
2020-03-07 21:06:09 DEBUG: Processing Request Response...
2020-03-07 21:06:09 INFO: (process_response Error) Status Code: 400
IamHussain503 commented 4 years ago

I printed the response and looks like this, anybody can help on this ?

2020-03-08 09:24:22 INFO: Checking Internet Connection ... 2020-03-08 09:24:24 INFO: Connection OK 2020-03-08 09:24:24 INFO: AVS token: Requesting a new one 2020-03-08 09:24:25 INFO: AVS token: Obtained successfully 2020-03-08 09:24:31 INFO: Triggered: pocketsphinx {'error': {'code': 'com.amazon.alexahttpproxy.exceptions.BadRequestException', 'message': 'No audio stream found in the multipart payload.'}} 2020-03-08 09:24:40 INFO: (process_response Error) Status Code: 400