speech

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 10 Imported by: 14

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 PhraseListGrammar added in v1.25.0

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

func NewPhraseListGrammarFromRecognizer added in v1.25.0

func NewPhraseListGrammarFromRecognizer(recognizer *SpeechRecognizer) (*PhraseListGrammar, error)

NewPhraseListGrammarFromRecognizer Creates a phrase list grammar for the specified recognizer.

func (*PhraseListGrammar) AddPhrase added in v1.25.0

func (grammar *PhraseListGrammar) AddPhrase(text string) error

AddPhrase adds a simple phrase that may be spoken by the user.

func (*PhraseListGrammar) Clear added in v1.25.0

func (grammar *PhraseListGrammar) Clear() error

Clears all phrases from the phrase list grammar.

func (*PhraseListGrammar) Close added in v1.25.0

func (grammar *PhraseListGrammar) Close()

Close releases the associated resources.

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
	// contains filtered or unexported fields
}

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) GetHandle added in v1.21.0

func (config SpeechConfig) GetHandle() common.SPXHandle

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

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 a phrase's worth 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 is the audio offset of the bookmark event, in ticks (100 nanoseconds).
	AudioOffset uint64

	// Text is the text of the bookmark.
	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

	// AudioDuration presents the time duration of synthesized audio.
	AudioDuration time.Duration

	// 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 is the audio offset of the viseme event, in ticks (100 nanoseconds).
	AudioOffset uint64

	// VisemeID is the viseme ID.
	VisemeID uint

	// Animation is the animation.
	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 is the audio offset of the word boundary event, in ticks (100 nanoseconds).
	AudioOffset uint64

	// Duration is the duration of the word boundary event.
	Duration time.Duration

	// TextOffset is the text offset.
	TextOffset uint

	// WordLength is the length of the word.
	WordLength uint

	// Text is the text.
	Text string

	// BoundaryType is the boundary type.
	BoundaryType common.SpeechSynthesisBoundaryType
	// 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 SpeechTranslationConfig added in v1.43.0

type SpeechTranslationConfig struct {
	SpeechConfig
}

SpeechTranslationConfig defines configurations for translation with speech input.

func NewSpeechTranslationConfigFromAuthorizationToken added in v1.43.0

func NewSpeechTranslationConfigFromAuthorizationToken(authToken string, region string) (*SpeechTranslationConfig, error)

NewSpeechTranslationConfigFromAuthorizationToken creates a speech translation config instance 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 NewSpeechTranslationConfigFromEndpoint added in v1.43.0

func NewSpeechTranslationConfigFromEndpoint(endpoint string) (*SpeechTranslationConfig, error)

NewSpeechTranslationConfigFromEndpoint creates a speech translation config instance 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.

func NewSpeechTranslationConfigFromEndpointWithSubscription added in v1.43.0

func NewSpeechTranslationConfigFromEndpointWithSubscription(endpoint string, subscription string) (*SpeechTranslationConfig, error)

NewSpeechTranslationConfigFromEndpointWithSubscription creates a speech translation config instance 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 NewSpeechTranslationConfigFromHost added in v1.43.0

func NewSpeechTranslationConfigFromHost(host string) (*SpeechTranslationConfig, error)

NewSpeechTranslationConfigFromHost creates a speech translation config instance 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: 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 NewSpeechTranslationConfigFromHostWithSubscription added in v1.43.0

func NewSpeechTranslationConfigFromHostWithSubscription(host string, subscription string) (*SpeechTranslationConfig, error)

NewSpeechTranslationConfigFromHostWithSubscription creates a speech translation config instance 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 NewSpeechTranslationConfigFromSubscription added in v1.43.0

func NewSpeechTranslationConfigFromSubscription(subscription string, region string) (*SpeechTranslationConfig, error)

NewSpeechTranslationConfigFromSubscription creates a speech translation config instance with specified subscription key and region.

func (*SpeechTranslationConfig) AddTargetLanguage added in v1.43.0

func (config *SpeechTranslationConfig) AddTargetLanguage(language string) error

AddTargetLanguage adds a target language for translation.

func (*SpeechTranslationConfig) GetTargetLanguages added in v1.43.0

func (config *SpeechTranslationConfig) GetTargetLanguages() []string

GetTargetLanguages gets target languages for translation.

func (*SpeechTranslationConfig) GetVoiceName added in v1.43.0

func (config *SpeechTranslationConfig) GetVoiceName() string

GetVoiceName gets output voice name.

func (*SpeechTranslationConfig) RemoveTargetLanguage added in v1.43.0

func (config *SpeechTranslationConfig) RemoveTargetLanguage(language string) error

RemoveTargetLanguage removes a target language for translation.

func (*SpeechTranslationConfig) SetCustomModelCategoryID added in v1.43.0

func (config *SpeechTranslationConfig) SetCustomModelCategoryID(categoryID string) error

SetCustomModelCategoryId sets a Category Id that will be passed to service. Category Id is used to find the custom model.

func (*SpeechTranslationConfig) SetVoiceName added in v1.43.0

func (config *SpeechTranslationConfig) SetVoiceName(voice string) error

SetVoiceName sets output voice name.

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 TranslationRecognitionCanceledEventArgs added in v1.43.0

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

TranslationRecognitionCanceledEventArgs represents the event arguments for a translation recognition canceled event.

func NewTranslationRecognitionCanceledEventArgsFromHandle added in v1.43.0

func NewTranslationRecognitionCanceledEventArgsFromHandle(handle common.SPXHandle) (*TranslationRecognitionCanceledEventArgs, error)

NewTranslationRecognitionCanceledEventArgsFromHandle creates a TranslationRecognitionCanceledEventArgs from a handle.

type TranslationRecognitionCanceledEventHandler added in v1.43.0

type TranslationRecognitionCanceledEventHandler func(event TranslationRecognitionCanceledEventArgs)

type TranslationRecognitionEventArgs added in v1.43.0

type TranslationRecognitionEventArgs struct {
	RecognitionEventArgs
	Result *TranslationRecognitionResult
}

TranslationRecognitionEventArgs represents the event arguments for a translation recognition event.

func NewTranslationRecognitionEventArgsFromHandle added in v1.43.0

func NewTranslationRecognitionEventArgsFromHandle(handle common.SPXHandle) (*TranslationRecognitionEventArgs, error)

NewTranslationRecognitionEventArgsFromHandle creates a TranslationRecognitionEventArgs from a handle.

type TranslationRecognitionEventHandler added in v1.43.0

type TranslationRecognitionEventHandler func(event TranslationRecognitionEventArgs)

Event handler types

type TranslationRecognitionOutcome added in v1.43.0

type TranslationRecognitionOutcome struct {
	Result *TranslationRecognitionResult
	common.OperationOutcome
}

TranslationRecognitionOutcome represents the outcome of a translation recognition operation.

type TranslationRecognitionResult added in v1.43.0

type TranslationRecognitionResult struct {
	SpeechRecognitionResult
	// contains filtered or unexported fields
}

TranslationRecognitionResult represents the result of a translation recognition.

func NewTranslationRecognitionResultFromHandle added in v1.43.0

func NewTranslationRecognitionResultFromHandle(handle common.SPXHandle) (*TranslationRecognitionResult, error)

NewTranslationRecognitionResultFromHandle creates a TranslationRecognitionResult from a handle.

func (TranslationRecognitionResult) GetTranslation added in v1.43.0

func (result TranslationRecognitionResult) GetTranslation(language string) string

GetTranslation returns the translation for the specified language.

func (TranslationRecognitionResult) GetTranslations added in v1.43.0

func (result TranslationRecognitionResult) GetTranslations() map[string]string

GetTranslations returns all available translations.

type TranslationRecognizer added in v1.43.0

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

TranslationRecognizer is the class for translation recognizers.

func NewTranslationRecognizerFromAutoDetectSourceLangConfig added in v1.43.0

func NewTranslationRecognizerFromAutoDetectSourceLangConfig(config *SpeechTranslationConfig, langConfig *AutoDetectSourceLanguageConfig, audioConfig *audio.AudioConfig) (*TranslationRecognizer, error)

NewTranslationRecognizerFromAutoDetectSourceLangConfig creates a translation recognizer from a speech translation config, auto detection source language config and audio config.

func NewTranslationRecognizerFromConfig added in v1.43.0

func NewTranslationRecognizerFromConfig(config *SpeechTranslationConfig, audioConfig *audio.AudioConfig) (*TranslationRecognizer, error)

NewTranslationRecognizerFromConfig creates a translation recognizer from a speech translation config and audio config.

func (TranslationRecognizer) AuthorizationToken added in v1.43.0

func (recognizer TranslationRecognizer) AuthorizationToken() string

AuthorizationToken is the authorization token.

func (TranslationRecognizer) Canceled added in v1.43.0

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 (TranslationRecognizer) Close added in v1.43.0

func (recognizer TranslationRecognizer) Close()

Close disposes the associated resources.

func (TranslationRecognizer) GetEndpointID added in v1.43.0

func (recognizer TranslationRecognizer) GetEndpointID() string

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

func (TranslationRecognizer) RecognizeOnceAsync added in v1.43.0

func (recognizer TranslationRecognizer) RecognizeOnceAsync() chan TranslationRecognitionOutcome

RecognizeOnceAsync starts translation 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 phrase's worth 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 (TranslationRecognizer) Recognized added in v1.43.0

func (recognizer TranslationRecognizer) Recognized(handler TranslationRecognitionEventHandler)

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

func (TranslationRecognizer) Recognizing added in v1.43.0

func (recognizer TranslationRecognizer) Recognizing(handler TranslationRecognitionEventHandler)

Recognizing signals for events containing intermediate recognition results.

func (TranslationRecognizer) SessionStarted added in v1.43.0

func (recognizer TranslationRecognizer) SessionStarted(handler SessionEventHandler)

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

func (TranslationRecognizer) SessionStopped added in v1.43.0

func (recognizer TranslationRecognizer) SessionStopped(handler SessionEventHandler)

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

func (TranslationRecognizer) SetAuthorizationToken added in v1.43.0

func (recognizer TranslationRecognizer) 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 (TranslationRecognizer) SpeechEndDetected added in v1.43.0

func (recognizer TranslationRecognizer) SpeechEndDetected(handler RecognitionEventHandler)

SpeechEndDetected signals for events indicating the end of speech.

func (TranslationRecognizer) SpeechStartDetected added in v1.43.0

func (recognizer TranslationRecognizer) SpeechStartDetected(handler RecognitionEventHandler)

SpeechStartDetected signals for events indicating the start of speech.

func (TranslationRecognizer) StartContinuousRecognitionAsync added in v1.43.0

func (recognizer TranslationRecognizer) StartContinuousRecognitionAsync() chan error

StartContinuousRecognitionAsync asynchronously initiates continuous translation recognition operation.

func (TranslationRecognizer) StopContinuousRecognitionAsync added in v1.43.0

func (recognizer TranslationRecognizer) StopContinuousRecognitionAsync() chan error

StopContinuousRecognitionAsync asynchronously terminates ongoing continuous translation recognition operation.

func (TranslationRecognizer) Synthesizing added in v1.43.0

func (recognizer TranslationRecognizer) Synthesizing(handler TranslationSynthesisEventHandler)

Synthesizing signals for events containing translation synthesis results.

type TranslationSynthesisEventArgs added in v1.43.0

type TranslationSynthesisEventArgs struct {
	SessionEventArgs
	Result *TranslationSynthesisResult
}

TranslationSynthesisEventArgs represents the event arguments for a translation synthesis event.

func NewTranslationSynthesisEventArgsFromHandle added in v1.43.0

func NewTranslationSynthesisEventArgsFromHandle(handle common.SPXHandle) (*TranslationSynthesisEventArgs, error)

NewTranslationSynthesisEventArgsFromHandle creates a TranslationSynthesisEventArgs from a handle.

type TranslationSynthesisEventHandler added in v1.43.0

type TranslationSynthesisEventHandler func(event TranslationSynthesisEventArgs)

type TranslationSynthesisResult added in v1.43.0

type TranslationSynthesisResult struct {
	Reason common.ResultReason
	// contains filtered or unexported fields
}

TranslationSynthesisResult represents the voice output of the translated text.

func NewTranslationSynthesisResultFromHandle added in v1.43.0

func NewTranslationSynthesisResultFromHandle(handle common.SPXHandle) (*TranslationSynthesisResult, error)

NewTranslationSynthesisResultFromHandle creates a TranslationSynthesisResult from a handle.

func (TranslationSynthesisResult) GetAudioData added in v1.43.0

func (result TranslationSynthesisResult) GetAudioData() []byte

GetAudioData returns the voice output of the translated text.

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