Giter VIP home page Giter VIP logo

houndify-sdk-go's Introduction

Houndify SDK for Go Build Status GoDoc

houndify-sdk-go is the official Houndify SDK for the Go programming language.

The SDK allows you to make voice and text queries to the Houndify API. The SDK comes with a fully functional example app that demonstrates usage and the various SDK features. The SDK has no third party dependencies.

Requirements

Installing

To use the SDK and/or example app, you will need a client ID and client key. You can get those after creating a Houndify account and registering a client.

Once you have set your $GOPATH, you can use both the Go Houndify SDK and example app.

go get github.com/soundhound/houndify-sdk-go

The example app will be compiled and available at $GOPATH/bin/houndify-sdk-go and the SDK will be ready to import and use.

Example App

example.go provides a working example using the SDK.

The example app features three modes of interacting with the Houndify API:

  1. Voice
  2. Text
  3. Stdin Interactive Text

To run the voice search:

houndify-sdk-go --id YOUR_CLIENT_ID --key YOUR_CLIENT_KEY --voice ./test_audio/whattimeisitindenver.wav

To run a text search:

houndify-sdk-go --id YOUR_CLIENT_ID --key YOUR_CLIENT_KEY --text "tell me a joke"

To run an interactive text search:

houndify-sdk-go --id YOUR_CLIENT_ID --key YOUR_CLIENT_KEY --stdin

You will then be prompted to type a query.

After Houndify replies with a response, you can follow up with additional text queries. Houndify will keep track of the conversation history, and interpret new queries in the context of previous ones.

An example set of queries:

  • "what is two plus six"
  • "minus 4"
  • "what is the square root of that"

Instead of using the --id and --key flags, you may set the environment variables HOUNDIFY_CLIENT_ID and HOUNDIFY_CLIENT_KEY.

Using the SDK

To use the SDK, you must import the package

import (
    houndify "github.com/soundhound/houndify-sdk-go/houndify"
)

Create a new client

client := houndify.Client{
    ClientID:  "YOUR_CLIENT_ID",
    ClientKey: "YOUR_CLIENT_KEY",
}

For a voice search, create a VoiceRequest and channel for partial transcripts. The audio to be streamed must already be the correct encoding that the server requires. See the Houndify Docs for details. There are example audio files to test with in test_audio.

req := houndify.VoiceRequest{
    AudioStream:       bytes.NewReader(audioDataByteArray),
    UserID:            "appUser123",
    RequestID:         "uniqueRequest456",
    RequestInfoFields: make(map[string]interface{}),
}

//listen for partial transcripts while audio is streaming
partialTranscripts := make(chan houndify.PartialTranscript)
go func() {
    for partial := range partialTranscripts {
        fmt.Println(partial.Message)
    }
}()

serverResponse, err := client.VoiceSearch(req, partialTranscripts)

For a text search, create a TextRequest

req := houndify.TextRequest{
    Query:             "what time is it in paris",
    UserID:            "appUser123",
    RequestID:         "uniqueRequest456",
    RequestInfoFields: make(map[string]interface{}),
}

serverResponse, err := client.TextSearch(req)

Conversation State

Houndified domains can use context to enable a conversational user interaction. For example, users can say "show me coffee shops near me", "which ones have wifi?", "sort by rating", "navigate to the first one". You can enable, disable, clear, set and get the client's conversation state with the following houndify.Client methods.

client.EnableConversationState()

client.DisableConversationState()

client.ClearConversationState()

currentState := client.GetConversationState()

client.SetConversationState(newState)

Contributing

There are multiple ways to contribute to the SDK.

If you found a bug or have a feature request, please open an Issue.

If you would like to make a code contribution, please sign the CLA, and make a Pull Request with your changes.

For account issues, security issues, or if you are unable to post publicly, please contact us directly.

License

The Houndify SDK for Go is distributed under the MIT License. See the LICENSE file for more information.

houndify-sdk-go's People

Contributors

bengadbois avatar odeke-em 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.