• Stars
    star
    196
  • Rank 198,511 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

python implementation of alexa voice service app, 支持DuerOS

Python Alexa Voice Service App

Features

  • Support Alexa Voice Service API v20160207
  • Support multiple audio players: gstreamer 1.0, mpv and mpg123
  • 支持Baidu DuerOS

Options

  1. Player

    We have 3 players (mpv, mpg123 and gstreamer) to use. SpeechSynthesizer and Alerts prefer mpg123 which is more responsive. AudioPlayer likes gstreamer > mpv > mpg123. Gstreamer supports more audio format and works well on raspberry pi. We can also specify the player of AudioPlayer using the environment variable PLAYER.

  2. Recorder

    2 recorders (pyaudio & arecord) are available. We can use environment variable RECORDER to specify the recorder. For example, run RECORDER=pyaudio alexa-tap will use pyaudio as the recorder. By default, arecord is used as the recorder.

  3. Keyword detector (optional)

    Use PocketSphinx or Snowboy. To use pocketsphinx, install respeaker python library and pocketsphinx. To use Snowboy, go to Snowboy's Github to install it.

If you use raspberry pi and gstreamer, it is likely that gstreamer's default audio sink is GstOMXHdmiAudioSink. It ignores ALSA configurations and outputs audio to HDMI. If you don't want to use HDMI audio output, you should run sudo apt remove gstreamer1.0-omx gstreamer1.0-omx-rpi

Requirements

  • For ReSpeaker Core (MT7688)

    gstreamer1.0, pyaudio and pocketsphinx and respeaker python library are already installed by default, just run pip install avs

  • For Debian/Ubuntu/Raspbian

    sudo apt-get install mpg123 mpv
    sudo apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
    gir1.2-gstreamer-1.0 python-gi python-gst-1.0
    sudo apt-get install python-pyaudio
    

Get started

  1. run alexa-audio-check to check if recording & playing is OK. If RMS is not zero, recording is OK, if you can hear alarm, playing is OK

     $alexa-audio-check
     RMS: 41
     RMS: 43
    
  2. run alexa-auth to login Amazon, it will save authorization information to ~/.avs.json

  3. run alexa-tap, then press Enter to talk with alexa

If you want to use a specified player, use the environment variable PLAYER to specify it, such as PLAYER=mpv alexa-tap or PLAYER=mpg123 alexa or PLAYER=gstreamer alexa

Hands-free Alexa

Using PocketSphinx for Keyword Spotting

  1. install respeaker and pocketsphinx python packages

    sudo pip install respeaker pocketsphinx # pocketsphinx requires gcc toolchain and libpulse-dev

  2. run alexa, then use "alexa" to start a conversation with alexa, for example, "alexa, what time is it"

Using Snowboy for Keyword Spotting

  1. Install Snowboy

    git clone --depth 1 https://github.com/Kitt-AI/snowboy.git snowboy_github
    cd snowboy_github
    sudo apt install libatlas-base-dev swig
    python setup.py build
    sudo pip install .
    
  2. Install voice-engine python library

    sudo pip install voice-engine

  3. run the following python script and use the keyword alexa to start a conversation with alexa

    import time
    import signal
    from voice_engine.source import Source
    from voice_engine.kws import KWS
    from avs.alexa import Alexa
    import logging
    
    logging.basicConfig(level=logging.DEBUG)
    
    
    src = Source(rate=16000)
    kws = KWS(model='snowboy')
    alexa = Alexa()
    
    src.pipeline(kws, alexa)
    
    def on_detected(keyword):
        print('detected {}'.format(keyword))
        alexa.listen()
    
    kws.set_callback(on_detected)
    
    is_quit = []
    def signal_handler(signal, frame):
        print('Quit')
        is_quit.append(True)
    
    signal.signal(signal.SIGINT, signal_handler)
    
    src.pipeline_start()
    while not is_quit:
        time.sleep(1)
    src.pipeline_stop()

To do

  • Speaker interface
  • Notifications interface

Change Alexa Voice Service client id and product id

If you want to use your own client id and product id, try:

  1. register for an Amazon Developer Account

  2. create a file named config.json with your product_id, client_id and client_secret

     {
         "product_id": "x",
         "client_id": "y",
         "client_secret": "z"
     }
    
  3. run alexa-auth -c config.json

  4. run alexa-tap or alexa

License

GNU General Public License v3

Credits

This project is based on nicholas-gh/python-alexa-client

This package was created with Cookiecutter_ and the audreyr/cookiecutter-pypackage project template.

More Repositories

1

seeed-voicecard

2 Mic Hat, 4 Mic Array, 6-Mic Circular Array Kit, and 4-Mic Linear Array Kit for Raspberry Pi
C
472
star
2

mic_array

DOA, VAD and KWS for ReSpeaker Microphone Array
Python
286
star
3

get_started_with_respeaker

This is the wiki of ReSpeaker Core V2, ReSpeaker Core and ReSpeaker Mic Array.
Python
257
star
4

respeaker_python_library

To build voice enabled objects/applications with Python and ReSpeaker
Python
149
star
5

usb_4_mic_array

ReSpeaker 4 Mic Array with builtin VAD, DOA, AEC, Beamforming & NS
Python
137
star
6

mic_hat

2 Mic Array for Raspberry Pi
Python
102
star
7

pixel_ring

RGB LED library for ReSpeaker 4 Mic Array, ReSpeaker V2 & ReSpeaker USB 6+1 Mic Array
Python
59
star
8

respeakerd

respeakerd is the server application for the microphone array solutions of SEEED, based on librespeaker which combines the audio front-end processing algorithms.
C++
54
star
9

Alexa

New version is at https://github.com/respeaker/avs
Python
53
star
10

respeaker_for_raspberrypi

Examples to use ReSpeaker series Mic Arrays on Raspberry Pi
Python
41
star
11

4mics_hat

Python
34
star
12

respeaker-feed

C
20
star
13

mic_array_dfu

ReSpeaker Microphone Array DFU tool for firmware upgrade
C
19
star
14

respeaker_arduino_library

C++
18
star
15

pocketsphinx_keyword_spotting

Use Pocketsphinx to detect keywords offline
Python
12
star
16

microsoft_cognitive_services

Not updated, use
Python
11
star
17

Music_Visualizer

Music Player with Spectrum
Python
8
star
18

ok_google

hands-free google assistant with respeaker
Python
8
star
19

respeaker_v2_eval

respeaker v2 评估板入坑指南
Python
8
star
20

respeaker.github.io

6
star
21

piano

Turn ReSpeaker into a Piano (with Fruit)
Python
6
star
22

w

Send Wi-Fi settings through sound wave http://respeaker.io/w
Python
6
star
23

googleassistant_respeakerd

Adapt google assistant's gRPC sample app for working with respeakerd
Python
6
star
24

respeaker_frontend

JavaScript
5
star
25

spi_bridge

SPI bridge between Arduino (ATmega32u4) and ReSpeaker (MT7688), ATmega32u4 as a SPI slave
Python
5
star
26

pocketsphinx-data

PocketSphinx's acoustic model, dictionary and keywords
Shell
5
star
27

rkbin

Shell
4
star
28

respeaker_hi

Python
4
star
29

FasterConfig

A faster way to setup wifi
C++
4
star
30

deb_repos

Roff
3
star
31

axol_system_image_changelog

ReSpeaker Core v2 image changelog, TODO and collecting issues.
2
star
32

image_builder

Shell
2
star
33

respeaker_openwrt_files

openwrt files for respeaker
Shell
2
star
34

respeaker_virtualenv

Python
2
star
35

source_builder

Shell
1
star
36

orangerpcd

Shell
1
star
37

mopidy-hallo

Voice Interaction with Mopidy
Python
1
star
38

toolchains

1
star
39

docs

ReSpeaker Documents
HTML
1
star
40

deb

deb package repository for respeaker v2
1
star