houndify

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const SDKUserAgent = "Go Houndify SDK"

Default user agent set by the SDK

Variables

This section is empty.

Functions

func ParseWrittenResponse

func ParseWrittenResponse(serverResponseJSON string) (string, error)

ParseWrittenResponse will take final server response JSON (as a string) and parse out the human readable text to be displayed or spoken the end user. If the string is invalid JSON, the server had an error, or there was nothing to reply with, an error is returned.

Types

type Client

type Client struct {
	// The ClientID comes from the Houndify site.
	ClientID string
	// The ClientKey comes from the Houndify site.
	// Keep the key secret.
	ClientKey string

	// If Verbose is true, all data sent from the server is printed to stdout, unformatted and unparsed.
	// This includes partial transcripts, errors, HTTP headers details (status code, headers, etc.), and final response JSON.
	Verbose bool
	// contains filtered or unexported fields
}

A Client holds the configuration and state, which is used for sending all outgoing Houndify requests and appropriately saving their responses.

func (*Client) ClearConversationState

func (c *Client) ClearConversationState()

ClearConversationState removes, or "forgets", the current conversation state

func (*Client) DisableConversationState

func (c *Client) DisableConversationState()

DisableConversationState disables conversation state for future queries

func (*Client) EnableConversationState

func (c *Client) EnableConversationState()

EnableConversationState enables conversation state for future queries

func (*Client) GetConversationState

func (c *Client) GetConversationState() interface{}

GetConversationState returns the current conversation state, useful for saving

func (*Client) SetConversationState

func (c *Client) SetConversationState(newState interface{})

SetConversationState sets the conversation state, useful for resuming from a saved point

func (*Client) TextSearch

func (c *Client) TextSearch(textReq TextRequest) (string, error)

TextSearch sends a text request and returns the body of the Hound server response.

An error is returned if there is a failure to create the request, failure to connect, failure to parse the response, or failure to update the conversation state (if applicable).

func (*Client) VoiceSearch

func (c *Client) VoiceSearch(voiceReq VoiceRequest, partialTranscriptChan chan PartialTranscript) (string, error)

VoiceSearch sends an audio request and returns the body of the Hound server response.

The partialTranscriptChan parameter allows the caller to receive for PartialTranscripts while the Hound server is listening to the voice search. If partial transcripts are not needed, create a throwaway channel that listens and discards all the PartialTranscripts sent.

An error is returned if there is a failure to create the request, failure to connect, failure to parse the response, or failure to update the conversation state (if applicable).

type PartialTranscript

type PartialTranscript struct {
	// The text of the partial transcript
	Message string
	// Length of audio this partial transcript applies to
	Duration time.Duration
	// If this is the last partial transcript
	Done bool
}

type TextRequest

type TextRequest struct {
	// The text query, e.g. "what time is it in london"
	Query             string
	UserID            string
	RequestID         string
	RequestInfoFields map[string]interface{}
}

A TextRequest holds all the information needed to make a Houndify request. Create one of these per request to send and use a Client to send it.

type VoiceRequest

type VoiceRequest struct {
	// Stream of audio in bytes. It must already be in correct encoding.
	// See the Houndify docs for details.
	AudioStream       io.Reader
	UserID            string
	RequestID         string
	RequestInfoFields map[string]interface{}
}

A VoiceRequest holds all the information needed to make a Houndify request. Create one of these per request to send and use a Client to send it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL