All Projects → rogertalk → go-avs

rogertalk / go-avs

Licence: MIT license
A simple package for communicating with Amazon’s HTTP/2 API for AVS.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-avs

alexa-ruby
Ruby toolkit for Amazon Alexa service
Stars: ✭ 17 (-32%)
Mutual labels:  alexa, amazon, amazon-echo, alexa-voice-service
go-snowboy
Go wrapper for Kitt-AI's snowboy audio detection library.
Stars: ✭ 40 (+60%)
Mutual labels:  alexa, avs, alexa-voice-service
Amazon Alexa Php
Php library for amazon echo (alexa) skill development.
Stars: ✭ 93 (+272%)
Mutual labels:  alexa, amazon, amazon-echo
Chatskills
Run and debug Alexa skills on the command-line. Create bots. Run them in Slack. Run them anywhere!
Stars: ✭ 171 (+584%)
Mutual labels:  alexa, amazon, amazon-echo
Alexa Skill Kit
Library for effortless Alexa Skill development with AWS Lambda
Stars: ✭ 278 (+1012%)
Mutual labels:  alexa, amazon, amazon-echo
HuntTheYetiAlexa
Play the game Hunt the Yeti on the Amazon Echo
Stars: ✭ 17 (-32%)
Mutual labels:  alexa, amazon, amazon-echo
Alexa Skills Kit Sdk For Java
The Alexa Skills Kit SDK for Java helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Stars: ✭ 758 (+2932%)
Mutual labels:  alexa, amazon, amazon-echo
Home-Assistant
Home-Assistant-Config
Stars: ✭ 186 (+644%)
Mutual labels:  alexa, amazon, amazon-echo
Home Assistant
Home-Assistant-Config
Stars: ✭ 182 (+628%)
Mutual labels:  alexa, amazon, amazon-echo
Go Alexa
A collection of Amazon Echo / Alexa tools for Go development.
Stars: ✭ 245 (+880%)
Mutual labels:  alexa, amazon, amazon-echo
Assistantcomputercontrol
Control your computer with your Google Home or Amazon Alexa assistant!
Stars: ✭ 554 (+2116%)
Mutual labels:  alexa, amazon-echo
Awesome Amazon Alexa
🗣Curated list of awesome resources for the Amazon Alexa platform.
Stars: ✭ 458 (+1732%)
Mutual labels:  alexa, amazon-echo
Home Assistantconfig
🏠 Home Assistant configuration & Documentation for my Smart House. Write-ups, videos, part lists, and links throughout. Be sure to ⭐ it. Updated FREQUENTLY!
Stars: ✭ 3,687 (+14648%)
Mutual labels:  alexa, amazon
Alexa App
A framework for Alexa (Amazon Echo) apps using Node.js
Stars: ✭ 1,015 (+3960%)
Mutual labels:  alexa, amazon-echo
Alexa Voice Service.js
Library for interacting with Alexa Voice Service (AVS) in the browser.
Stars: ✭ 123 (+392%)
Mutual labels:  alexa, amazon
Voicewp
Create Alexa Skills through WordPress
Stars: ✭ 132 (+428%)
Mutual labels:  alexa, amazon
Alexa Rubykit
Amazon Echo Alexa's App Kit Ruby Implementation
Stars: ✭ 155 (+520%)
Mutual labels:  alexa, amazon-echo
AlexaAndroid
No description or website provided.
Stars: ✭ 15 (-40%)
Mutual labels:  alexa, amazon
SinricPro Generic
Simple way to control your IOT development boards like ESP8226, ESP32, Arduino SAMD21, Adafruit SAMD21, SAMD51, nRF52, STM32, Teensy, SAM DUE with Amazon Alexa or Google Home
Stars: ✭ 18 (-28%)
Mutual labels:  alexa, alexa-voice-service
Bst
🔧 Bespoken Tools - Tools for making voice apps faster and better
Stars: ✭ 193 (+672%)
Mutual labels:  alexa, amazon-echo

Alexa Voice Service for Go

GoDoc

A simple package for communicating with Amazon’s HTTP/2 API for AVS.

Requires Go 1.8 or later.

Example

package main

import (
  "fmt"
  "io/ioutil"
  "os"

  "github.com/fika-io/go-avs"
)

// Put your access token below.
const ACCESS_TOKEN = "YOUR ACCESS TOKEN"

func main() {
  // Record your request into request.wav.
  audio, _ := os.Open("./request.wav")
  response, err := avs.PostRecognize(ACCESS_TOKEN, "abc123", "abc123dialog", audio)
  if err != nil {
    fmt.Printf("Failed to call AVS: %v\n", err)
    return
  }
  // AVS might not return any directives in some cases.
  if len(response.Directives) == 0 {
    fmt.Println("Alexa had nothing to say.")
    return
  }
  // A response can have multiple directives in the response.
  for _, directive := range response.Directives {
    switch d := directive.Typed().(type) {
    case *avs.ExpectSpeech:
      fmt.Printf("Alexa wants you to speak within %s!\n", d.Timeout())
    case *avs.Play:
      // The Play directive can point to attached audio or remote streams.
      if cid := d.Payload.AudioItem.Stream.ContentId(); cid != "" {
        save(response, cid)
      } else {
        fmt.Println("Remote stream:", d.Payload.AudioItem.Stream.URL)
      }
    case *avs.Speak:
      // The Speak directive always points to attached audio.
      save(response, d.ContentId())
    default:
      fmt.Println("No code to handle directive:", d)
    }
  }
}

var savedFiles = 0

// Function that saves an audio file to disk.
func save(resp *avs.Response, cid string) {
  savedFiles++
  filename := fmt.Sprintf("./response%d.mp3", savedFiles)
  ioutil.WriteFile(filename, resp.Content[cid], 0666)
  fmt.Println("Saved Alexa’s response to", filename)
}

Downchannels

You can open a downchannel with the CreateDownchannel method. It's implemented as a read-only channel of Message pointers.

package main

import (
  "fmt"

  "github.com/fika-io/go-avs"
)

// Put your access token below.
const ACCESS_TOKEN = "YOUR ACCESS TOKEN"

func main() {
  directives, err := avs.CreateDownchannel(ACCESS_TOKEN)
  if err != nil {
    fmt.Printf("Failed to open downchannel: %v\n", err)
    return
  }
  // Wait for directives to come in on the downchannel.
  for directive := range directives {
    switch d := directive.Typed().(type) {
    case *avs.DeleteAlert:
      fmt.Println("Unset alert:", d.Payload.Token)
    case *avs.SetAlert:
      fmt.Printf("Set alert %s (%s) for %s\n", d.Payload.Token, d.Payload.Type, d.Payload.ScheduledTime)
    default:
      fmt.Println("No code to handle directive:", d)
    }
  }
  fmt.Println("Downchannel closed. Bye!")
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].