Giter VIP home page Giter VIP logo

alexa-client's Introduction

Alexa Client

Python client for Amazon's Alexa Voice Service (AVS).

Prerequisites

Amazon Developer Account

In order to use Alexa Voice Service you will need to signup for an Amazon Developer account. You can read about it on my blog post and get the details from Amazon's Getting Started Guide.

In order to access Alexa Voice Service, you will also need to make an Authorization Code Grant request to get a refresh token. This is detailed in Amazon's guide.

See the Authorization Code Grant section below for an example of how to do this.

Installation

  1. Clone this repository

    git clone https://github.com/ewenchou/alexa-client.git
    
  2. Configure settings. Set the PRODUCT_ID, CLIENT_ID, CLIENT_SECRET, and REFRESH_TOKEN values in alexa_client/settings.py.

    Note: If you do not have a refresh token, see the Authorization Code Grant section below for an example of how to get one.

  3. Install requirements

    pip install -r requirements.txt
    
  4. Install alexa_client

    python setup.py install
    

Authorization Code Grant

The Python script, auth_web.py is included in this repository to make it easier to request an Authorization Code Grant as detailed in Amazon's guide.

NOTE: The auth_web.py script is taken and modified from the respeaker/Alexa Github repository.

You should have followed Amazon's Getting Started Guide and created a developer account as well as a new Alexa Voice Service device with a Security Profile.

You should now have the following values and they should be saved in alexa_client/settings.py:

  • Device Type ID
  • Client ID
  • Client Secret

In order to authorize a client, you will also need to configure the Web Settings tab of the Security Profile of your device.

  1. Log into the Amazon Developer Portal and navigate to the Alexa Voice Service section. Click on the device you created in the list.

  2. Click on Security Profile on the left menu.

  3. Click on the Web Settings tab

  4. Click on the Edit button and add the following:

    • Allowed Origins: http://localhost:3000/
    • Allowed Return URLs: http://localhost:3000/authresponse
  5. Click the Save button to save the settings.

Install the requirements for auth_web.py:

    sudo pip install -r auth_web_requirements.txt

Now you can run the auth_web.py script.

  1. Run the script: python auth_web.py
  2. Open a web browser and go to http://localhost:3000
  3. You should be redirected to an Amazon Login page. Enter your username and password and login.
  4. You should now see a simple page that says Success! and the refresh token value.
  5. Copy the refresh token value and set it in alexa_client/settings.py

Tests

Some sample tests are available in the test directory. Once installed and configured, you can run them to check if everything is working.

  • Test a single request: python test/test_ask.py

  • Test multiple concurrent requests: python test/test_multiple.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.