Giter Site home page Giter Site logo

avsexample-swift's Introduction

AVSExample-Swift

This is an Alexa Voice Service example using Swift specifically for the Mac but the general concept should work on iOS as well. It requires Swift 2 from XCode 7 or later.

Before getting started make sure you have read getting started with Alexa Voice Service.

Carthage is used for dependancies. After cloning go into the root directory and run:

carthage bootstrap

You will need to fill out the following three items found in Config.swift before running:

struct LoginWithAmazon {
    static let ClientId = ""
    static let ProductId = ""
    static let DeviceSerialNumber = ""
}

If you follow the AVS getting started guide from above then the ClientId is set up in the Select or Create a Security Profile section, the ProductId is called Device Type ID and set up in the Device Type Info section and the DeviceSerialNumber can be anything as long as it is unique for the device type (something like "1000-0000-0000-0000" for example).

Once configured you can run the application and configure the authentication. The configure button will open a Login with Amazon web page that will allow you to authorize the application to use Alexa Voice Service. Once complete there will be a link to take you back to the application where you can use the record button to query Alexa.

Structure

Authorization is performed using the Implicit Grant method described in the Authorizing Your Alexa-enabled Product from a Website documentation. The application runs a simple web server derived from GCDWebServer, see SimpleWebServer.swift and login.html for more information.

The code for recording the request audio can be found in SimplePCMRecorder.swift, it is hard coded to the correct format for AVS. As of now this is the only format that will work with AVS so if you change things in this file be prepared for the processing to potentially fail.

The code for uploading the request audio as well as constructing the proper request can be found in AVSUploader.swift.

The code in ViewController.swift glues together the authorization, recording and uploading.

Potential Enhancements

  • Save config data to prefs, save auth token info to prefs
  • Display auth token expiration time on the screen
  • Upload to AVS as recording is in progress
  • Add a max length for the recording
  • Put in task bar, add a global shortcut key to record

avsexample-swift's People

Contributors

carsonmcdonald avatar

Watchers

John E. Ray avatar

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.