speech

package
Version: v1.17.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 10 Imported by: 5

Documentation

Overview

Package speech provides functionality for speech recognizers along with their related configuration and event objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioDataStream added in v1.17.0

type AudioDataStream struct {

	// Properties represents the collection of additional properties.
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

AudioDataStream represents audio data stream used for operating audio data as a stream. Added in version 1.17.0

func NewAudioDataStreamFromHandle added in v1.17.0

func NewAudioDataStreamFromHandle(handle common.SPXHandle) (*AudioDataStream, error)

NewAudioDataStreamFromHandle creates a new AudioDataStream from a handle (for internal use)

func NewAudioDataStreamFromSpeechSynthesisResult added in v1.17.0

func NewAudioDataStreamFromSpeechSynthesisResult(result *SpeechSynthesisResult) (*AudioDataStream, error)

NewAudioDataStreamFromSpeechSynthesisResult creates a memory backed AudioDataStream from given speech synthesis result.

func NewAudioDataStreamFromWavFileInput added in v1.17.0

func NewAudioDataStreamFromWavFileInput(filename string) (*AudioDataStream, error)

NewAudioDataStreamFromWavFileInput creates a memory backed AudioDataStream for the specified audio input file.

func (AudioDataStream) CanReadData added in v1.17.0

func (stream AudioDataStream) CanReadData(bytesRequested uint) bool

CanReadData checks whether the stream has enough data to be read.

func (AudioDataStream) CanReadDataAt added in v1.17.0

func (stream AudioDataStream) CanReadDataAt(bytesRequested uint, off int64) bool

CanReadDataAt checks whether the stream has enough data to be read, at the specified offset.

func (AudioDataStream) Close added in v1.17.0

func (stream AudioDataStream) Close()

Close disposes the associated resources.

func (AudioDataStream) GetOffset added in v1.17.0

func (stream AudioDataStream) GetOffset() (int, error)

GetOffset gets current offset of the audio data stream.

func (AudioDataStream) GetStatus added in v1.17.0

func (stream AudioDataStream) GetStatus() (common.StreamStatus, error)

GetStatus gets the current status of the audio data stream.

func (AudioDataStream) Read added in v1.17.0

func (stream AudioDataStream) Read(buffer []byte) (int, error)

Read reads a chunk of the audio data stream and fill it to given buffer. It returns size of data filled to the buffer and any write error encountered.

func (AudioDataStream) ReadAt added in v1.17.0

func (stream AudioDataStream) ReadAt(buffer []byte, off int64) (int, error)

ReadAt reads a chunk of the audio data stream and fill it to given buffer, at specified offset. It returns size of data filled to the buffer and any write error encountered.

func (AudioDataStream) SaveToWavFileAsync added in v1.17.0

func (stream AudioDataStream) SaveToWavFileAsync(filename string) chan error

SaveToWavFileAsync saves the audio data to a file, asynchronously.

func (AudioDataStream) SetOffset added in v1.17.0

func (stream AudioDataStream) SetOffset(offset int) error

SetOffset sets current offset of the audio data stream.

type AutoDetectSourceLanguageConfig

type AutoDetectSourceLanguageConfig struct {
	// contains filtered or unexported fields
}

AutoDetectSourceLanguageConfig defines auto detection source configuration

func NewAutoDetectSourceLanguageConfigFromLanguageConfigs

func NewAutoDetectSourceLanguageConfigFromLanguageConfigs(configs []*SourceLanguageConfig) (*AutoDetectSourceLanguageConfig, error)

NewAutoDetectSourceLanguageConfigFromLanguageConfigs creates an instance of the AutoDetectSourceLanguageConfig with a list of source language config

func NewAutoDetectSourceLanguageConfigFromLanguages

func NewAutoDetectSourceLanguageConfigFromLanguages(languages []string) (*AutoDetectSourceLanguageConfig, error)

NewAutoDetectSourceLanguageConfigFromLanguages creates an instance of the AutoDetectSourceLanguageConfig with source languages

func NewAutoDetectSourceLanguageConfigFromOpenRange added in v1.17.0

func NewAutoDetectSourceLanguageConfigFromOpenRange() (*AutoDetectSourceLanguageConfig, error)

NewAutoDetectSourceLanguageConfigFromOpenRange creates an instance of the AutoDetectSourceLanguageConfig with open range as source languages

func (AutoDetectSourceLanguageConfig) Close

func (config AutoDetectSourceLanguageConfig) Close()

Close performs cleanup of resources.

type CancellationDetails added in v1.17.0

type CancellationDetails struct {
	Reason       common.CancellationReason
	ErrorCode    common.CancellationErrorCode
	ErrorDetails string
}

CancellationDetails contains detailed information about why a result was canceled. Added in version 1.17.0

func NewCancellationDetailsFromSpeechSynthesisResult added in v1.17.0

func NewCancellationDetailsFromSpeechSynthesisResult(result *SpeechSynthesisResult) (*CancellationDetails, error)

NewCancellationDetailsFromSpeechSynthesisResult creates the object from the speech synthesis result.

type KeywordRecognitionModel

type KeywordRecognitionModel struct {
	// contains filtered or unexported fields
}

KeywordRecognitionModel represents the keyword recognition model used with StartKeywordRecognitionAsync methods.

func NewKeywordRecognitionModelFromFile

func NewKeywordRecognitionModelFromFile(filename string) (*KeywordRecognitionModel, error)

/ NewKeywordRecognitionModelFromFile creates a keyword recognition model using the specified file.

func (KeywordRecognitionModel) Close

func (model KeywordRecognitionModel) Close()

Close disposes the associated resources.

func (KeywordRecognitionModel) GetHandle

func (model KeywordRecognitionModel) GetHandle() common.SPXHandle

GetHandle gets the handle to the resource (for internal use)

type RecognitionEventArgs

type RecognitionEventArgs struct {
	SessionEventArgs
	Offset uint64
}

RecognitionEventArgs represents the recognition event arguments.

func NewRecognitionEventArgsFromHandle

func NewRecognitionEventArgsFromHandle(handle common.SPXHandle) (*RecognitionEventArgs, error)

NewRecognitionEventArgsFromHandle creates the object from the handle (for internal use)

type RecognitionEventHandler

type RecognitionEventHandler func(event RecognitionEventArgs)

RecognitionEventHandler is the type of the event handler that receives RecognitionEventArgs

type SessionEventArgs

type SessionEventArgs struct {
	// SessionID Session identifier (a GUID in string format).
	SessionID string
}

SessionEventArgs represents the session event arguments.

func NewSessionEventArgsFromHandle

func NewSessionEventArgsFromHandle(handle common.SPXHandle) (*SessionEventArgs, error)

NewSessionEventArgsFromHandle creates the object from the handle (for internal use)

func (SessionEventArgs) Close

func (event SessionEventArgs) Close()

Close releases the underlying resources.

type SessionEventHandler

type SessionEventHandler func(event SessionEventArgs)

SessionEventHandler is the type of the event handler that receives SessionEventArgs

type SourceLanguageConfig

type SourceLanguageConfig struct {
	// contains filtered or unexported fields
}

SourceLanguageConfig defines source language configuration.

func NewSourceLanguageConfigFromLanguage

func NewSourceLanguageConfigFromLanguage(language string) (*SourceLanguageConfig, error)

NewSourceLanguageConfigFromLanguage creates an instance of the SourceLanguageConfig with source language

func NewSourceLanguageConfigFromLanguageAndEndpointId

func NewSourceLanguageConfigFromLanguageAndEndpointId(language string, endpointID string) (*SourceLanguageConfig, error)

NewSourceLanguageConfigFromLanguageAndEndpointId creates an instance of the SourceLanguageConfig with source language and custom endpoint id. A custom endpoint id corresponds to custom models.

func (SourceLanguageConfig) Close

func (config SourceLanguageConfig) Close()

Close performs cleanup of resources.

type SpeechConfig

type SpeechConfig struct {
	// contains filtered or unexported fields
}

SpeechConfig is the class that defines configurations for speech / intent recognition, or speech synthesis.

func NewSpeechConfigFromAuthorizationToken

func NewSpeechConfigFromAuthorizationToken(authorizationToken string, region string) (*SpeechConfig, error)

NewSpeechConfigFromAuthorizationToken creates an instance of the speech config with specified authorization token and region. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. For recognizers that have been created before, you need to set authorization token of the corresponding recognizer to refresh the token. Otherwise, the recognizers will encounter errors during recognition.

func NewSpeechConfigFromEndpoint

func NewSpeechConfigFromEndpoint(endpoint string) (*SpeechConfig, error)

NewSpeechConfigFromEndpoint creates an instance of SpeechConfig with specified endpoint. This method is intended only for users who use a non-standard service endpoint. Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. For example, if the recognition language is defined in URI as query parameter "language=de-DE", and also set by SetSpeechRecognitionLanguage("en-US"), the language setting in URI takes precedence, and the effective language is "de-DE". Only the parameters that are not specified in the endpoint URI can be set by other APIs. Note: If the endpoint requires a subscription key for authentication, use NewSpeechConfigFromEndpointWithSubscription to pass the subscription key as parameter. To use an authorization token with FromEndpoint, use this method to create a SpeechConfig instance, and then call SetAuthorizationToken() on the created SpeechConfig instance.

func NewSpeechConfigFromEndpointWithSubscription

func NewSpeechConfigFromEndpointWithSubscription(endpoint string, subscriptionKey string) (*SpeechConfig, error)

NewSpeechConfigFromEndpointWithSubscription creates an instance of the speech config with specified endpoint and subscription. This method is intended only for users who use a non-standard service endpoint. Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. For example, if the recognition language is defined in URI as query parameter "language=de-DE", and also set by SetSpeechRecognitionLanguage("en-US"), the language setting in URI takes precedence, and the effective language is "de-DE". / Only the parameters that are not specified in the endpoint URI can be set by other APIs. / Note: To use an authorization token with endoint, use FromEndpoint, / and then call SetAuthorizationToken() on the created SpeechConfig instance.

func NewSpeechConfigFromHandle

func NewSpeechConfigFromHandle(handle common.SPXHandle) (*SpeechConfig, error)

NewSpeechConfigFromHandle creates a SpeechConfig instance from a valid handle. This is for internal use only.

func NewSpeechConfigFromHost

func NewSpeechConfigFromHost(host string) (*SpeechConfig, error)

NewSpeechConfigFromHost Creates an instance of SpeechConfig with specified host. This method is intended only for users who use a non-default service host. Standard resource path will be assumed. For services with a non-standard resource path or no path at all, use FromEndpoint instead. Note: Query parameters are not allowed in the host URI and must be set by other APIs. Note: If the host requires a subscription key for authentication, use NewSpeechConfigFromHostWithSubscription to pass the subscription key as parameter. To use an authorization token with FromHost, use this method to create a SpeechConfig instance, and then call SetAuthorizationToken() on the created SpeechConfig instance.

func NewSpeechConfigFromHostWithSubscription

func NewSpeechConfigFromHostWithSubscription(host string, subscriptionKey string) (*SpeechConfig, error)

NewSpeechConfigFromHostWithSubscription creates an instance of the speech config with specified host and subscription. This method is intended only for users who use a non-default service host. Standard resource path will be assumed. For services with a non-standard resource path or no path at all, use FromEndpoint instead. Note: Query parameters are not allowed in the host URI and must be set by other APIs. Note: To use an authorization token with host, use NewSpeechConfigFromHost, and then call SetAuthorizationToken() on the created SpeechConfig instance.

func NewSpeechConfigFromSubscription

func NewSpeechConfigFromSubscription(subscriptionKey string, region string) (*SpeechConfig, error)

NewSpeechConfigFromSubscription creates an instance of the speech config with specified subscription key and region.

func (*SpeechConfig) AuthorizationToken

func (config *SpeechConfig) AuthorizationToken() string

AuthorizationToken is the authorization token to connect to the service.

func (*SpeechConfig) Close

func (config *SpeechConfig) Close()

Close disposes the associated resources.

func (*SpeechConfig) EnableAudioLogging

func (config *SpeechConfig) EnableAudioLogging() error

EnableAudioLogging enables audio logging in service.

func (*SpeechConfig) EnableDictation

func (config *SpeechConfig) EnableDictation() error

EnableDictation enables dictation mode. Only supported in speech continuous recognition.

func (*SpeechConfig) EndpointID

func (config *SpeechConfig) EndpointID() string

EndpointID is the endpoint ID

func (*SpeechConfig) GetProperty

func (config *SpeechConfig) GetProperty(id common.PropertyID) string

GetProperty gets a property value by ID.

func (*SpeechConfig) GetPropertyByString

func (config *SpeechConfig) GetPropertyByString(name string) string

GetPropertyByString gets a property value by string.

func (*SpeechConfig) OutputFormat

func (config *SpeechConfig) OutputFormat() common.OutputFormat

OutputFormat is result output format.

func (*SpeechConfig) Region

func (config *SpeechConfig) Region() string

Region is the region key that used to create Speech Recognizer or Intent Recognizer or Translation Recognizer or Speech Synthesizer.

func (*SpeechConfig) RequestWordLevelTimestamps

func (config *SpeechConfig) RequestWordLevelTimestamps() error

RequestWordLevelTimestamps includes word-level timestamps in response result.

func (*SpeechConfig) SetAuthorizationToken

func (config *SpeechConfig) SetAuthorizationToken(authToken string) error

SetAuthorizationToken sets the authorization token to connect to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. For recognizers that have been created before, you need to set authorization token of the corresponding recognizer to refresh the token. Otherwise, the recognizers will encounter errors during recognition.

func (*SpeechConfig) SetEndpointID

func (config *SpeechConfig) SetEndpointID(endpointID string) error

SetEndpointID sets the endpoint ID

func (*SpeechConfig) SetOutputFormat

func (config *SpeechConfig) SetOutputFormat(outputFormat common.OutputFormat) error

SetOutputFormat sets output format.

func (*SpeechConfig) SetProfanity

func (config *SpeechConfig) SetProfanity(profanity common.ProfanityOption) error

SetProfanity sets profanity option.

func (*SpeechConfig) SetProperty

func (config *SpeechConfig) SetProperty(id common.PropertyID, value string) error

SetProperty sets a property value by ID.

func (*SpeechConfig) SetPropertyByString

func (config *SpeechConfig) SetPropertyByString(name string, value string) error

SetPropertyByString sets a property value by string.

func (*SpeechConfig) SetProxy

func (config *SpeechConfig) SetProxy(hostname string, port uint64) error

SetProxy sets proxy configuration

Note: Proxy functionality is not available on macOS. This function will have no effect on this platform.

func (*SpeechConfig) SetProxyWithUsernameAndPassword

func (config *SpeechConfig) SetProxyWithUsernameAndPassword(hostname string, port uint64, username string, password string) error

SetProxyWithUsernameAndPassword sets proxy configuration with username and password

Note: Proxy functionality is not available on macOS. This function will have no effect on this platform.

func (*SpeechConfig) SetServiceProperty

func (config *SpeechConfig) SetServiceProperty(name string, value string, channel common.ServicePropertyChannel) error

SetServiceProperty sets a property value that will be passed to service using the specified channel.

func (*SpeechConfig) SetSpeechRecognitionLanguage

func (config *SpeechConfig) SetSpeechRecognitionLanguage(language string) error

SetSpeechRecognitionLanguage sets the input language to the speech recognizer.

func (*SpeechConfig) SetSpeechSynthesisLanguage

func (config *SpeechConfig) SetSpeechSynthesisLanguage(language string) error

SetSpeechSynthesisLanguage sets the language of the speech synthesizer.

func (*SpeechConfig) SetSpeechSynthesisOutputFormat

func (config *SpeechConfig) SetSpeechSynthesisOutputFormat(format common.SpeechSynthesisOutputFormat) error

SetSpeechSynthesisOutputFormat sets the speech synthesis output format (e.g. Riff16Khz16BitMonoPcm).

func (*SpeechConfig) SetSpeechSynthesisVoiceName

func (config *SpeechConfig) SetSpeechSynthesisVoiceName(voiceName string) error

SetSpeechSynthesisVoiceName sets the voice of the speech synthesizer.

func (*SpeechConfig) SpeechRecognitionLanguage

func (config *SpeechConfig) SpeechRecognitionLanguage() string

SpeechRecognitionLanguage is the input language to the speech recognition. The language is specified in BCP-47 format.

func (*SpeechConfig) SpeechSynthesisLanguage

func (config *SpeechConfig) SpeechSynthesisLanguage() string

SpeechSynthesisLanguage is the language of the speech synthesizer.

func (*SpeechConfig) SpeechSynthesisOutputFormat

func (config *SpeechConfig) SpeechSynthesisOutputFormat() string

SpeechSynthesisOutputFormat is the speech synthesis output format.

func (*SpeechConfig) SpeechSynthesisVoiceName

func (config *SpeechConfig) SpeechSynthesisVoiceName() string

SpeechSynthesisVoiceName is the voice of the speech synthesizer.

func (*SpeechConfig) SubscriptionKey

func (config *SpeechConfig) SubscriptionKey() string

SubscriptionKey is the subscription key that is used to create Speech Recognizer or Intent Recognizer or Translation Recognizer or Speech Synthesizer

type SpeechRecognitionCanceledEventArgs

type SpeechRecognitionCanceledEventArgs struct {
	SpeechRecognitionEventArgs
	Reason       common.CancellationReason
	ErrorCode    common.CancellationErrorCode
	ErrorDetails string
}

SpeechRecognitionCanceledEventArgs represents speech recognition canceled event arguments.

func NewSpeechRecognitionCanceledEventArgsFromHandle

func NewSpeechRecognitionCanceledEventArgsFromHandle(handle common.SPXHandle) (*SpeechRecognitionCanceledEventArgs, error)

NewSpeechRecognitionCanceledEventArgsFromHandle creates the object from the handle (for internal use)

type SpeechRecognitionCanceledEventHandler

type SpeechRecognitionCanceledEventHandler func(event SpeechRecognitionCanceledEventArgs)

SpeechRecognitionCanceledEventHandler is the type of the event handler that receives SpeechRecognitionCanceledEventArgs

type SpeechRecognitionEventArgs

type SpeechRecognitionEventArgs struct {
	RecognitionEventArgs

	Result SpeechRecognitionResult
	// contains filtered or unexported fields
}

SpeechRecognitionEventArgs represents the speech recognition event arguments.

func NewSpeechRecognitionEventArgsFromHandle

func NewSpeechRecognitionEventArgsFromHandle(handle common.SPXHandle) (*SpeechRecognitionEventArgs, error)

NewSpeechRecognitionEventArgsFromHandle creates the object from the handle (for internal use)

func (SpeechRecognitionEventArgs) Close

func (event SpeechRecognitionEventArgs) Close()

Close releases the underlying resources

type SpeechRecognitionEventHandler

type SpeechRecognitionEventHandler func(event SpeechRecognitionEventArgs)

SpeechRecognitionEventHandler is the type of the event handler that receives SpeechRecognitionEventArgs

type SpeechRecognitionOutcome

type SpeechRecognitionOutcome struct {
	common.OperationOutcome

	// Result is the result of the operation
	Result *SpeechRecognitionResult
}

SpeechRecognitionOutcome is a wrapper type to be returned by operations returning SpeechRecognitionResult and error

func (SpeechRecognitionOutcome) Close

func (outcome SpeechRecognitionOutcome) Close()

Close releases the underlying resources

type SpeechRecognitionResult

type SpeechRecognitionResult struct {

	// ResultID specifies the result identifier.
	ResultID string

	// Reason specifies status of speech recognition result.
	Reason common.ResultReason

	// Text presents the recognized text in the result.
	Text string

	// Duration of the recognized speech.
	Duration time.Duration

	// Offset of the recognized speech in ticks.
	Offset time.Duration

	// Collection of additional RecognitionResult properties.
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

SpeechRecognitionResult contains detailed information about result of a recognition operation.

func NewSpeechRecognitionResultFromHandle

func NewSpeechRecognitionResultFromHandle(handle common.SPXHandle) (*SpeechRecognitionResult, error)

NewSpeechRecognitionResultFromHandle creates a SpeechRecognitionResult from a handle (for internal use)

func (SpeechRecognitionResult) Close

func (result SpeechRecognitionResult) Close()

Close releases the underlying resources

type SpeechRecognizer

type SpeechRecognizer struct {
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

SpeechRecognizer is the class for speech recognizers.

func NewSpeechRecognizerFomAutoDetectSourceLangConfig

func NewSpeechRecognizerFomAutoDetectSourceLangConfig(config *SpeechConfig, langConfig *AutoDetectSourceLanguageConfig, audioConfig *audio.AudioConfig) (*SpeechRecognizer, error)

NewSpeechRecognizerFomAutoDetectSourceLangConfig creates a speech recognizer from a speech config, auto detection source language config and audio config

func NewSpeechRecognizerFromConfig

func NewSpeechRecognizerFromConfig(config *SpeechConfig, audioConfig *audio.AudioConfig) (*SpeechRecognizer, error)

NewSpeechRecognizerFromConfig creates a speech recognizer from a speech config and audio config.

func NewSpeechRecognizerFromSourceLanguage

func NewSpeechRecognizerFromSourceLanguage(config *SpeechConfig, sourceLanguage string, audioConfig *audio.AudioConfig) (*SpeechRecognizer, error)

NewSpeechRecognizerFromSourceLanguage creates a speech recognizer from a speech config, source language and audio config

func NewSpeechRecognizerFromSourceLanguageConfig

func NewSpeechRecognizerFromSourceLanguageConfig(config *SpeechConfig, sourceLanguageConfig *SourceLanguageConfig, audioConfig *audio.AudioConfig) (*SpeechRecognizer, error)

NewSpeechRecognizerFromSourceLanguageConfig creates a speech recognizer from a speech config, source language config and audio config

func (SpeechRecognizer) AuthorizationToken

func (recognizer SpeechRecognizer) AuthorizationToken() string

AuthorizationToken is the authorization token.

func (SpeechRecognizer) Canceled

func (recognizer SpeechRecognizer) Canceled(handler SpeechRecognitionCanceledEventHandler)

Canceled signals for events containing canceled recognition results (indicating a recognition attempt that was canceled as a result or a direct cancellation request or, alternatively, a transport or protocol failure).

func (SpeechRecognizer) Close

func (recognizer SpeechRecognizer) Close()

Close disposes the associated resources.

func (SpeechRecognizer) GetEndpointID

func (recognizer SpeechRecognizer) GetEndpointID() string

GetEndpointID gets the endpoint ID of a customized speech model that is used for speech recognition.

func (SpeechRecognizer) RecognizeOnceAsync

func (recognizer SpeechRecognizer) RecognizeOnceAsync() chan SpeechRecognitionOutcome

RecognizeOnceAsync starts speech recognition, and returns after a single utterance is recognized. The end of a single utterance is determined by listening for silence at the end or until a maximum of 15 seconds of audio is processed. The task returns the recognition text as result. Note: Since RecognizeOnceAsync() returns only a single utterance, it is suitable only for single shot recognition like command or query. For long-running multi-utterance recognition, use StartContinuousRecognitionAsync() instead.

func (SpeechRecognizer) Recognized

func (recognizer SpeechRecognizer) Recognized(handler SpeechRecognitionEventHandler)

Recognized signals for events containing final recognition results. (indicating a successful recognition attempt).

func (SpeechRecognizer) Recognizing

func (recognizer SpeechRecognizer) Recognizing(handler SpeechRecognitionEventHandler)

Recognizing signals for events containing intermediate recognition results.

func (SpeechRecognizer) SessionStarted

func (recognizer SpeechRecognizer) SessionStarted(handler SessionEventHandler)

SessionStarted signals events indicating the start of a recognition session (operation).

func (SpeechRecognizer) SessionStopped

func (recognizer SpeechRecognizer) SessionStopped(handler SessionEventHandler)

SessionStopped signals events indicating the end of a recognition session (operation).

func (SpeechRecognizer) SetAuthorizationToken

func (recognizer SpeechRecognizer) SetAuthorizationToken(token string) error

SetAuthorizationToken sets the authorization token that will be used for connecting to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will encounter errors during recognition.

func (SpeechRecognizer) SpeechEndDetected

func (recognizer SpeechRecognizer) SpeechEndDetected(handler RecognitionEventHandler)

SpeechEndDetected signals for events indicating the end of speech.

func (SpeechRecognizer) SpeechStartDetected

func (recognizer SpeechRecognizer) SpeechStartDetected(handler RecognitionEventHandler)

SpeechStartDetected signals for events indicating the start of speech.

func (SpeechRecognizer) StartContinuousRecognitionAsync

func (recognizer SpeechRecognizer) StartContinuousRecognitionAsync() chan error

StartContinuousRecognitionAsync asynchronously initiates continuous speech recognition operation.

func (SpeechRecognizer) StartKeywordRecognitionAsync

func (recognizer SpeechRecognizer) StartKeywordRecognitionAsync(model KeywordRecognitionModel) chan error

StartKeywordRecognitionAsync asynchronously initiates keyword recognition operation.

func (SpeechRecognizer) StopContinuousRecognitionAsync

func (recognizer SpeechRecognizer) StopContinuousRecognitionAsync() chan error

StopContinuousRecognitionAsync asynchronously terminates ongoing continuous speech recognition operation.

func (SpeechRecognizer) StopKeywordRecognitionAsync

func (recognizer SpeechRecognizer) StopKeywordRecognitionAsync() chan error

StopKeywordRecognitionAsync asynchronously terminates keyword recognition operation.

type SpeechSynthesisBookmarkEventArgs added in v1.17.0

type SpeechSynthesisBookmarkEventArgs struct {
	AudioOffset uint64
	Text        string
	// contains filtered or unexported fields
}

SpeechSynthesisBookmarkEventArgs represents the speech synthesis bookmark event arguments.

func NewSpeechSynthesisBookmarkEventArgsFromHandle added in v1.17.0

func NewSpeechSynthesisBookmarkEventArgsFromHandle(handle common.SPXHandle) (*SpeechSynthesisBookmarkEventArgs, error)

NewSpeechSynthesisBookmarkEventArgsFromHandle creates the object from the handle (for internal use)

func (SpeechSynthesisBookmarkEventArgs) Close added in v1.17.0

func (event SpeechSynthesisBookmarkEventArgs) Close()

Close releases the underlying resources

type SpeechSynthesisBookmarkEventHandler added in v1.17.0

type SpeechSynthesisBookmarkEventHandler func(event SpeechSynthesisBookmarkEventArgs)

SpeechSynthesisBookmarkEventHandler is the type of the event handler that receives SpeechSynthesisBookmarkEventArgs

type SpeechSynthesisEventArgs added in v1.17.0

type SpeechSynthesisEventArgs struct {
	Result SpeechSynthesisResult
	// contains filtered or unexported fields
}

SpeechSynthesisEventArgs represents the speech synthesis event arguments.

func NewSpeechSynthesisEventArgsFromHandle added in v1.17.0

func NewSpeechSynthesisEventArgsFromHandle(handle common.SPXHandle) (*SpeechSynthesisEventArgs, error)

NewSpeechSynthesisEventArgsFromHandle creates the object from the handle (for internal use)

func (SpeechSynthesisEventArgs) Close added in v1.17.0

func (event SpeechSynthesisEventArgs) Close()

Close releases the underlying resources

type SpeechSynthesisEventHandler added in v1.17.0

type SpeechSynthesisEventHandler func(event SpeechSynthesisEventArgs)

SpeechSynthesisEventHandler is the type of the event handler that receives SpeechSynthesisEventArgs

type SpeechSynthesisOutcome added in v1.17.0

type SpeechSynthesisOutcome struct {
	common.OperationOutcome

	// Result is the result of the operation
	Result *SpeechSynthesisResult
}

SpeechSynthesisOutcome is a wrapper type to be returned by operations returning SpeechSynthesisResult and error

func (SpeechSynthesisOutcome) Close added in v1.17.0

func (outcome SpeechSynthesisOutcome) Close()

Close releases the underlying resources

type SpeechSynthesisResult added in v1.17.0

type SpeechSynthesisResult struct {

	// ResultID specifies the result identifier.
	ResultID string

	// Reason specifies status of speech synthesis result.
	Reason common.ResultReason

	// AudioData presents the synthesized audio.
	AudioData []byte

	// Collection of additional synthesisResult properties.
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

SpeechSynthesisResult contains detailed information about result of a synthesis operation.

func NewSpeechSynthesisResultFromHandle added in v1.17.0

func NewSpeechSynthesisResultFromHandle(handle common.SPXHandle) (*SpeechSynthesisResult, error)

NewSpeechSynthesisResultFromHandle creates a SpeechSynthesisResult from a handle (for internal use)

func (SpeechSynthesisResult) Close added in v1.17.0

func (result SpeechSynthesisResult) Close()

Close releases the underlying resources

type SpeechSynthesisVisemeEventArgs added in v1.17.0

type SpeechSynthesisVisemeEventArgs struct {
	AudioOffset uint64
	VisemeID    uint
	Animation   string
	// contains filtered or unexported fields
}

SpeechSynthesisVisemeEventArgs represents the speech synthesis viseme event arguments.

func NewSpeechSynthesisVisemeEventArgsFromHandle added in v1.17.0

func NewSpeechSynthesisVisemeEventArgsFromHandle(handle common.SPXHandle) (*SpeechSynthesisVisemeEventArgs, error)

NewSpeechSynthesisVisemeEventArgsFromHandle creates the object from the handle (for internal use)

func (SpeechSynthesisVisemeEventArgs) Close added in v1.17.0

func (event SpeechSynthesisVisemeEventArgs) Close()

Close releases the underlying resources

type SpeechSynthesisVisemeEventHandler added in v1.17.0

type SpeechSynthesisVisemeEventHandler func(event SpeechSynthesisVisemeEventArgs)

SpeechSynthesisVisemeEventHandler is the type of the event handler that receives SpeechSynthesisVisemeEventArgs

type SpeechSynthesisVoicesOutcome added in v1.17.0

type SpeechSynthesisVoicesOutcome struct {
	common.OperationOutcome

	// Result is the result of the operation
	Result *SynthesisVoicesResult
}

SpeechSynthesisVoicesOutcome is a wrapper type to be returned by operations returning SynthesisVoicesResult and error

func (SpeechSynthesisVoicesOutcome) Close added in v1.17.0

func (outcome SpeechSynthesisVoicesOutcome) Close()

Close releases the underlying resources

type SpeechSynthesisWordBoundaryEventArgs added in v1.17.0

type SpeechSynthesisWordBoundaryEventArgs struct {
	AudioOffset uint64
	TextOffset  uint
	WordLength  uint
	// contains filtered or unexported fields
}

SpeechSynthesisWordBoundaryEventArgs represents the speech synthesis word boundary event arguments.

func NewSpeechSynthesisWordBoundaryEventArgsFromHandle added in v1.17.0

func NewSpeechSynthesisWordBoundaryEventArgsFromHandle(handle common.SPXHandle) (*SpeechSynthesisWordBoundaryEventArgs, error)

NewSpeechSynthesisWordBoundaryEventArgsFromHandle creates the object from the handle (for internal use)

func (SpeechSynthesisWordBoundaryEventArgs) Close added in v1.17.0

Close releases the underlying resources

type SpeechSynthesisWordBoundaryEventHandler added in v1.17.0

type SpeechSynthesisWordBoundaryEventHandler func(event SpeechSynthesisWordBoundaryEventArgs)

SpeechSynthesisWordBoundaryEventHandler is the type of the event handler that receives SpeechSynthesisWordBoundaryEventArgs

type SpeechSynthesizer added in v1.17.0

type SpeechSynthesizer struct {
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

SpeechSynthesizer is the class for speech synthesizer.

func NewSpeechSynthesizerFomAutoDetectSourceLangConfig added in v1.17.0

func NewSpeechSynthesizerFomAutoDetectSourceLangConfig(config *SpeechConfig, langConfig *AutoDetectSourceLanguageConfig, audioConfig *audio.AudioConfig) (*SpeechSynthesizer, error)

NewSpeechSynthesizerFomAutoDetectSourceLangConfig creates a speech synthesizer from a speech config, auto detection source language config and audio config

func NewSpeechSynthesizerFromConfig added in v1.17.0

func NewSpeechSynthesizerFromConfig(config *SpeechConfig, audioConfig *audio.AudioConfig) (*SpeechSynthesizer, error)

NewSpeechSynthesizerFromConfig creates a speech synthesizer from a speech config and audio config.

func (SpeechSynthesizer) AuthorizationToken added in v1.17.0

func (synthesizer SpeechSynthesizer) AuthorizationToken() string

AuthorizationToken is the authorization token.

func (SpeechSynthesizer) BookmarkReached added in v1.17.0

func (synthesizer SpeechSynthesizer) BookmarkReached(handler SpeechSynthesisBookmarkEventHandler)

BookmarkReached signals that a viseme event is received.

func (SpeechSynthesizer) Close added in v1.17.0

func (synthesizer SpeechSynthesizer) Close()

Close disposes the associated resources.

func (SpeechSynthesizer) GetVoicesAsync added in v1.17.0

func (synthesizer SpeechSynthesizer) GetVoicesAsync(locale string) chan SpeechSynthesisVoicesOutcome

GetVoicesAsync gets the available voices, asynchronously. The parameter locale specifies the locale of voices, in BCP-47 format; or leave it empty to get all available voices.

func (SpeechSynthesizer) SetAuthorizationToken added in v1.17.0

func (synthesizer SpeechSynthesizer) SetAuthorizationToken(token string) error

SetAuthorizationToken sets the authorization token that will be used for connecting to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the synthesizer will encounter errors during synthesizing.

func (SpeechSynthesizer) SpeakSsmlAsync added in v1.17.0

func (synthesizer SpeechSynthesizer) SpeakSsmlAsync(ssml string) chan SpeechSynthesisOutcome

SpeakSsmlAsync executes the speech synthesis on SSML, asynchronously.

func (SpeechSynthesizer) SpeakTextAsync added in v1.17.0

func (synthesizer SpeechSynthesizer) SpeakTextAsync(text string) chan SpeechSynthesisOutcome

SpeakTextAsync executes the speech synthesis on plain text, asynchronously.

func (SpeechSynthesizer) StartSpeakingSsmlAsync added in v1.17.0

func (synthesizer SpeechSynthesizer) StartSpeakingSsmlAsync(ssml string) chan SpeechSynthesisOutcome

StartSpeakingSsmlAsync starts the speech synthesis on SSML, asynchronously. It returns when the synthesis request is started to process (the result reason is SynthesizingAudioStarted).

func (SpeechSynthesizer) StartSpeakingTextAsync added in v1.17.0

func (synthesizer SpeechSynthesizer) StartSpeakingTextAsync(text string) chan SpeechSynthesisOutcome

StartSpeakingTextAsync starts the speech synthesis on plain text, asynchronously. It returns when the synthesis request is started to process (the result reason is SynthesizingAudioStarted).

func (SpeechSynthesizer) StopSpeakingAsync added in v1.17.0

func (synthesizer SpeechSynthesizer) StopSpeakingAsync() chan error

StopSpeakingAsync stops the speech synthesis, asynchronously. It stops audio speech synthesis and discards any unread data in audio.PullAudioOutputStream.

func (SpeechSynthesizer) SynthesisCanceled added in v1.17.0

func (synthesizer SpeechSynthesizer) SynthesisCanceled(handler SpeechSynthesisEventHandler)

SynthesisCanceled signals that a speech synthesis result is received when the synthesis is canceled.

func (SpeechSynthesizer) SynthesisCompleted added in v1.17.0

func (synthesizer SpeechSynthesizer) SynthesisCompleted(handler SpeechSynthesisEventHandler)

SynthesisCompleted signals events indicating synthesis is completed.

func (SpeechSynthesizer) SynthesisStarted added in v1.17.0

func (synthesizer SpeechSynthesizer) SynthesisStarted(handler SpeechSynthesisEventHandler)

SynthesisStarted signals events indicating the start of a synthesis

func (SpeechSynthesizer) Synthesizing added in v1.17.0

func (synthesizer SpeechSynthesizer) Synthesizing(handler SpeechSynthesisEventHandler)

Synthesizing signals events indicating audio chunk is received while the synthesis is on going.

func (SpeechSynthesizer) VisemeReceived added in v1.17.0

func (synthesizer SpeechSynthesizer) VisemeReceived(handler SpeechSynthesisVisemeEventHandler)

VisemeReceived signals that a viseme event is received.

func (SpeechSynthesizer) WordBoundary added in v1.17.0

func (synthesizer SpeechSynthesizer) WordBoundary(handler SpeechSynthesisWordBoundaryEventHandler)

WordBoundary signals that a word boundary event is received.

type SynthesisVoicesResult added in v1.17.0

type SynthesisVoicesResult struct {

	// Voices specifies all voices retrieved
	Voices []*VoiceInfo

	// ResultID specifies the result identifier.
	ResultID string

	// Reason specifies status of speech synthesis result.
	Reason common.ResultReason

	// ErrorDetails presents error details.
	ErrorDetails string

	// Collection of additional properties.
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

SynthesisVoicesResult contains information about result from voices list of speech synthesizers.

func NewSynthesisVoicesResultFromHandle added in v1.17.0

func NewSynthesisVoicesResultFromHandle(handle common.SPXHandle) (*SynthesisVoicesResult, error)

NewSynthesisVoicesResultFromHandle creates a SynthesisVoicesResult from a handle (for internal use)

func (SynthesisVoicesResult) Close added in v1.17.0

func (result SynthesisVoicesResult) Close()

Close releases the underlying resources

type VoiceInfo added in v1.17.0

type VoiceInfo struct {

	// Name specifies the voice name.
	Name string

	// Locale specifies the locale of the voice
	Locale string

	// ShortName specifies the voice name in short format
	ShortName string

	// LocalName specifies the local name of the voice
	LocalName string

	// Gender specifies the gender of the voice.
	Gender common.SynthesisVoiceGender

	// VoiceType specifies the voice type.
	VoiceType common.SynthesisVoiceType

	// StyleList specifies the styles the voice supports.
	StyleList []string

	// VoicePath specifies the voice path
	VoicePath string

	// Collection of additional properties.
	Properties common.PropertyCollection
	// contains filtered or unexported fields
}

VoiceInfo contains information about result from voices list of speech synthesizers.

func NewVoiceInfoFromHandle added in v1.17.0

func NewVoiceInfoFromHandle(handle common.SPXHandle) (*VoiceInfo, error)

NewVoiceInfoFromHandle creates a VoiceInfo from a handle (for internal use)

func (VoiceInfo) Close added in v1.17.0

func (result VoiceInfo) Close()

Close releases the underlying resources

Jump to

Keyboard shortcuts

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