respeaker / avs

python implementation of alexa voice service app, 支持DuerOS
Other
197 stars 63 forks source link

Alexa radio/music/songs not working #7

Closed ThePinkPanda closed 6 years ago

ThePinkPanda commented 7 years ago

Description

After installing and configuring Amazon Alexa on the Respeaker Core I was unable to listen (for example) to a tunein radio station or commands like 'sing happy birthday, sing a song, etc.' are not working. Every time I ask something, she just thinks and doesn't respond. I really want to add the functions of music and songs, because this will make a better Alexa experience.

What I Did

I (kind of) successfully installed alexa on the Respeaker core using all the instructions from here (https://github.com/respeaker/Alexa). She is responding on almost all my questions, but not playing music.

I need to say that almost everytime is start up alexa from the online terminal (command: 'alexa') I get an error of no open channels or something, but got that fixed by running the commands in this order: /etc/init.d/alexa start // wait two seconds /etc/init.d/alexa stop // wait two seconds alexa // wait about 20 seconds and then i got output

Sometimes I use the /etc/init.d/mopidy stop if the commands above does not work and after the command I try the commands above again.

What doesn't work

Every time I say 'Alexa, sing a bithday song', I get this output:

Jk3Lw~rvQV8ApshSZu0fzlmB-ea-sBqTobFoOdzQ6ZHfceyFTiFZA__&Key-Pair-Id=APKAJMAIYIGWWT37OIHA",
                "offsetInMilliseconds": 0,
                "expiryTime": "2017-10-29T00:47:58+0000",
                "streamId": "amzn1.as-ct.v1.Domain:Phatic:AlexaOriginals#ACRI#url#ACRI#AlexaOriginals|8d67dfad-a6c9-4cf4-a6a9-ac2bb68b50f9|https://dvi
8md6049w6b.cloudfront.net/nina_v1_492be71da6e3d76e9270__en_us_happy_birthday_tts_128kb.mp3?Expires=1509238078&Signature=OAMeCHyl8IkBeEYfDcNMCQKvXHzK2y
qvBW6wjqrY3d879pyAMsh6yeqqj4c-Y6e4rH1xzR~HbfRsZhOEJ5aQixi9dHWd4MfY1nAmpDDW5ZvIjh1Fs3RuXzm60k2HMT8Xlzgrz1VLvQsMj2Hn0KCIbgQdDnNYNiwaRLynvj0dS9imisGwDbNN
oMKsi9JYb2hlv4Ypq7jXLYuRviIx-VdmYx0jSwXYs35P6GL8qh4RiUQ5qdvPomqxFlDyoriujWyMcY8NbQY7QQBK6ac6mfowDN0opQ4ONnOFVJk3Lw~rvQV8ApshSZu0fzlmB-ea-sBqTobFoOdzQ6
ZHfceyFTiFZA__&Key-Pair-Id=APKAJMAIYIGWWT37OIHA|Happy Birthday To You!|1509209278710|ATVPDKIKX0DER|A2HA14VFFC1ULC|en_US|Alexa3P:1.0/2017/10/28/16/5e31
fde911ad444cace637eb16d3e959/47:56::TNIH_2V.456bcac9-1425-4d6e-81ad-bd945057a3a4ZXV/0|5db373ac-d81d-442c-9c2f-cd9b2f38d408|PhaticIntent",
                "progressReportRequired": false
              }
            ],
            "audioItemId": "amzn1.as-ct.v1.Domain:Phatic:AlexaOriginals#ACRI#url#ACRI#AlexaOriginals|8d67dfad-a6c9-4cf4-a6a9-ac2bb68b50f9|https://dvi8
md6049w6b.cloudfront.net/nina_v1_492be71da6e3d76e9270__en_us_happy_birthday_tts_128kb.mp3?Expires=1509238078&Signature=OAMeCHyl8IkBeEYfDcNMCQKvXHzK2yq
vBW6wjqrY3d879pyAMsh6yeqqj4c-Y6e4rH1xzR~HbfRsZhOEJ5aQixi9dHWd4MfY1nAmpDDW5ZvIjh1Fs3RuXzm60k2HMT8Xlzgrz1VLvQsMj2Hn0KCIbgQdDnNYNiwaRLynvj0dS9imisGwDbNNo
MKsi9JYb2hlv4Ypq7jXLYuRviIx-VdmYx0jSwXYs35P6GL8qh4RiUQ5qdvPomqxFlDyoriujWyMcY8NbQY7QQBK6ac6mfowDN0opQ4ONnOFVJk3Lw~rvQV8ApshSZu0fzlmB-ea-sBqTobFoOdzQ6Z
HfceyFTiFZA__&Key-Pair-Id=APKAJMAIYIGWWT37OIHA|Happy Birthday To You!|1509209278710|ATVPDKIKX0DER|A2HA14VFFC1ULC|en_US|Alexa3P:1.0/2017/10/28/16/5e31f
de911ad444cace637eb16d3e959/47:56::TNIH_2V.456bcac9-1425-4d6e-81ad-bd945057a3a4ZXV/0|5db373ac-d81d-442c-9c2f-cd9b2f38d408|PhaticIntent"
          },
          "navigationToken": "amzn1.as-ct.v1.Domain:Phatic:AlexaOriginals#ACRI#url#ACRI#AlexaOriginals|8d67dfad-a6c9-4cf4-a6a9-ac2bb68b50f9|https://dv
i8md6049w6b.cloudfront.net/nina_v1_492be71da6e3d76e9270__en_us_happy_birthday_tts_128kb.mp3?Expires=1509238078&Signature=OAMeCHyl8IkBeEYfDcNMCQKvXHzK2
yqvBW6wjqrY3d879pyAMsh6yeqqj4c-Y6e4rH1xzR~HbfRsZhOEJ5aQixi9dHWd4MfY1nAmpDDW5ZvIjh1Fs3RuXzm60k2HMT8Xlzgrz1VLvQsMj2Hn0KCIbgQdDnNYNiwaRLynvj0dS9imisGwDbN
NoMKsi9JYb2hlv4Ypq7jXLYuRviIx-VdmYx0jSwXYs35P6GL8qh4RiUQ5qdvPomqxFlDyoriujWyMcY8NbQY7QQBK6ac6mfowDN0opQ4ONnOFVJk3Lw~rvQV8ApshSZu0fzlmB-ea-sBqTobFoOdzQ
6ZHfceyFTiFZA__&Key-Pair-Id=APKAJMAIYIGWWT37OIHA|Happy Birthday To You!|1509209278710|ATVPDKIKX0DER|A2HA14VFFC1ULC|en_US|Alexa3P:1.0/2017/10/28/16/5e3
1fde911ad444cace637eb16d3e959/47:56::TNIH_2V.456bcac9-1425-4d6e-81ad-bd945057a3a4ZXV/0|5db373ac-d81d-442c-9c2f-cd9b2f38d408|PhaticIntent"
        }
      }
    ]
  },
  "messageHeader": {}
}
DEBUG:/usr/bin/alexa:AudioPlayer audio:https://dvi8md6049w6b.cloudfront.net/nina_v1_492be71da6e3d76e9270__en_us_happy_birthday_tts_128kb.mp3?Expires=1
509238078&Signature=OAMeCHyl8IkBeEYfDcNMCQKvXHzK2yqvBW6wjqrY3d879pyAMsh6yeqqj4c-Y6e4rH1xzR~HbfRsZhOEJ5aQixi9dHWd4MfY1nAmpDDW5ZvIjh1Fs3RuXzm60k2HMT8Xlz
grz1VLvQsMj2Hn0KCIbgQdDnNYNiwaRLynvj0dS9imisGwDbNNoMKsi9JYb2hlv4Ypq7jXLYuRviIx-VdmYx0jSwXYs35P6GL8qh4RiUQ5qdvPomqxFlDyoriujWyMcY8NbQY7QQBK6ac6mfowDN0o
pQ4ONnOFVJk3Lw~rvQV8ApshSZu0fzlmB-ea-sBqTobFoOdzQ6ZHfceyFTiFZA__&Key-Pair-Id=APKAJMAIYIGWWT37OIHA

The strange thing about this is that it includes the path to the audio file (audio:https:://dvi8......), but it just don't plays the sound and when I try: 'Alexa, play BBC Radio 6 Music', I get this output:

              "logo": {
                "sources": [
                  {
                    "url": "https://s3.amazonaws.com/music-provider-logos/TuneIn.svg"
                  }
                ]
              },
              "name": "TuneIn Live Radio"
            },
            "mediaLengthInMilliseconds": 0
          },
          "controls": [
            {
              "type": "BUTTON",
              "selected": false,
              "enabled": true,
              "name": "PLAY_PAUSE"
            }
          ],
          "audioItemId": "amzn1.as-ct.v1.Dee-Domain-Music#ACRI#url#ACRI#80ddf91b-7d64-4df5-bf6c-8389dfb6747a:1"
        }
      }
    ]
  },
  "messageHeader": {}
}
DEBUG:/usr/bin/alexa:Play DeviceTTSRendererV4_1779ecf3-f128-4319-852a-f456fc3e1260_1191541581
MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 24000 Hz, Mono
104 frames decoded (0:00:02.4), -2.2 dB peak amplitude, 0 clipped samples
DEBUG:/usr/bin/alexa:SpeechSynthesizer audio: DeviceTTSRendererV4_1779ecf3-f128-4319-852a-f456fc3e1260_1191541581
DEBUG:/usr/bin/alexa:AudioPlayer audio:https://opml.radiotime.com/Tune.ashx?serial=AG6ECDT3MHVASCBMGROTP6FQBPYQ&formats=aac,mp3&id=s44491&partnerId=4J
qugguZ
INFO:mic:Start detecting
INFO:mic:Too many delays, 6 in queue
INFO:mic:Too many delays, 5 in queue

She says something like 'playing BBC Radio 6 Music from TuneIn', but then it goes quit and I still don't have any sound.

So my question is:

Does anybody know how to fix this problem? I just really want to get as close as possible to an real Amazon Alexa with the Respeaker.

xiongyihui commented 6 years ago

have you tried the code in this repo https://github.com/respeaker/avs ?

ThePinkPanda commented 6 years ago

Actually no, because I find the installation instructions unclear. I only see a 'requirements' and a 'get started' section, but I don't know how to install or upload the files to the respeaker (no 'On ReSpeaker' & 'On Ubuntu' section) . Do I need to follow the same instructions as with the older version or other instructions?

xiongyihui commented 6 years ago

Most of the requirements are installed by default on ReSpeaker. Install the new version avs on respeaker by typeing:

pip install avs
ThePinkPanda commented 6 years ago

Thanks for your help so far, it worked, but I got stuck on alexa with an error code 204. First of all, I did a reset on the respeaker (firstboot) and followed the tutorial 'Use SD card to Extend Storage' (here) from the 'Get Started' page to extend the storage because last time I got some errors.

Then I installed avs with the pip install avs command without errors and configured my accound with alexa-auth just as mentioned on the 'Get Started' page, but every time I do alexa or alexa-tap I get the following error:

root@ReSpeaker:~# alexa-tap
press ENTER to talk
DEBUG:hyper.http20.connection:Selected NPN protocol: h2
DEBUG:hyper.http20.connection:recv for stream 0 with set([]) already present
INFO:hyper.http20.connection:Received unhandled event <RemoteSettingsChanged changed_settings:{ChangedSetting(setting=SettingCodes.MAX_CONCURRENT_STRE
AMS, original_value=None, new_value=100), ChangedSetting(setting=SettingCodes._max_header_list_size, original_value=None, new_value=40960)}>
DEBUG:hpack.hpack:HPACK encoding <generator object inner at 0xb73ca0>
DEBUG:hpack.hpack:Adding (':method', 'GET') to the header table
DEBUG:hpack.hpack:Encoding 2 with 7 bits
DEBUG:hpack.hpack:Adding (':scheme', 'https') to the header table
DEBUG:hpack.hpack:Encoding 7 with 7 bits
DEBUG:hpack.hpack:Adding (':authority', 'avs-alexa-na.amazon.com') to the header table
DEBUG:hpack.hpack:Encoding 1 with 6 bits
DEBUG:hpack.hpack:Encoding 17 with 7 bits
DEBUG:hpack.hpack:Adding (':path', '/v20160207/directives') to the header table
DEBUG:hpack.hpack:Encoding 4 with 6 bits
DEBUG:hpack.hpack:Encoding 459 with 7 bits
DEBUG:hyper.http20.connection:recv for stream 1 with set([]) already present
INFO:hyper.http20.connection:Received unhandled event <SettingsAcknowledged changed_settings:{ChangedSetting(setting=SettingCodes.ENABLE_PUSH, origina
l_value=1, new_value=0)}>
INFO:hyper.http20.connection:Received unhandled event <SettingsAcknowledged changed_settings:{}>
DEBUG:hyper.http20.connection:recv for stream 1 with set([]) already present
DEBUG:hpack.hpack:Decoded 8, consumed 1 bytes
DEBUG:hpack.hpack:Decoded (':status', '200'), consumed 1
DEBUG:hpack.hpack:Decoded 20, consumed 1 bytes
DEBUG:hpack.hpack:Decoded 1, consumed 1 bytes
DEBUG:hpack.hpack:Decoded ('access-control-allow-origin', <memory at 0xb746a0>), total consumed 3 bytes, indexed True
DEBUG:hpack.hpack:Decoded 12, consumed 1 bytes
DEBUG:hpack.hpack:Decoded 44, consumed 1 bytes
DEBUG:hpack.hpack:Decoded ('x-amzn-requestid', '0ede90fffeb4973a-000067e9-0008b616-9e731b5e17334b3a-ffd14392-1'), total consumed 59 bytes, indexed Tru
e
DEBUG:hpack.hpack:Decoded 31, consumed 1 bytes
DEBUG:hpack.hpack:Decoded 47, consumed 1 bytes
DEBUG:hpack.hpack:Decoded ('content-type', 'multipart/related; boundary=------abcde123; type=application/json'), total consumed 49 bytes, indexed True
INFO:hyper.http20.connection:Received unhandled event <PriorityUpdated stream_id:1, weight:16, depends_on:0, exclusive:False>
DEBUG:hpack.hpack:HPACK encoding <generator object inner at 0xb7ce90>
DEBUG:hpack.hpack:Adding (':method', 'POST') to the header table
DEBUG:hpack.hpack:Encoding 3 with 7 bits
DEBUG:hpack.hpack:Adding (':scheme', 'https') to the header table
DEBUG:hpack.hpack:Encoding 7 with 7 bits
DEBUG:hpack.hpack:Adding (':authority', 'avs-alexa-na.amazon.com') to the header table
DEBUG:hpack.hpack:Encoding 63 with 7 bits
DEBUG:hpack.hpack:Adding (':path', '/v20160207/events') to the header table
DEBUG:hpack.hpack:Encoding 4 with 6 bits
DEBUG:hpack.hpack:Encoding 12 with 7 bits
DEBUG:hpack.hpack:Adding ('content-type', 'multipart/form-data; boundary=seeed-voice-engine') to the header table
DEBUG:hpack.hpack:Encoding 31 with 6 bits
DEBUG:hpack.hpack:Encoding 34 with 7 bits
DEBUG:hpack.hpack:Adding ('authorization', 'Bearer Atza|IwEBINBfu3Y9bkq5EkmIHaLwT9Tdtsq2UVTcd3iuQPjBHtNkgOpudfUt72RsyikE3BBJc_k7f8Sqs4J1MR1G2g75ulFvxk
hy7GXSbNefTybh9ZbPqr1CZ7Vy_73tgbYnpf5H7vJQ86K7bYfrbQd0S5vdKI7UcrGP0wGRkOhB4uUT_ELGpvfBvE9NVbhBin53oZlTBVKW_pCQMF8B4fnQw5JF4OQ14tEf8y5MLcs85iZaebnpLUlL
Onu74IfvJo00en40pMwDE_w0kbJx4JgvGrqm0sQVVewKlvCDetSkMFivaC8SdRF1XzT3DFOdCjYLIFSIgEeHrQm5ZDkOxo3H1eRzm-An7-L3emgDV7I02G9Iu_DgTaEilaSsqMcKYpJEqfr0_-cmku
Hbf8iV3Ap9y5Vx3CIfcQCDhDze6-OIvqPO90m8BBlOwery8EN3wfbP04BJZMHz2rsEXurR_xCdum__EbRlqreQFj_fZmS6cIqfhzj1BQKsRW77aTacIuSGViL-38BsMUGgFtM_N6SDwqJSXpuDdOdQ
OxxCKV4YWS7mzefPng') to the header table
DEBUG:hpack.hpack:Encoding 23 with 4 bits
DEBUG:hpack.hpack:Encoding 459 with 7 bits
DEBUG:avs.alexa:metadata: {
    "event": {
        "header": {
            "namespace": "System",
            "name": "SynchronizeState",
            "messageId": "bf51ddad60b842aeadaf3448af40c8bf"
        },
        "payload": {}
    },
    "context": [
        {
            "header": {
                "namespace": "SpeechSynthesizer",
                "name": "SpeechState"
            },
            "payload": {
                "token": "",
                "playerActivity": "FINISHED",
                "offsetInMilliseconds": 0
            }
        },
        {
            "header": {
                "namespace": "Speaker",
                "name": "VolumeState"
            },
            "payload": {
                "volume": 50,
                "muted": false
            }
        },
        {
            "header": {
                "namespace": "AudioPlayer",
                "name": "PlaybackState"
            },
            "payload": {
                "token": "",
                "playerActivity": "IDLE",
                "offsetInMilliseconds": 0
            }
        },
        {
            "header": {
                "namespace": "Alerts",
                "name": "AlertsState"
            },
            "payload": {
                "allAlerts": [],
                "activeAlerts": []
            }
        }
    ]
}
INFO:avs.alexa:wait for response
DEBUG:hyper.http20.connection:recv for stream 3 with set([1]) already present
DEBUG:hpack.hpack:Decoded 9, consumed 1 bytes
DEBUG:hpack.hpack:Decoded (':status', '204'), consumed 1
DEBUG:hpack.hpack:Decoded 64, consumed 1 bytes
DEBUG:hpack.hpack:Decoded ('access-control-allow-origin', <memory at 0xb746a0>), consumed 1
DEBUG:hpack.hpack:Decoded 63, consumed 2 bytes
DEBUG:hpack.hpack:Decoded 44, consumed 1 bytes
DEBUG:hpack.hpack:Decoded ('x-amzn-requestid', '0ede90fffeb4973a-000067e9-0008b616-9e731b5e17334b3a-ffd14392-3'), total consumed 47 bytes, indexed Tru
e
INFO:hyper.http20.connection:Received unhandled event <PriorityUpdated stream_id:3, weight:16, depends_on:0, exclusive:False>
INFO:avs.alexa:status code: 204
DEBUG:avs.alexa:ping at Sun Nov 26 14:27:45 2017
INFO:hyper.http20.connection:Received unhandled event <PingAcknowledged ping_data:3761643434356466>

I don't know how to fix this, and when I do Ctrl+C to exit I get this:

^CException in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 763, in run
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 116, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'http20'
root@ReSpeaker:~#

Does somebody know how to fix this? Thanks.

ThePinkPanda commented 6 years ago

Hello, I still have a question about this topic, because it's still not working. Does somebody know how to fix this? I have tried many things but it just doesn't work and I get the same output as above. Thanks.

xiongyihui commented 6 years ago

There are some update. Cloud you try to run pip install -U avs to upgrade the library?

Then run alexa-audio-check to verify if the audio input and output are ok

$alexa-audio-check
RMS: 41 RMS: 43

If RMS is not zero, recording is OK, if you can hear alarm, playing is OK

adrenaline15 commented 6 years ago

Updating the avs library worked for me:

pip install -U avs

Thank you very much!

ThePinkPanda commented 6 years ago

Hi, Updating worked and I now see the message that my respeaker is online on alexa.amazon.com and I finally can play TuneIn radio stations!!! Thanks guys!!!

(Note: I can play stations from the alexa.amazon.com website, but it doesn't work if I say 'Alexa play bbc radio 6 music'. I don't think it's a huge problem, but it could be fixed ;)