Skip to main content

Alexa client in your browser. Django app.

Project description

Alexa Browser Client

code-climate-image circle-ci-image codecov-image pypi-image django-version-image

Alexa client in your browser. Django app. Talk to Alexa from your desktop, phone, or tablet browser.


Demo

The demo should really be heard, so click the gif below to view it in youtube.

Demo

Run the demo

First follow these steps:

  1. Configure your Amazon oauth configuration
  2. Set your environment variables
  3. Install:
$ git clone git@github.com:richtier/alexa-browser-client.git
$ cd alexa-browser-client
$ virtualenv .venv -p python3.6
$ source .venv/bin/activate
$ pip install -r requirements-dev.txt
  1. Compile snowboy
  2. $ make demo

Installation

pip install alexa_browser_client

Make sure your settings INSTALLED_APPS contains at least these entries:

INSTALLED_APPS = [
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sessions',
    'channels',
    'alexa_browser_client',
]

Dependencies

Snowboy detects when the wakeword "Alexa" is uttered.

You must compile Snowboy manually. Copy the compiled snowboy folder to the top level of you project. By default, the folder structure should be:

.
├── ...
├── snowboy
|   ├── snowboy-detect-swig.cc
|   ├── snowboydetect.py
|   └── resources
|       ├── alexa.umdl
|       └── common.res
└── ...

If the default folder structure does not suit your needs you can customize the wakeword detector.

Routing and urls

Add url(r'^', include('alexa_browser_client.config.urls')), to urls.py url_patterns.

Add include('alexa_browser_client.config.routing.channel_routing') to your routing.py channel_routing.

Authentication

This app uses Alexa Voice Service. To use AVS you must first have a developer account. Then register your product here. Choose "Application" under "Is your product an app or a device"?

Ensure you update your settings.py:

Setting Notes
ALEXA_BROWSER_CLIENT_AVS_CLIENT_ID Retrieve by clicking on the your product listed here
ALEXA_BROWSER_CLIENT_AVS_CLIENT_SECRET Retrieve by clicking on the your product listed here
ALEXA_BROWSER_CLIENT_AVS_DEVICE_TYPE_ID Retrieve by reading "Product ID" here

Refresh token

You will need to login to Amazon via a web browser to get your refresh token.

To enable this first go here and click on your product to set some security settings under Security Profile and, assuming you're running on localhost:8000, set the following:

setting value
Allowed Origins https://localhost:8000/refreshtoken/
Allowed Return URLs https://localhost:8000/refreshtoken/callback/

Usage

Once you have all the settings configured:

  • Run django: ./manage.py runserver
  • Go to http://localhost:8000 and start talking to Alexa.

Customization

Wakeword

The default wakeword is "Alexa". You can change this by customizing the lifecycle's audio_detector_class:

# my_project/consumers.py

import alexa_browser_client
import command_lifecycle


class CustomAudioDetector(command_lifecycle.wakeword.SnowboyWakewordDetector):
    wakeword_library_import_path = 'dotted.import.path.to.wakeword.Detector'
    resource_file = b'path/to/resource_file.res'
    decoder_model = b'path/to/model_file.umdl'


class CustomAudioLifecycle(alexa_browser_client.AudioLifecycle):
    audio_detector_class = CustomAudioDetector


class CustomAlexaConsumer(alexa_browser_client.AlexaConsumer):
    audio_lifecycle_class = CustomAudioLifecycle

Then in your routes.py:

from my_project import consumers


channel_routing = [
    consumers.CustomAlexaConsumer.as_route(path='/'),
]

Versioning

We use SemVer for versioning. For the versions available, see the PyPI.

Other projects

This project uses Voice Command Lifecycle and Alexa Voice Service Client.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alexa_browser_client-3.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file alexa_browser_client-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: alexa_browser_client-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/38.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.1

File hashes

Hashes for alexa_browser_client-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d7cae59277257e2ce609d955639879516a75c52bcc953d14304f8459d917713
MD5 12610bc335499edb85445a49bd3ca202
BLAKE2b-256 3da4187a55d004120bae7134c9a936ba9c185dcdb08ada3195687ff0fddc652e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page