https://github.com/soundhound/houndify-sdk-go
The official Houndify SDK for Go
https://github.com/soundhound/houndify-sdk-go
go golang houndify sdk speech-recognition voice-recognition voice-search
Last synced: 6 months ago
JSON representation
The official Houndify SDK for Go
- Host: GitHub
- URL: https://github.com/soundhound/houndify-sdk-go
- Owner: soundhound
- License: mit
- Created: 2017-03-17T22:26:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-09-04T02:03:15.000Z (almost 4 years ago)
- Last Synced: 2024-06-20T12:07:50.238Z (about 2 years ago)
- Topics: go, golang, houndify, sdk, speech-recognition, voice-recognition, voice-search
- Language: Go
- Homepage: https://www.houndify.com
- Size: 414 KB
- Stars: 23
- Watchers: 6
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Houndify SDK for Go [](https://travis-ci.org/soundhound/houndify-sdk-go) [](https://godoc.org/github.com/soundhound/houndify-sdk-go/houndify)
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
- Go v1.8+
- Houndify account available from [Houndify.com](https://www.houndify.com)
## 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](https://www.houndify.com) 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 `houndify` package:
```go
import (
"github.com/soundhound/houndify-sdk-go"
)
```
Create a new client
```go
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](https://www.houndify.com/docs/) for details. There are example audio files to test with in `test_audio`.
```go
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
```go
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.
```go
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](https://github.com/soundhound/houndify-sdk-go/issues).
If you would like to make a code contribution, please sign the [CLA](https://cla-assistant.io/soundhound/houndify-sdk-go), and make a [Pull Request](https://github.com/soundhound/houndify-sdk-go/pulls) with your changes.
For account issues, security issues, or if you are unable to post publicly, please [contact us](https://www.houndify.com/contact) directly.
## License
The Houndify SDK for Go is distributed under the MIT License. See the LICENSE file for more information.