Documentation ¶
Overview ¶
Package aurora is an SDK to interact with the Aurora API, making it easy to integrate voice user interfaces into your application.
Index ¶
Constants ¶
const ( // ListenDefaultLength is the default length of time (in seconds) to listen for. ListenDefaultLength = 0.0 // ListenDefaultSilenceLen is the default amount of silence (in seconds) // that the recording framework will allow before stoping. ListenDefaultSilenceLen = 0.5 )
Variables ¶
var Config = config.C
Config is an alias for config.C so that you can easily override the SDK configuation by typing something like:
aurora.Config.AppID = "My ID" aurora.Config.AppToken = "My Token" aurora.Config.DeviceID = "My Device"
Functions ¶
func ContinuouslyListen ¶
func ContinuouslyListen(params *ListenParams, handleFunc SpeechHandleFunc)
This function accepts another function as an argument that is called each time a speech utterance is decoded. See the documentation for `SpeechHandleFunc` for more information.
func ContinuouslyListenAndTranscribe ¶
func ContinuouslyListenAndTranscribe(params *ListenParams, handleFunc TextHandleFunc)
ContinuouslyListenAndTranscribe is a combination of `ContinuouslyListen` and `ListenAndTranscribe`. See the documentation for those two functions to understand how it works. The difference is that this handler function receives objects of type *Text instead of *Speech. See the documentation for `TextHandleFunc` for more information on that.
Types ¶
type Interpret ¶
type Interpret struct { // Intent represents the intent of the user. This can be an empty string if // the intent of the user was unclear. Otherwise, it will be one of the // pre-determined values listed in the Aurora dashboard. Intent string // Entities contain auxiliary information about the user's utterance. This // can be an empty map if no such information was detected. Otherwise, it // will be a key-value listing according to the entities described on the // Aurora dashboard. Entities map[string]string }
Interpret contains the results from a call to the Aurora Interpret service.
func NewInterpret ¶
func NewInterpret(res *api.InterpretResponse) *Interpret
NewInterpret takes a response from the API and creates an Interpet object out of it. It doesn't really make sense for a developer to call this, but it is left exported in case it makes sense in the future.
type ListenParams ¶
type ListenParams struct { // Length specifies how long to listen for in seconds. A value of 0 // means that the recording framework will continue to listen until // the specified amount of silence. A value greater than 0 will // override any value set to `SilenceLen` Length float64 // SilenceLen is how long of silence (in seconds) will be allowed before // automatically stopping. This value is only taken into consideration if // `Length` is 0 SilenceLen float64 }
ListenParams configures how the recording framework should listen for speech.
func NewListenParams ¶
func NewListenParams() *ListenParams
NewListenParams creates the default set of ListenParams. You should call this function to get the default and then replace the ones you want to customize.
type Speech ¶
type Speech struct { // Audio is the underlying audio that this struct wraps. You can create // a speech object and set this directly if you want to operate on some // pre-recorded audio Audio *audio.File }
Speech represents a user's utterance. It has high-level methods that let you operate on the speech (like convert it to text) and also allows you to access the underlying audio data to manipulate it, save it, play it, etc.
func Listen ¶
func Listen(params *ListenParams) (*Speech, error)
`Listen` takes in `ListenParams` and generates a speech object based on those parameters by recording from the default input device.
Note that the `ListenParams` is expected to contain values for every field, including defaults for fields that you did not want to change. To avoid having to do this, you should call `NewListenParams` to obtain an instance of `ListenParams` with all of the default filled out, and then over- ride them with the ones you want to change. Alternatively, you can pass `nil` to simply use the default parameters.
Currently, this function uses the default audio input interface (an option to change this will be available at a later time).
type SpeechHandleFunc ¶
SpeechHandleFunc is the type of function that is passed to `ContinuouslyListen`. It is called every time a speech utterance is decoded and passed to the function. If there was an error, that is passed as well. The function must return a boolean that indicates whether or not to continue listening (true to continue listening, false to stop listening).
type Text ¶
type Text struct { // Text is the actual text that this object encapsulates Text string }
Text encapsulates some text, whether it is obtained from STT, a user input, or generated programmatically, and allows high-level operations to be conducted and chained on it (like converting to speech, or calling Interpret).
func ListenAndTranscribe ¶
func ListenAndTranscribe(params *ListenParams) (*Text, error)
ListenAndTranscribe starts listening with the given parameters, except instead of waiting for the audio to finish capturing and returning a Speech object, it directly streams it to the API, transcribing it in real-time. When the transcription completes, this function directly returns a Text object. This reduces latency by a significant amount if you already know you want to transcribe the audio.
Note that the `ListenParams` is expected to contain values for every field, including defaults for fields that you did not want to change. To avoid having to do this, you should call `NewListenParams` to obtain an instance of `ListenParams` with all of the default filled out, and then override them with the ones you want to change. Alternatively, you can pass `nil` to simply use the default parameters.
type TextHandleFunc ¶
TextHandleFunc is the type of function that is passed to `ContinuouslyListenAndTranscribe`. It is called every time a speech utterance is decoded and converted to text. The resulting text object is passed to the function. If there was an error, that is passed as well. The function must return a boolean that indicates whether or not to continue listening (true to continue listening, false to stop listening).
Directories ¶
Path | Synopsis |
---|---|
Package api provides methods to contact the Aurora API and process the given requests.
|
Package api provides methods to contact the Aurora API and process the given requests. |
backend
Package backend provides a generic interface to make calls to the Aurora backend.
|
Package backend provides a generic interface to make calls to the Aurora backend. |
Package audio contains structs and functions to allow operating on audio data
|
Package audio contains structs and functions to allow operating on audio data |
Package config contains configuration information that is used by the rest of the SDK.
|
Package config contains configuration information that is used by the rest of the SDK. |
Package error is a collection of error-related functionality that aims to unify all of the errors across the SDK.
|
Package error is a collection of error-related functionality that aims to unify all of the errors across the SDK. |