Documentation
¶
Overview ¶
Package speech provides Go bindings for the Speech framework.
Perform speech recognition on live or prerecorded audio, and receive transcriptions, alternative interpretations, and confidence levels of the results.
Use the Speech framework to recognize spoken words in recorded or live audio. The keyboard’s dictation support uses speech recognition to translate audio content into text. This framework provides a similar behavior, except that you can use it without the presence of the keyboard. For example, you might use speech recognition to recognize verbal commands or to handle text dictation in other parts of your app.
Essentials ¶
- Speech Recognition in Objective-C: Use these classes to perform speech recognition in Objective-C code. (SFSpeechRecognizer, SFSpeechRecognizerDelegate, SFSpeechRecognitionTaskHint, SFSpeechRecognizerAuthorizationStatus, SFSpeechURLRecognitionRequest)
Custom vocabulary ¶
- SFSpeechLanguageModel: A language model built from custom training data.
- SFSpeechLanguageModelConfiguration: An object describing the location of a custom language model and specialized vocabulary.//
Key Types ¶
- SFSpeechRecognizer - An object you use to check for the availability of the speech recognition service, and to initiate the speech recognition process.
- SFSpeechLanguageModelConfiguration - An object describing the location of a custom language model and specialized vocabulary.
- SFSpeechRecognitionRequest - An abstract class that represents a request to recognize speech from an audio source.
- SFSpeechRecognitionTask - A task object for monitoring the speech recognition progress.
- SFTranscriptionSegment - A discrete part of an entire transcription, as identified by the speech recognizer.
- SFSpeechRecognitionMetadata - The metadata of speech in the audio of a speech recognition request.
- SFSpeechAudioBufferRecognitionRequest - A request to recognize speech from captured audio content, such as audio from the device’s microphone.
- SFSpeechLanguageModel - A language model built from custom training data.
- SFSpeechRecognitionResult - An object that contains the partial or final results of a speech recognition request.
- SFVoiceAnalytics - A collection of vocal analysis metrics.
Code generated from Apple documentation. DO NOT EDIT.
Index ¶
- Variables
- func NewErrorBlock(handler ErrorHandler) (objc.ID, func())
- func NewSFSpeechRecognitionResultErrorBlock(handler SFSpeechRecognitionResultErrorHandler) (objc.ID, func())
- func NewSFSpeechRecognizerAuthorizationStatusBlock(handler SFSpeechRecognizerAuthorizationStatusHandler) (objc.ID, func())
- type ErrorHandler
- type ISFAcousticFeature
- type ISFSpeechAudioBufferRecognitionRequest
- type ISFSpeechLanguageModel
- type ISFSpeechLanguageModelConfiguration
- type ISFSpeechRecognitionMetadata
- type ISFSpeechRecognitionRequest
- type ISFSpeechRecognitionResult
- type ISFSpeechRecognitionTask
- type ISFSpeechRecognizer
- type ISFSpeechURLRecognitionRequest
- type ISFTranscription
- type ISFTranscriptionSegment
- type ISFVoiceAnalytics
- type SFAcousticFeature
- func (a SFAcousticFeature) AcousticFeatureValuePerFrame() float64
- func (a SFAcousticFeature) Autorelease() SFAcousticFeature
- func (a SFAcousticFeature) EncodeWithCoder(coder foundation.INSCoder)
- func (a SFAcousticFeature) FrameDuration() foundation.NSTimeInterval
- func (a SFAcousticFeature) Init() SFAcousticFeature
- func (a SFAcousticFeature) SetAcousticFeatureValuePerFrame(value float64)
- type SFAcousticFeatureClass
- type SFSpeechAudioBufferRecognitionRequest
- func (s SFSpeechAudioBufferRecognitionRequest) AppendAudioPCMBuffer(audioPCMBuffer avfaudio.AVAudioPCMBuffer)
- func (s SFSpeechAudioBufferRecognitionRequest) AppendAudioSampleBuffer(sampleBuffer coremedia.CMSampleBufferRef)
- func (s SFSpeechAudioBufferRecognitionRequest) Autorelease() SFSpeechAudioBufferRecognitionRequest
- func (s SFSpeechAudioBufferRecognitionRequest) EndAudio()
- func (s SFSpeechAudioBufferRecognitionRequest) Init() SFSpeechAudioBufferRecognitionRequest
- func (s SFSpeechAudioBufferRecognitionRequest) NativeAudioFormat() avfaudio.AVAudioFormat
- type SFSpeechAudioBufferRecognitionRequestClass
- type SFSpeechErrorCode
- type SFSpeechLanguageModel
- type SFSpeechLanguageModelClass
- func (sc SFSpeechLanguageModelClass) Alloc() SFSpeechLanguageModel
- func (sc SFSpeechLanguageModelClass) Class() objc.Class
- func (_SFSpeechLanguageModelClass SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationCompletion(asset foundation.NSURL, configuration ISFSpeechLanguageModelConfiguration, ...)
- func (sc SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationCompletionSync(ctx context.Context, asset foundation.NSURL, ...) error
- func (_SFSpeechLanguageModelClass SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion(asset foundation.NSURL, configuration ISFSpeechLanguageModelConfiguration, ...)
- func (sc SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletionSync(ctx context.Context, asset foundation.NSURL, ...) error
- type SFSpeechLanguageModelConfiguration
- func NewSFSpeechLanguageModelConfiguration() SFSpeechLanguageModelConfiguration
- func NewSpeechLanguageModelConfigurationWithLanguageModel(languageModel foundation.NSURL) SFSpeechLanguageModelConfiguration
- func NewSpeechLanguageModelConfigurationWithLanguageModelVocabulary(languageModel foundation.NSURL, vocabulary foundation.NSURL) SFSpeechLanguageModelConfiguration
- func NewSpeechLanguageModelConfigurationWithLanguageModelVocabularyWeight(languageModel foundation.NSURL, vocabulary foundation.NSURL, ...) SFSpeechLanguageModelConfiguration
- func SFSpeechLanguageModelConfigurationFromID(id objc.ID) SFSpeechLanguageModelConfiguration
- func (s SFSpeechLanguageModelConfiguration) Autorelease() SFSpeechLanguageModelConfiguration
- func (s SFSpeechLanguageModelConfiguration) EncodeWithCoder(coder foundation.INSCoder)
- func (s SFSpeechLanguageModelConfiguration) Init() SFSpeechLanguageModelConfiguration
- func (s SFSpeechLanguageModelConfiguration) InitWithLanguageModel(languageModel foundation.NSURL) SFSpeechLanguageModelConfiguration
- func (s SFSpeechLanguageModelConfiguration) InitWithLanguageModelVocabulary(languageModel foundation.NSURL, vocabulary foundation.NSURL) SFSpeechLanguageModelConfiguration
- func (s SFSpeechLanguageModelConfiguration) InitWithLanguageModelVocabularyWeight(languageModel foundation.NSURL, vocabulary foundation.NSURL, ...) SFSpeechLanguageModelConfiguration
- func (s SFSpeechLanguageModelConfiguration) LanguageModel() foundation.NSURL
- func (s SFSpeechLanguageModelConfiguration) Vocabulary() foundation.NSURL
- func (s SFSpeechLanguageModelConfiguration) Weight() foundation.NSNumber
- type SFSpeechLanguageModelConfigurationClass
- type SFSpeechRecognitionMetadata
- func (s SFSpeechRecognitionMetadata) Autorelease() SFSpeechRecognitionMetadata
- func (s SFSpeechRecognitionMetadata) AveragePauseDuration() foundation.NSTimeInterval
- func (s SFSpeechRecognitionMetadata) EncodeWithCoder(coder foundation.INSCoder)
- func (s SFSpeechRecognitionMetadata) Init() SFSpeechRecognitionMetadata
- func (s SFSpeechRecognitionMetadata) SpeakingRate() float64
- func (s SFSpeechRecognitionMetadata) SpeechDuration() foundation.NSTimeInterval
- func (s SFSpeechRecognitionMetadata) SpeechStartTimestamp() foundation.NSTimeInterval
- func (s SFSpeechRecognitionMetadata) VoiceAnalytics() ISFVoiceAnalytics
- type SFSpeechRecognitionMetadataClass
- type SFSpeechRecognitionRequest
- func (s SFSpeechRecognitionRequest) AddsPunctuation() bool
- func (s SFSpeechRecognitionRequest) Autorelease() SFSpeechRecognitionRequest
- func (s SFSpeechRecognitionRequest) ContextualStrings() []string
- func (s SFSpeechRecognitionRequest) CustomizedLanguageModel() ISFSpeechLanguageModelConfiguration
- func (s SFSpeechRecognitionRequest) Init() SFSpeechRecognitionRequest
- func (s SFSpeechRecognitionRequest) RequiresOnDeviceRecognition() bool
- func (s SFSpeechRecognitionRequest) SetAddsPunctuation(value bool)
- func (s SFSpeechRecognitionRequest) SetContextualStrings(value []string)
- func (s SFSpeechRecognitionRequest) SetCustomizedLanguageModel(value ISFSpeechLanguageModelConfiguration)
- func (s SFSpeechRecognitionRequest) SetRequiresOnDeviceRecognition(value bool)
- func (s SFSpeechRecognitionRequest) SetShouldReportPartialResults(value bool)
- func (s SFSpeechRecognitionRequest) SetTaskHint(value SFSpeechRecognitionTaskHint)
- func (s SFSpeechRecognitionRequest) ShouldReportPartialResults() bool
- func (s SFSpeechRecognitionRequest) TaskHint() SFSpeechRecognitionTaskHint
- type SFSpeechRecognitionRequestClass
- type SFSpeechRecognitionResult
- func (s SFSpeechRecognitionResult) Autorelease() SFSpeechRecognitionResult
- func (s SFSpeechRecognitionResult) BestTranscription() ISFTranscription
- func (s SFSpeechRecognitionResult) EncodeWithCoder(coder foundation.INSCoder)
- func (s SFSpeechRecognitionResult) Init() SFSpeechRecognitionResult
- func (s SFSpeechRecognitionResult) IsFinal() bool
- func (s SFSpeechRecognitionResult) SpeechRecognitionMetadata() ISFSpeechRecognitionMetadata
- func (s SFSpeechRecognitionResult) Transcriptions() []SFTranscription
- type SFSpeechRecognitionResultClass
- type SFSpeechRecognitionResultErrorHandler
- type SFSpeechRecognitionTask
- func (s SFSpeechRecognitionTask) Autorelease() SFSpeechRecognitionTask
- func (s SFSpeechRecognitionTask) Cancel()
- func (s SFSpeechRecognitionTask) Error() foundation.NSError
- func (s SFSpeechRecognitionTask) Finish()
- func (s SFSpeechRecognitionTask) Init() SFSpeechRecognitionTask
- func (s SFSpeechRecognitionTask) IsCancelled() bool
- func (s SFSpeechRecognitionTask) IsFinishing() bool
- func (s SFSpeechRecognitionTask) State() SFSpeechRecognitionTaskState
- type SFSpeechRecognitionTaskClass
- type SFSpeechRecognitionTaskDelegate
- type SFSpeechRecognitionTaskDelegateConfig
- type SFSpeechRecognitionTaskDelegateObject
- func (o SFSpeechRecognitionTaskDelegateObject) BaseObject() objectivec.Object
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionDidDetectSpeech(task ISFSpeechRecognitionTask)
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidFinishRecognition(task ISFSpeechRecognitionTask, recognitionResult ISFSpeechRecognitionResult)
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidFinishSuccessfully(task ISFSpeechRecognitionTask, successfully bool)
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidHypothesizeTranscription(task ISFSpeechRecognitionTask, transcription ISFTranscription)
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidProcessAudioDuration(task ISFSpeechRecognitionTask, duration foundation.NSTimeInterval)
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskFinishedReadingAudio(task ISFSpeechRecognitionTask)
- func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskWasCancelled(task ISFSpeechRecognitionTask)
- type SFSpeechRecognitionTaskHint
- type SFSpeechRecognitionTaskState
- type SFSpeechRecognizer
- func (s SFSpeechRecognizer) Autorelease() SFSpeechRecognizer
- func (s SFSpeechRecognizer) DefaultTaskHint() SFSpeechRecognitionTaskHint
- func (s SFSpeechRecognizer) Delegate() SFSpeechRecognizerDelegate
- func (s SFSpeechRecognizer) Init() SFSpeechRecognizer
- func (s SFSpeechRecognizer) InitWithLocale(locale foundation.NSLocale) SFSpeechRecognizer
- func (s SFSpeechRecognizer) IsAvailable() bool
- func (s SFSpeechRecognizer) Locale() foundation.NSLocale
- func (s SFSpeechRecognizer) Queue() foundation.OperationQueue
- func (s SFSpeechRecognizer) RecognitionTaskWithRequestDelegate(request ISFSpeechRecognitionRequest, delegate SFSpeechRecognitionTaskDelegate) ISFSpeechRecognitionTask
- func (s SFSpeechRecognizer) RecognitionTaskWithRequestResultHandler(request ISFSpeechRecognitionRequest, ...) ISFSpeechRecognitionTask
- func (s SFSpeechRecognizer) RecognitionTaskWithRequestResultHandlerSync(ctx context.Context, request ISFSpeechRecognitionRequest) (*SFSpeechRecognitionResult, error)
- func (s SFSpeechRecognizer) SetDefaultTaskHint(value SFSpeechRecognitionTaskHint)
- func (s SFSpeechRecognizer) SetDelegate(value SFSpeechRecognizerDelegate)
- func (s SFSpeechRecognizer) SetQueue(value foundation.OperationQueue)
- func (s SFSpeechRecognizer) SetSupportsOnDeviceRecognition(value bool)
- func (s SFSpeechRecognizer) SupportsOnDeviceRecognition() bool
- type SFSpeechRecognizerAuthorizationStatus
- type SFSpeechRecognizerAuthorizationStatusHandler
- type SFSpeechRecognizerClass
- func (sc SFSpeechRecognizerClass) Alloc() SFSpeechRecognizer
- func (_SFSpeechRecognizerClass SFSpeechRecognizerClass) AuthorizationStatus() SFSpeechRecognizerAuthorizationStatus
- func (sc SFSpeechRecognizerClass) Class() objc.Class
- func (_SFSpeechRecognizerClass SFSpeechRecognizerClass) RequestAuthorization(handler SFSpeechRecognizerAuthorizationStatusHandler)
- func (sc SFSpeechRecognizerClass) RequestAuthorizationSync(ctx context.Context) (SFSpeechRecognizerAuthorizationStatus, error)
- func (_SFSpeechRecognizerClass SFSpeechRecognizerClass) SupportedLocales() foundation.INSSet
- type SFSpeechRecognizerDelegate
- type SFSpeechRecognizerDelegateConfig
- type SFSpeechRecognizerDelegateObject
- type SFSpeechURLRecognitionRequest
- func (s SFSpeechURLRecognitionRequest) Autorelease() SFSpeechURLRecognitionRequest
- func (s SFSpeechURLRecognitionRequest) Init() SFSpeechURLRecognitionRequest
- func (s SFSpeechURLRecognitionRequest) InitWithURL(URL foundation.NSURL) SFSpeechURLRecognitionRequest
- func (s SFSpeechURLRecognitionRequest) URL() foundation.NSURL
- type SFSpeechURLRecognitionRequestClass
- type SFTranscription
- type SFTranscriptionClass
- type SFTranscriptionSegment
- func (t SFTranscriptionSegment) AlternativeSubstrings() []string
- func (t SFTranscriptionSegment) Autorelease() SFTranscriptionSegment
- func (t SFTranscriptionSegment) Confidence() float32
- func (t SFTranscriptionSegment) Duration() foundation.NSTimeInterval
- func (t SFTranscriptionSegment) EncodeWithCoder(coder foundation.INSCoder)
- func (t SFTranscriptionSegment) Init() SFTranscriptionSegment
- func (t SFTranscriptionSegment) Substring() string
- func (t SFTranscriptionSegment) SubstringRange() foundation.NSRange
- func (t SFTranscriptionSegment) Timestamp() foundation.NSTimeInterval
- type SFTranscriptionSegmentClass
- type SFVoiceAnalytics
- func (v SFVoiceAnalytics) Autorelease() SFVoiceAnalytics
- func (v SFVoiceAnalytics) EncodeWithCoder(coder foundation.INSCoder)
- func (v SFVoiceAnalytics) Init() SFVoiceAnalytics
- func (v SFVoiceAnalytics) Jitter() ISFAcousticFeature
- func (v SFVoiceAnalytics) Pitch() ISFAcousticFeature
- func (v SFVoiceAnalytics) Shimmer() ISFAcousticFeature
- func (v SFVoiceAnalytics) Voicing() ISFAcousticFeature
- type SFVoiceAnalyticsClass
Constants ¶
This section is empty.
Variables ¶
var ( // See: https://developer.apple.com/documentation/Speech/SFSpeechErrorDomain SFSpeechErrorDomain foundation.NSErrorDomain )
Functions ¶
func NewErrorBlock ¶
func NewErrorBlock(handler ErrorHandler) (objc.ID, func())
NewErrorBlock wraps a Go ErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.
Used by:
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlClientIdentifierConfigurationCompletion]
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlClientIdentifierConfigurationIgnoresCacheCompletion]
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlConfigurationCompletion]
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion]
func NewSFSpeechRecognitionResultErrorBlock ¶
func NewSFSpeechRecognitionResultErrorBlock(handler SFSpeechRecognitionResultErrorHandler) (objc.ID, func())
NewSFSpeechRecognitionResultErrorBlock wraps a Go SFSpeechRecognitionResultErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.
Used by:
func NewSFSpeechRecognizerAuthorizationStatusBlock ¶
func NewSFSpeechRecognizerAuthorizationStatusBlock(handler SFSpeechRecognizerAuthorizationStatusHandler) (objc.ID, func())
NewSFSpeechRecognizerAuthorizationStatusBlock wraps a Go SFSpeechRecognizerAuthorizationStatusHandler as an Objective-C block. The caller must defer the returned cleanup function.
Used by:
- [SFSpeechRecognizer.RequestAuthorization]
Types ¶
type ErrorHandler ¶
type ErrorHandler = func(error)
ErrorHandler handles Called when the language model has been created. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.
Used by:
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlClientIdentifierConfigurationCompletion]
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlClientIdentifierConfigurationIgnoresCacheCompletion]
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlConfigurationCompletion]
- [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion]
type ISFAcousticFeature ¶
type ISFAcousticFeature interface {
objectivec.IObject
// The duration of the audio frame.
FrameDuration() foundation.NSTimeInterval
// An array of feature values, one value per audio frame, corresponding to a transcript segment of recorded audio.
AcousticFeatureValuePerFrame() float64
SetAcousticFeatureValuePerFrame(value float64)
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFAcousticFeature class.
Inspecting a feature ¶
- [ISFAcousticFeature.FrameDuration]: The duration of the audio frame.
- [ISFAcousticFeature.AcousticFeatureValuePerFrame]: An array of feature values, one value per audio frame, corresponding to a transcript segment of recorded audio.
- [ISFAcousticFeature.SetAcousticFeatureValuePerFrame]
See: https://developer.apple.com/documentation/Speech/SFAcousticFeature
type ISFSpeechAudioBufferRecognitionRequest ¶
type ISFSpeechAudioBufferRecognitionRequest interface {
ISFSpeechRecognitionRequest
// Appends audio in the PCM format to the end of the recognition request.
AppendAudioPCMBuffer(audioPCMBuffer avfaudio.AVAudioPCMBuffer)
// Appends audio to the end of the recognition request.
AppendAudioSampleBuffer(sampleBuffer coremedia.CMSampleBufferRef)
// Marks the end of audio input for the recognition request.
EndAudio()
// The preferred audio format for optimal speech recognition.
NativeAudioFormat() avfaudio.AVAudioFormat
}
An interface definition for the SFSpeechAudioBufferRecognitionRequest class.
Appending Audio Buffers ¶
- [ISFSpeechAudioBufferRecognitionRequest.AppendAudioPCMBuffer]: Appends audio in the PCM format to the end of the recognition request.
- [ISFSpeechAudioBufferRecognitionRequest.AppendAudioSampleBuffer]: Appends audio to the end of the recognition request.
- [ISFSpeechAudioBufferRecognitionRequest.EndAudio]: Marks the end of audio input for the recognition request.
Getting the Audio Format ¶
- [ISFSpeechAudioBufferRecognitionRequest.NativeAudioFormat]: The preferred audio format for optimal speech recognition.
See: https://developer.apple.com/documentation/Speech/SFSpeechAudioBufferRecognitionRequest
type ISFSpeechLanguageModel ¶
type ISFSpeechLanguageModel interface {
objectivec.IObject
}
An interface definition for the SFSpeechLanguageModel class.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel
type ISFSpeechLanguageModelConfiguration ¶
type ISFSpeechLanguageModelConfiguration interface {
objectivec.IObject
// Creates a configuration with the location of a language model file.
InitWithLanguageModel(languageModel foundation.NSURL) SFSpeechLanguageModelConfiguration
// Creates a configuration with the locations of language model and vocabulary files.
InitWithLanguageModelVocabulary(languageModel foundation.NSURL, vocabulary foundation.NSURL) SFSpeechLanguageModelConfiguration
// Creates a configuration with the locations of language model and vocabulary files, and custom weight.
InitWithLanguageModelVocabularyWeight(languageModel foundation.NSURL, vocabulary foundation.NSURL, weight foundation.NSNumber) SFSpeechLanguageModelConfiguration
// The location of a compiled language model file.
LanguageModel() foundation.NSURL
// The location of a compiled vocabulary file.
Vocabulary() foundation.NSURL
// The relative weight of the language model customization. Value must be between 0.0 and 1.0 inclusive.
Weight() foundation.NSNumber
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFSpeechLanguageModelConfiguration class.
Creating a language model configuration ¶
- [ISFSpeechLanguageModelConfiguration.InitWithLanguageModel]: Creates a configuration with the location of a language model file.
- [ISFSpeechLanguageModelConfiguration.InitWithLanguageModelVocabulary]: Creates a configuration with the locations of language model and vocabulary files.
- [ISFSpeechLanguageModelConfiguration.InitWithLanguageModelVocabularyWeight]: Creates a configuration with the locations of language model and vocabulary files, and custom weight.
Inspecting a language model ¶
- [ISFSpeechLanguageModelConfiguration.LanguageModel]: The location of a compiled language model file.
- [ISFSpeechLanguageModelConfiguration.Vocabulary]: The location of a compiled vocabulary file.
- [ISFSpeechLanguageModelConfiguration.Weight]: The relative weight of the language model customization. Value must be between 0.0 and 1.0 inclusive.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel/Configuration
type ISFSpeechRecognitionMetadata ¶
type ISFSpeechRecognitionMetadata interface {
objectivec.IObject
// The average pause duration between words, measured in seconds.
AveragePauseDuration() foundation.NSTimeInterval
// The number of words spoken per minute.
SpeakingRate() float64
// The duration in seconds of speech in the audio.
SpeechDuration() foundation.NSTimeInterval
// The start timestamp of speech in the audio.
SpeechStartTimestamp() foundation.NSTimeInterval
// An analysis of the transcription segment’s vocal properties.
VoiceAnalytics() ISFVoiceAnalytics
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFSpeechRecognitionMetadata class.
Getting audio timing information ¶
- [ISFSpeechRecognitionMetadata.AveragePauseDuration]: The average pause duration between words, measured in seconds.
- [ISFSpeechRecognitionMetadata.SpeakingRate]: The number of words spoken per minute.
- [ISFSpeechRecognitionMetadata.SpeechDuration]: The duration in seconds of speech in the audio.
- [ISFSpeechRecognitionMetadata.SpeechStartTimestamp]: The start timestamp of speech in the audio.
Analyzing voice ¶
- [ISFSpeechRecognitionMetadata.VoiceAnalytics]: An analysis of the transcription segment’s vocal properties.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata
type ISFSpeechRecognitionRequest ¶
type ISFSpeechRecognitionRequest interface {
objectivec.IObject
// A Boolean value that determines whether a request must keep its audio data on the device.
RequiresOnDeviceRecognition() bool
SetRequiresOnDeviceRecognition(value bool)
// A Boolean value that indicates whether you want intermediate results returned for each utterance.
ShouldReportPartialResults() bool
SetShouldReportPartialResults(value bool)
// An array of phrases that should be recognized, even if they are not in the system vocabulary.
ContextualStrings() []string
SetContextualStrings(value []string)
// A value that indicates the type of speech recognition being performed.
TaskHint() SFSpeechRecognitionTaskHint
SetTaskHint(value SFSpeechRecognitionTaskHint)
// A Boolean value that indicates whether to add punctuation to speech recognition results.
AddsPunctuation() bool
SetAddsPunctuation(value bool)
CustomizedLanguageModel() ISFSpeechLanguageModelConfiguration
SetCustomizedLanguageModel(value ISFSpeechLanguageModelConfiguration)
}
An interface definition for the SFSpeechRecognitionRequest class.
Configuring a recognition request ¶
- [ISFSpeechRecognitionRequest.RequiresOnDeviceRecognition]: A Boolean value that determines whether a request must keep its audio data on the device.
- [ISFSpeechRecognitionRequest.SetRequiresOnDeviceRecognition]
- [ISFSpeechRecognitionRequest.ShouldReportPartialResults]: A Boolean value that indicates whether you want intermediate results returned for each utterance.
- [ISFSpeechRecognitionRequest.SetShouldReportPartialResults]
- [ISFSpeechRecognitionRequest.ContextualStrings]: An array of phrases that should be recognized, even if they are not in the system vocabulary.
- [ISFSpeechRecognitionRequest.SetContextualStrings]
Speech Type Classification ¶
- [ISFSpeechRecognitionRequest.TaskHint]: A value that indicates the type of speech recognition being performed.
- [ISFSpeechRecognitionRequest.SetTaskHint]
Punctuation ¶
- [ISFSpeechRecognitionRequest.AddsPunctuation]: A Boolean value that indicates whether to add punctuation to speech recognition results.
- [ISFSpeechRecognitionRequest.SetAddsPunctuation]
Instance Properties ¶
- [ISFSpeechRecognitionRequest.CustomizedLanguageModel]
- [ISFSpeechRecognitionRequest.SetCustomizedLanguageModel]
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionRequest
type ISFSpeechRecognitionResult ¶
type ISFSpeechRecognitionResult interface {
objectivec.IObject
// The transcription with the highest confidence level.
BestTranscription() ISFTranscription
// An array of potential transcriptions, sorted in descending order of confidence.
Transcriptions() []SFTranscription
// An object that contains the metadata results for a speech recognition request.
SpeechRecognitionMetadata() ISFSpeechRecognitionMetadata
// A Boolean value that indicates whether speech recognition is complete and whether the transcriptions are final.
IsFinal() bool
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFSpeechRecognitionResult class.
Getting transcriptions ¶
- [ISFSpeechRecognitionResult.BestTranscription]: The transcription with the highest confidence level.
- [ISFSpeechRecognitionResult.Transcriptions]: An array of potential transcriptions, sorted in descending order of confidence.
- [ISFSpeechRecognitionResult.SpeechRecognitionMetadata]: An object that contains the metadata results for a speech recognition request.
Determining whether transcriptions are final ¶
- [ISFSpeechRecognitionResult.IsFinal]: A Boolean value that indicates whether speech recognition is complete and whether the transcriptions are final.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionResult
type ISFSpeechRecognitionTask ¶
type ISFSpeechRecognitionTask interface {
objectivec.IObject
// Cancels the current speech recognition task.
Cancel()
// A Boolean value that indicates whether the speech recognition task was canceled.
IsCancelled() bool
// Stops accepting new audio and finishes processing on the audio input that has already been accepted.
Finish()
// A Boolean value that indicates whether audio input has stopped.
IsFinishing() bool
// The current state of the speech recognition task.
State() SFSpeechRecognitionTaskState
// An error object that specifies the error that occurred during a speech recognition task.
Error() foundation.NSError
}
An interface definition for the SFSpeechRecognitionTask class.
Canceling a speech recognition task ¶
- [ISFSpeechRecognitionTask.Cancel]: Cancels the current speech recognition task.
- [ISFSpeechRecognitionTask.IsCancelled]: A Boolean value that indicates whether the speech recognition task was canceled.
Finishing a speech recognition task ¶
- [ISFSpeechRecognitionTask.Finish]: Stops accepting new audio and finishes processing on the audio input that has already been accepted.
- [ISFSpeechRecognitionTask.IsFinishing]: A Boolean value that indicates whether audio input has stopped.
Monitoring recognition progress ¶
- [ISFSpeechRecognitionTask.State]: The current state of the speech recognition task.
- [ISFSpeechRecognitionTask.Error]: An error object that specifies the error that occurred during a speech recognition task.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask
type ISFSpeechRecognizer ¶
type ISFSpeechRecognizer interface {
objectivec.IObject
// Creates a speech recognizer associated with the specified locale.
InitWithLocale(locale foundation.NSLocale) SFSpeechRecognizer
// The delegate object that handles changes to the availability of speech recognition services.
Delegate() SFSpeechRecognizerDelegate
SetDelegate(value SFSpeechRecognizerDelegate)
// A Boolean value that indicates whether the speech recognizer is currently available.
IsAvailable() bool
// A Boolean value that indicates whether the speech recognizer can operate without network access.
SupportsOnDeviceRecognition() bool
SetSupportsOnDeviceRecognition(value bool)
// A hint that indicates the type of speech recognition being requested.
DefaultTaskHint() SFSpeechRecognitionTaskHint
SetDefaultTaskHint(value SFSpeechRecognitionTaskHint)
// The queue on which to execute recognition task handlers and delegate methods.
Queue() foundation.OperationQueue
SetQueue(value foundation.OperationQueue)
// Executes the speech recognition request and delivers the results to the specified handler block.
RecognitionTaskWithRequestResultHandler(request ISFSpeechRecognitionRequest, resultHandler SFSpeechRecognitionResultErrorHandler) ISFSpeechRecognitionTask
// Recognizes speech from the audio source associated with the specified request, using the specified delegate to manage the results.
RecognitionTaskWithRequestDelegate(request ISFSpeechRecognitionRequest, delegate SFSpeechRecognitionTaskDelegate) ISFSpeechRecognitionTask
// The locale of the speech recognizer.
Locale() foundation.NSLocale
}
An interface definition for the SFSpeechRecognizer class.
Creating a speech recognizer ¶
- [ISFSpeechRecognizer.InitWithLocale]: Creates a speech recognizer associated with the specified locale.
Monitoring speech recognition availability ¶
- [ISFSpeechRecognizer.Delegate]: The delegate object that handles changes to the availability of speech recognition services.
- [ISFSpeechRecognizer.SetDelegate]
- [ISFSpeechRecognizer.IsAvailable]: A Boolean value that indicates whether the speech recognizer is currently available.
- [ISFSpeechRecognizer.SupportsOnDeviceRecognition]: A Boolean value that indicates whether the speech recognizer can operate without network access.
- [ISFSpeechRecognizer.SetSupportsOnDeviceRecognition]
Configuring the speech recognizer ¶
- [ISFSpeechRecognizer.DefaultTaskHint]: A hint that indicates the type of speech recognition being requested.
- [ISFSpeechRecognizer.SetDefaultTaskHint]
- [ISFSpeechRecognizer.Queue]: The queue on which to execute recognition task handlers and delegate methods.
- [ISFSpeechRecognizer.SetQueue]
Performing speech recognition on audio ¶
- [ISFSpeechRecognizer.RecognitionTaskWithRequestResultHandler]: Executes the speech recognition request and delivers the results to the specified handler block.
- [ISFSpeechRecognizer.RecognitionTaskWithRequestDelegate]: Recognizes speech from the audio source associated with the specified request, using the specified delegate to manage the results.
Getting the current language ¶
- [ISFSpeechRecognizer.Locale]: The locale of the speech recognizer.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer
type ISFSpeechURLRecognitionRequest ¶
type ISFSpeechURLRecognitionRequest interface {
ISFSpeechRecognitionRequest
// Creates a speech recognition request, initialized with the specified URL.
InitWithURL(URL foundation.NSURL) SFSpeechURLRecognitionRequest
// The URL of the audio file.
URL() foundation.NSURL
}
An interface definition for the SFSpeechURLRecognitionRequest class.
Creating a speech recognition request ¶
- [ISFSpeechURLRecognitionRequest.InitWithURL]: Creates a speech recognition request, initialized with the specified URL.
Accessing the audio file URL ¶
- [ISFSpeechURLRecognitionRequest.URL]: The URL of the audio file.
See: https://developer.apple.com/documentation/Speech/SFSpeechURLRecognitionRequest
type ISFTranscription ¶
type ISFTranscription interface {
objectivec.IObject
// The entire transcription of utterances, formatted into a single, user-displayable string.
FormattedString() string
// An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.
Segments() []SFTranscriptionSegment
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFTranscription class.
Transcribing utterances ¶
- [ISFTranscription.FormattedString]: The entire transcription of utterances, formatted into a single, user-displayable string.
Getting individual utterances ¶
- [ISFTranscription.Segments]: An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.
See: https://developer.apple.com/documentation/Speech/SFTranscription
type ISFTranscriptionSegment ¶
type ISFTranscriptionSegment interface {
objectivec.IObject
// The string representation of the utterance in the transcription segment.
Substring() string
// The range information for the transcription segment’s substring, relative to the overall transcription.
SubstringRange() foundation.NSRange
// An array of alternate interpretations of the utterance in the transcription segment.
AlternativeSubstrings() []string
// The level of confidence the speech recognizer has in its recognition of the speech transcribed for the segment.
Confidence() float32
// The start time of the segment in the processed audio stream.
Timestamp() foundation.NSTimeInterval
// The number of seconds it took for the user to speak the utterance represented by the segment.
Duration() foundation.NSTimeInterval
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFTranscriptionSegment class.
Transcribing the segment ¶
- [ISFTranscriptionSegment.Substring]: The string representation of the utterance in the transcription segment.
- [ISFTranscriptionSegment.SubstringRange]: The range information for the transcription segment’s substring, relative to the overall transcription.
- [ISFTranscriptionSegment.AlternativeSubstrings]: An array of alternate interpretations of the utterance in the transcription segment.
Assessing the recognition confidence level ¶
- [ISFTranscriptionSegment.Confidence]: The level of confidence the speech recognizer has in its recognition of the speech transcribed for the segment.
Getting audio timing information ¶
- [ISFTranscriptionSegment.Timestamp]: The start time of the segment in the processed audio stream.
- [ISFTranscriptionSegment.Duration]: The number of seconds it took for the user to speak the utterance represented by the segment.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment
type ISFVoiceAnalytics ¶
type ISFVoiceAnalytics interface {
objectivec.IObject
// The likelihood of a voice in each frame of a transcription segment.
Voicing() ISFAcousticFeature
// The highness or lowness of the tone (fundamental frequency) in each frame of a transcription segment, expressed as a logarithm.
Pitch() ISFAcousticFeature
// The variation in pitch in each frame of a transcription segment, expressed as a percentage of the frame’s fundamental frequency.
Jitter() ISFAcousticFeature
// The variation in vocal volume stability (amplitude) in each frame of a transcription segment, expressed in decibels.
Shimmer() ISFAcousticFeature
EncodeWithCoder(coder foundation.INSCoder)
}
An interface definition for the SFVoiceAnalytics class.
Analyzing voice ¶
- [ISFVoiceAnalytics.Voicing]: The likelihood of a voice in each frame of a transcription segment.
- [ISFVoiceAnalytics.Pitch]: The highness or lowness of the tone (fundamental frequency) in each frame of a transcription segment, expressed as a logarithm.
- [ISFVoiceAnalytics.Jitter]: The variation in pitch in each frame of a transcription segment, expressed as a percentage of the frame’s fundamental frequency.
- [ISFVoiceAnalytics.Shimmer]: The variation in vocal volume stability (amplitude) in each frame of a transcription segment, expressed in decibels.
See: https://developer.apple.com/documentation/Speech/SFVoiceAnalytics
type SFAcousticFeature ¶
type SFAcousticFeature struct {
objectivec.Object
}
The value of a voice analysis metric.
Inspecting a feature ¶
- SFAcousticFeature.FrameDuration: The duration of the audio frame.
- SFAcousticFeature.AcousticFeatureValuePerFrame: An array of feature values, one value per audio frame, corresponding to a transcript segment of recorded audio.
- SFAcousticFeature.SetAcousticFeatureValuePerFrame
See: https://developer.apple.com/documentation/Speech/SFAcousticFeature
func NewSFAcousticFeature ¶
func NewSFAcousticFeature() SFAcousticFeature
NewSFAcousticFeature creates a new SFAcousticFeature instance.
func SFAcousticFeatureFromID ¶
func SFAcousticFeatureFromID(id objc.ID) SFAcousticFeature
SFAcousticFeatureFromID constructs a SFAcousticFeature from an objc.ID.
The value of a voice analysis metric.
func (SFAcousticFeature) AcousticFeatureValuePerFrame ¶
func (a SFAcousticFeature) AcousticFeatureValuePerFrame() float64
An array of feature values, one value per audio frame, corresponding to a transcript segment of recorded audio.
func (SFAcousticFeature) Autorelease ¶
func (a SFAcousticFeature) Autorelease() SFAcousticFeature
Autorelease adds the receiver to the current autorelease pool.
func (SFAcousticFeature) EncodeWithCoder ¶
func (a SFAcousticFeature) EncodeWithCoder(coder foundation.INSCoder)
func (SFAcousticFeature) FrameDuration ¶
func (a SFAcousticFeature) FrameDuration() foundation.NSTimeInterval
The duration of the audio frame.
See: https://developer.apple.com/documentation/Speech/SFAcousticFeature/frameDuration
func (SFAcousticFeature) Init ¶
func (a SFAcousticFeature) Init() SFAcousticFeature
Init initializes the instance.
func (SFAcousticFeature) SetAcousticFeatureValuePerFrame ¶
func (a SFAcousticFeature) SetAcousticFeatureValuePerFrame(value float64)
type SFAcousticFeatureClass ¶
type SFAcousticFeatureClass struct {
// contains filtered or unexported fields
}
func GetSFAcousticFeatureClass ¶
func GetSFAcousticFeatureClass() SFAcousticFeatureClass
GetSFAcousticFeatureClass returns the class object for SFAcousticFeature.
func (SFAcousticFeatureClass) Alloc ¶
func (sc SFAcousticFeatureClass) Alloc() SFAcousticFeature
Alloc allocates memory for a new instance of the class.
func (SFAcousticFeatureClass) Class ¶
func (sc SFAcousticFeatureClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechAudioBufferRecognitionRequest ¶
type SFSpeechAudioBufferRecognitionRequest struct {
SFSpeechRecognitionRequest
}
A request to recognize speech from captured audio content, such as audio from the device’s microphone.
Overview ¶
Use an SFSpeechAudioBufferRecognitionRequest object to perform speech recognition on live audio, or on a set of existing audio buffers. For example, use this request object to route audio from a device’s microphone to the speech recognizer.
The request object contains no audio initially. As you capture audio, call SFSpeechAudioBufferRecognitionRequest.AppendAudioPCMBuffer or SFSpeechAudioBufferRecognitionRequest.AppendAudioSampleBuffer to add audio samples to the request object. The speech recognizer continuously analyzes the audio you appended, stopping only when you call the SFSpeechAudioBufferRecognitionRequest.EndAudio method. You must call SFSpeechAudioBufferRecognitionRequest.EndAudio explicitly to stop the speech recognition process.
For a complete example of how to use audio buffers with speech recognition, see SpeakToMe: Using Speech Recognition with AVAudioEngine.
Appending Audio Buffers ¶
- SFSpeechAudioBufferRecognitionRequest.AppendAudioPCMBuffer: Appends audio in the PCM format to the end of the recognition request.
- SFSpeechAudioBufferRecognitionRequest.AppendAudioSampleBuffer: Appends audio to the end of the recognition request.
- SFSpeechAudioBufferRecognitionRequest.EndAudio: Marks the end of audio input for the recognition request.
Getting the Audio Format ¶
- SFSpeechAudioBufferRecognitionRequest.NativeAudioFormat: The preferred audio format for optimal speech recognition.
See: https://developer.apple.com/documentation/Speech/SFSpeechAudioBufferRecognitionRequest
func NewSFSpeechAudioBufferRecognitionRequest ¶
func NewSFSpeechAudioBufferRecognitionRequest() SFSpeechAudioBufferRecognitionRequest
NewSFSpeechAudioBufferRecognitionRequest creates a new SFSpeechAudioBufferRecognitionRequest instance.
func SFSpeechAudioBufferRecognitionRequestFromID ¶
func SFSpeechAudioBufferRecognitionRequestFromID(id objc.ID) SFSpeechAudioBufferRecognitionRequest
SFSpeechAudioBufferRecognitionRequestFromID constructs a SFSpeechAudioBufferRecognitionRequest from an objc.ID.
A request to recognize speech from captured audio content, such as audio from the device’s microphone.
func (SFSpeechAudioBufferRecognitionRequest) AppendAudioPCMBuffer ¶
func (s SFSpeechAudioBufferRecognitionRequest) AppendAudioPCMBuffer(audioPCMBuffer avfaudio.AVAudioPCMBuffer)
Appends audio in the PCM format to the end of the recognition request.
audioPCMBuffer: An audio buffer that contains audio in the PCM format.
Discussion ¶
The audio must be in a native format and uncompressed.
See: https://developer.apple.com/documentation/Speech/SFSpeechAudioBufferRecognitionRequest/append(_:)
func (SFSpeechAudioBufferRecognitionRequest) AppendAudioSampleBuffer ¶
func (s SFSpeechAudioBufferRecognitionRequest) AppendAudioSampleBuffer(sampleBuffer coremedia.CMSampleBufferRef)
Appends audio to the end of the recognition request.
sampleBuffer: A buffer of audio.
Discussion ¶
The audio must be in a native format.
func (SFSpeechAudioBufferRecognitionRequest) Autorelease ¶
func (s SFSpeechAudioBufferRecognitionRequest) Autorelease() SFSpeechAudioBufferRecognitionRequest
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechAudioBufferRecognitionRequest) EndAudio ¶
func (s SFSpeechAudioBufferRecognitionRequest) EndAudio()
Marks the end of audio input for the recognition request.
Discussion ¶
Call this method explicitly to let the speech recognizer know that no more audio input is coming.
See: https://developer.apple.com/documentation/Speech/SFSpeechAudioBufferRecognitionRequest/endAudio()
func (SFSpeechAudioBufferRecognitionRequest) NativeAudioFormat ¶
func (s SFSpeechAudioBufferRecognitionRequest) NativeAudioFormat() avfaudio.AVAudioFormat
The preferred audio format for optimal speech recognition.
Discussion ¶
Use the audio format in this property as a hint for optimal recording, but don’t depend on the value remaining unchanged.
type SFSpeechAudioBufferRecognitionRequestClass ¶
type SFSpeechAudioBufferRecognitionRequestClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechAudioBufferRecognitionRequestClass ¶
func GetSFSpeechAudioBufferRecognitionRequestClass() SFSpeechAudioBufferRecognitionRequestClass
GetSFSpeechAudioBufferRecognitionRequestClass returns the class object for SFSpeechAudioBufferRecognitionRequest.
func (SFSpeechAudioBufferRecognitionRequestClass) Alloc ¶
Alloc allocates memory for a new instance of the class.
func (SFSpeechAudioBufferRecognitionRequestClass) Class ¶
func (sc SFSpeechAudioBufferRecognitionRequestClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechErrorCode ¶
type SFSpeechErrorCode int
See: https://developer.apple.com/documentation/Speech/SFSpeechError/Code
const ( // SFSpeechErrorCodeAudioReadFailed: The audio file could not be read. SFSpeechErrorCodeAudioReadFailed SFSpeechErrorCode = 2 // SFSpeechErrorCodeInternalServiceError: There was an internal error. SFSpeechErrorCodeInternalServiceError SFSpeechErrorCode = 1 // SFSpeechErrorCodeMalformedSupplementalModel: The custom language model file was malformed. SFSpeechErrorCodeMalformedSupplementalModel SFSpeechErrorCode = 8 // SFSpeechErrorCodeMissingParameter: A required parameter is missing/nil. SFSpeechErrorCodeMissingParameter SFSpeechErrorCode = 13 // SFSpeechErrorCodeTimeout: The operation timed out. SFSpeechErrorCodeTimeout SFSpeechErrorCode = 12 // SFSpeechErrorCodeUndefinedTemplateClassName: The custom language model templates were malformed. SFSpeechErrorCodeUndefinedTemplateClassName SFSpeechErrorCode = 7 )
func (SFSpeechErrorCode) String ¶
func (e SFSpeechErrorCode) String() string
type SFSpeechLanguageModel ¶
type SFSpeechLanguageModel struct {
objectivec.Object
}
A language model built from custom training data.
Overview ¶
Create this object using SFSpeechLanguageModelClass.PrepareCustomLanguageModelForUrlConfigurationCompletion or SFSpeechLanguageModelClass.PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel
func NewSFSpeechLanguageModel ¶
func NewSFSpeechLanguageModel() SFSpeechLanguageModel
NewSFSpeechLanguageModel creates a new SFSpeechLanguageModel instance.
func SFSpeechLanguageModelFromID ¶
func SFSpeechLanguageModelFromID(id objc.ID) SFSpeechLanguageModel
SFSpeechLanguageModelFromID constructs a SFSpeechLanguageModel from an objc.ID.
A language model built from custom training data.
func (SFSpeechLanguageModel) Autorelease ¶
func (s SFSpeechLanguageModel) Autorelease() SFSpeechLanguageModel
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechLanguageModel) Init ¶
func (s SFSpeechLanguageModel) Init() SFSpeechLanguageModel
Init initializes the instance.
type SFSpeechLanguageModelClass ¶
type SFSpeechLanguageModelClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechLanguageModelClass ¶
func GetSFSpeechLanguageModelClass() SFSpeechLanguageModelClass
GetSFSpeechLanguageModelClass returns the class object for SFSpeechLanguageModel.
func (SFSpeechLanguageModelClass) Alloc ¶
func (sc SFSpeechLanguageModelClass) Alloc() SFSpeechLanguageModel
Alloc allocates memory for a new instance of the class.
func (SFSpeechLanguageModelClass) Class ¶
func (sc SFSpeechLanguageModelClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
func (SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationCompletion ¶
func (_SFSpeechLanguageModelClass SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationCompletion(asset foundation.NSURL, configuration ISFSpeechLanguageModelConfiguration, completion ErrorHandler)
Creates a language model from custom training data.
asset: The URL of a file containing custom training data. Create this file with export(to:).
configuration: An object listing the URLs at which this method should create the language model and compiled vocabulary from the training data.
completion: Called when the language model has been created.
func (SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationCompletionSync ¶
func (sc SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationCompletionSync(ctx context.Context, asset foundation.NSURL, configuration ISFSpeechLanguageModelConfiguration) error
PrepareCustomLanguageModelForUrlConfigurationCompletionSync is a synchronous wrapper around [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlConfigurationCompletion]. It blocks until the completion handler fires or the context is cancelled.
func (SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion ¶
func (_SFSpeechLanguageModelClass SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion(asset foundation.NSURL, configuration ISFSpeechLanguageModelConfiguration, ignoresCache bool, completion ErrorHandler)
Creates a language model from custom training data.
asset: The URL of a file containing custom training data. Create this file with export(to:).
configuration: An object listing the URLs at which this method should create the language model and compiled vocabulary from the training data.
ignoresCache: If `true`, the language model identified by the configuration will be recreated even if the `asset` file is unchanged.
completion: Called when the language model has been created.
func (SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletionSync ¶
func (sc SFSpeechLanguageModelClass) PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletionSync(ctx context.Context, asset foundation.NSURL, configuration ISFSpeechLanguageModelConfiguration, ignoresCache bool) error
PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletionSync is a synchronous wrapper around [SFSpeechLanguageModel.PrepareCustomLanguageModelForUrlConfigurationIgnoresCacheCompletion]. It blocks until the completion handler fires or the context is cancelled.
type SFSpeechLanguageModelConfiguration ¶
type SFSpeechLanguageModelConfiguration struct {
objectivec.Object
}
An object describing the location of a custom language model and specialized vocabulary.
Overview ¶
Pass this object to SFSpeechLanguageModelClass.PrepareCustomLanguageModelForUrlConfigurationCompletion to indicate where that method should create the custom language model file, and to SFSpeechRecognitionRequest.CustomizedLanguageModel or customizedLanguage(modelConfiguration:) to indicate where the system should find that model to use.
Creating a language model configuration ¶
- SFSpeechLanguageModelConfiguration.InitWithLanguageModel: Creates a configuration with the location of a language model file.
- SFSpeechLanguageModelConfiguration.InitWithLanguageModelVocabulary: Creates a configuration with the locations of language model and vocabulary files.
- SFSpeechLanguageModelConfiguration.InitWithLanguageModelVocabularyWeight: Creates a configuration with the locations of language model and vocabulary files, and custom weight.
Inspecting a language model ¶
- SFSpeechLanguageModelConfiguration.LanguageModel: The location of a compiled language model file.
- SFSpeechLanguageModelConfiguration.Vocabulary: The location of a compiled vocabulary file.
- SFSpeechLanguageModelConfiguration.Weight: The relative weight of the language model customization. Value must be between 0.0 and 1.0 inclusive.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel/Configuration
func NewSFSpeechLanguageModelConfiguration ¶
func NewSFSpeechLanguageModelConfiguration() SFSpeechLanguageModelConfiguration
NewSFSpeechLanguageModelConfiguration creates a new SFSpeechLanguageModelConfiguration instance.
func NewSpeechLanguageModelConfigurationWithLanguageModel ¶
func NewSpeechLanguageModelConfigurationWithLanguageModel(languageModel foundation.NSURL) SFSpeechLanguageModelConfiguration
Creates a configuration with the location of a language model file.
func NewSpeechLanguageModelConfigurationWithLanguageModelVocabulary ¶
func NewSpeechLanguageModelConfigurationWithLanguageModelVocabulary(languageModel foundation.NSURL, vocabulary foundation.NSURL) SFSpeechLanguageModelConfiguration
Creates a configuration with the locations of language model and vocabulary files.
func NewSpeechLanguageModelConfigurationWithLanguageModelVocabularyWeight ¶
func NewSpeechLanguageModelConfigurationWithLanguageModelVocabularyWeight(languageModel foundation.NSURL, vocabulary foundation.NSURL, weight foundation.NSNumber) SFSpeechLanguageModelConfiguration
Creates a configuration with the locations of language model and vocabulary files, and custom weight.
func SFSpeechLanguageModelConfigurationFromID ¶
func SFSpeechLanguageModelConfigurationFromID(id objc.ID) SFSpeechLanguageModelConfiguration
SFSpeechLanguageModelConfigurationFromID constructs a SFSpeechLanguageModelConfiguration from an objc.ID.
An object describing the location of a custom language model and specialized vocabulary.
func (SFSpeechLanguageModelConfiguration) Autorelease ¶
func (s SFSpeechLanguageModelConfiguration) Autorelease() SFSpeechLanguageModelConfiguration
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechLanguageModelConfiguration) EncodeWithCoder ¶
func (s SFSpeechLanguageModelConfiguration) EncodeWithCoder(coder foundation.INSCoder)
func (SFSpeechLanguageModelConfiguration) Init ¶
func (s SFSpeechLanguageModelConfiguration) Init() SFSpeechLanguageModelConfiguration
Init initializes the instance.
func (SFSpeechLanguageModelConfiguration) InitWithLanguageModel ¶
func (s SFSpeechLanguageModelConfiguration) InitWithLanguageModel(languageModel foundation.NSURL) SFSpeechLanguageModelConfiguration
Creates a configuration with the location of a language model file.
func (SFSpeechLanguageModelConfiguration) InitWithLanguageModelVocabulary ¶
func (s SFSpeechLanguageModelConfiguration) InitWithLanguageModelVocabulary(languageModel foundation.NSURL, vocabulary foundation.NSURL) SFSpeechLanguageModelConfiguration
Creates a configuration with the locations of language model and vocabulary files.
func (SFSpeechLanguageModelConfiguration) InitWithLanguageModelVocabularyWeight ¶
func (s SFSpeechLanguageModelConfiguration) InitWithLanguageModelVocabularyWeight(languageModel foundation.NSURL, vocabulary foundation.NSURL, weight foundation.NSNumber) SFSpeechLanguageModelConfiguration
Creates a configuration with the locations of language model and vocabulary files, and custom weight.
func (SFSpeechLanguageModelConfiguration) LanguageModel ¶
func (s SFSpeechLanguageModelConfiguration) LanguageModel() foundation.NSURL
The location of a compiled language model file.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel/Configuration/languageModel
func (SFSpeechLanguageModelConfiguration) Vocabulary ¶
func (s SFSpeechLanguageModelConfiguration) Vocabulary() foundation.NSURL
The location of a compiled vocabulary file.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel/Configuration/vocabulary
func (SFSpeechLanguageModelConfiguration) Weight ¶
func (s SFSpeechLanguageModelConfiguration) Weight() foundation.NSNumber
The relative weight of the language model customization. Value must be between 0.0 and 1.0 inclusive.
See: https://developer.apple.com/documentation/Speech/SFSpeechLanguageModel/Configuration/weight
type SFSpeechLanguageModelConfigurationClass ¶
type SFSpeechLanguageModelConfigurationClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechLanguageModelConfigurationClass ¶
func GetSFSpeechLanguageModelConfigurationClass() SFSpeechLanguageModelConfigurationClass
GetSFSpeechLanguageModelConfigurationClass returns the class object for SFSpeechLanguageModelConfiguration.
func (SFSpeechLanguageModelConfigurationClass) Alloc ¶
func (sc SFSpeechLanguageModelConfigurationClass) Alloc() SFSpeechLanguageModelConfiguration
Alloc allocates memory for a new instance of the class.
func (SFSpeechLanguageModelConfigurationClass) Class ¶
func (sc SFSpeechLanguageModelConfigurationClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechRecognitionMetadata ¶
type SFSpeechRecognitionMetadata struct {
objectivec.Object
}
The metadata of speech in the audio of a speech recognition request.
Getting audio timing information ¶
- SFSpeechRecognitionMetadata.AveragePauseDuration: The average pause duration between words, measured in seconds.
- SFSpeechRecognitionMetadata.SpeakingRate: The number of words spoken per minute.
- SFSpeechRecognitionMetadata.SpeechDuration: The duration in seconds of speech in the audio.
- SFSpeechRecognitionMetadata.SpeechStartTimestamp: The start timestamp of speech in the audio.
Analyzing voice ¶
- SFSpeechRecognitionMetadata.VoiceAnalytics: An analysis of the transcription segment’s vocal properties.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata
func NewSFSpeechRecognitionMetadata ¶
func NewSFSpeechRecognitionMetadata() SFSpeechRecognitionMetadata
NewSFSpeechRecognitionMetadata creates a new SFSpeechRecognitionMetadata instance.
func SFSpeechRecognitionMetadataFromID ¶
func SFSpeechRecognitionMetadataFromID(id objc.ID) SFSpeechRecognitionMetadata
SFSpeechRecognitionMetadataFromID constructs a SFSpeechRecognitionMetadata from an objc.ID.
The metadata of speech in the audio of a speech recognition request.
func (SFSpeechRecognitionMetadata) Autorelease ¶
func (s SFSpeechRecognitionMetadata) Autorelease() SFSpeechRecognitionMetadata
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechRecognitionMetadata) AveragePauseDuration ¶
func (s SFSpeechRecognitionMetadata) AveragePauseDuration() foundation.NSTimeInterval
The average pause duration between words, measured in seconds.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata/averagePauseDuration
func (SFSpeechRecognitionMetadata) EncodeWithCoder ¶
func (s SFSpeechRecognitionMetadata) EncodeWithCoder(coder foundation.INSCoder)
func (SFSpeechRecognitionMetadata) Init ¶
func (s SFSpeechRecognitionMetadata) Init() SFSpeechRecognitionMetadata
Init initializes the instance.
func (SFSpeechRecognitionMetadata) SpeakingRate ¶
func (s SFSpeechRecognitionMetadata) SpeakingRate() float64
The number of words spoken per minute.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata/speakingRate
func (SFSpeechRecognitionMetadata) SpeechDuration ¶
func (s SFSpeechRecognitionMetadata) SpeechDuration() foundation.NSTimeInterval
The duration in seconds of speech in the audio.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata/speechDuration
func (SFSpeechRecognitionMetadata) SpeechStartTimestamp ¶
func (s SFSpeechRecognitionMetadata) SpeechStartTimestamp() foundation.NSTimeInterval
The start timestamp of speech in the audio.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata/speechStartTimestamp
func (SFSpeechRecognitionMetadata) VoiceAnalytics ¶
func (s SFSpeechRecognitionMetadata) VoiceAnalytics() ISFVoiceAnalytics
An analysis of the transcription segment’s vocal properties.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionMetadata/voiceAnalytics
type SFSpeechRecognitionMetadataClass ¶
type SFSpeechRecognitionMetadataClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechRecognitionMetadataClass ¶
func GetSFSpeechRecognitionMetadataClass() SFSpeechRecognitionMetadataClass
GetSFSpeechRecognitionMetadataClass returns the class object for SFSpeechRecognitionMetadata.
func (SFSpeechRecognitionMetadataClass) Alloc ¶
func (sc SFSpeechRecognitionMetadataClass) Alloc() SFSpeechRecognitionMetadata
Alloc allocates memory for a new instance of the class.
func (SFSpeechRecognitionMetadataClass) Class ¶
func (sc SFSpeechRecognitionMetadataClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechRecognitionRequest ¶
type SFSpeechRecognitionRequest struct {
objectivec.Object
}
An abstract class that represents a request to recognize speech from an audio source.
Overview ¶
Don’t create SFSpeechRecognitionRequest objects directly. Create an SFSpeechURLRecognitionRequest or SFSpeechAudioBufferRecognitionRequest object instead. Use the properties of this class to configure various aspects of your request object before you start the speech recognition process. For example, use the SFSpeechRecognitionRequest.ShouldReportPartialResults property to specify whether you want partial results or only the final result of speech recognition.
Configuring a recognition request ¶
- SFSpeechRecognitionRequest.RequiresOnDeviceRecognition: A Boolean value that determines whether a request must keep its audio data on the device.
- SFSpeechRecognitionRequest.SetRequiresOnDeviceRecognition
- SFSpeechRecognitionRequest.ShouldReportPartialResults: A Boolean value that indicates whether you want intermediate results returned for each utterance.
- SFSpeechRecognitionRequest.SetShouldReportPartialResults
- SFSpeechRecognitionRequest.ContextualStrings: An array of phrases that should be recognized, even if they are not in the system vocabulary.
- SFSpeechRecognitionRequest.SetContextualStrings
Speech Type Classification ¶
- SFSpeechRecognitionRequest.TaskHint: A value that indicates the type of speech recognition being performed.
- SFSpeechRecognitionRequest.SetTaskHint
Punctuation ¶
- SFSpeechRecognitionRequest.AddsPunctuation: A Boolean value that indicates whether to add punctuation to speech recognition results.
- SFSpeechRecognitionRequest.SetAddsPunctuation
Instance Properties ¶
- SFSpeechRecognitionRequest.CustomizedLanguageModel
- SFSpeechRecognitionRequest.SetCustomizedLanguageModel
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionRequest
func NewSFSpeechRecognitionRequest ¶
func NewSFSpeechRecognitionRequest() SFSpeechRecognitionRequest
NewSFSpeechRecognitionRequest creates a new SFSpeechRecognitionRequest instance.
func SFSpeechRecognitionRequestFromID ¶
func SFSpeechRecognitionRequestFromID(id objc.ID) SFSpeechRecognitionRequest
SFSpeechRecognitionRequestFromID constructs a SFSpeechRecognitionRequest from an objc.ID.
An abstract class that represents a request to recognize speech from an audio source.
func (SFSpeechRecognitionRequest) AddsPunctuation ¶
func (s SFSpeechRecognitionRequest) AddsPunctuation() bool
A Boolean value that indicates whether to add punctuation to speech recognition results.
Discussion ¶
Set this property to `true` for the speech framework to automatically include punctuation in the recognition results. Punctuation includes a period or question mark at the end of a sentence, and a comma within a sentence.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionRequest/addsPunctuation
func (SFSpeechRecognitionRequest) Autorelease ¶
func (s SFSpeechRecognitionRequest) Autorelease() SFSpeechRecognitionRequest
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechRecognitionRequest) ContextualStrings ¶
func (s SFSpeechRecognitionRequest) ContextualStrings() []string
An array of phrases that should be recognized, even if they are not in the system vocabulary.
Discussion ¶
Use this property to specify short custom phrases that are unique to your app. You might include phrases with the names of characters, products, or places that are specific to your app. You might also include domain-specific terminology or unusual or made-up words. Assigning custom phrases to this property improves the likelihood of those phrases being recognized.
Keep phrases relatively brief, limiting them to one or two words whenever possible. Lengthy phrases are less likely to be recognized. In addition, try to limit each phrase to something the user can say without pausing.
Limit the total number of phrases to no more than 100.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionRequest/contextualStrings
func (SFSpeechRecognitionRequest) CustomizedLanguageModel ¶
func (s SFSpeechRecognitionRequest) CustomizedLanguageModel() ISFSpeechLanguageModelConfiguration
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionRequest/customizedLanguageModel
func (SFSpeechRecognitionRequest) Init ¶
func (s SFSpeechRecognitionRequest) Init() SFSpeechRecognitionRequest
Init initializes the instance.
func (SFSpeechRecognitionRequest) RequiresOnDeviceRecognition ¶
func (s SFSpeechRecognitionRequest) RequiresOnDeviceRecognition() bool
A Boolean value that determines whether a request must keep its audio data on the device.
Discussion ¶
Set this property to `true` to prevent an SFSpeechRecognitionRequest from sending audio over the network. However, on-device requests won’t be as accurate.
func (SFSpeechRecognitionRequest) SetAddsPunctuation ¶
func (s SFSpeechRecognitionRequest) SetAddsPunctuation(value bool)
func (SFSpeechRecognitionRequest) SetContextualStrings ¶
func (s SFSpeechRecognitionRequest) SetContextualStrings(value []string)
func (SFSpeechRecognitionRequest) SetCustomizedLanguageModel ¶
func (s SFSpeechRecognitionRequest) SetCustomizedLanguageModel(value ISFSpeechLanguageModelConfiguration)
func (SFSpeechRecognitionRequest) SetRequiresOnDeviceRecognition ¶
func (s SFSpeechRecognitionRequest) SetRequiresOnDeviceRecognition(value bool)
func (SFSpeechRecognitionRequest) SetShouldReportPartialResults ¶
func (s SFSpeechRecognitionRequest) SetShouldReportPartialResults(value bool)
func (SFSpeechRecognitionRequest) SetTaskHint ¶
func (s SFSpeechRecognitionRequest) SetTaskHint(value SFSpeechRecognitionTaskHint)
func (SFSpeechRecognitionRequest) ShouldReportPartialResults ¶
func (s SFSpeechRecognitionRequest) ShouldReportPartialResults() bool
A Boolean value that indicates whether you want intermediate results returned for each utterance.
Discussion ¶
The default value of this property is `true`. If you want only final results (and you don’t care about intermediate results), set this property to `false` to prevent the system from doing extra work.
func (SFSpeechRecognitionRequest) TaskHint ¶
func (s SFSpeechRecognitionRequest) TaskHint() SFSpeechRecognitionTaskHint
A value that indicates the type of speech recognition being performed.
Discussion ¶
The default value of this property is SFSpeechRecognitionTaskHint.unspecified. For a valid list of values, see SFSpeechRecognitionTaskHint.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionRequest/taskHint
type SFSpeechRecognitionRequestClass ¶
type SFSpeechRecognitionRequestClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechRecognitionRequestClass ¶
func GetSFSpeechRecognitionRequestClass() SFSpeechRecognitionRequestClass
GetSFSpeechRecognitionRequestClass returns the class object for SFSpeechRecognitionRequest.
func (SFSpeechRecognitionRequestClass) Alloc ¶
func (sc SFSpeechRecognitionRequestClass) Alloc() SFSpeechRecognitionRequest
Alloc allocates memory for a new instance of the class.
func (SFSpeechRecognitionRequestClass) Class ¶
func (sc SFSpeechRecognitionRequestClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechRecognitionResult ¶
type SFSpeechRecognitionResult struct {
objectivec.Object
}
An object that contains the partial or final results of a speech recognition request.
Overview ¶
Use an SFSpeechRecognitionResult object to retrieve the results of a speech recognition request. You don’t create these objects directly. Instead, the Speech framework creates them and passes them to the handler block or delegate object you specified when starting your speech recognition task.
A speech recognition result object contains one or more SFSpeechRecognitionResult.Transcriptions of the current utterance. Each transcription has a confidence rating indicating how likely it is to be correct. You can also get the transcription with the highest rating directly from the SFSpeechRecognitionResult.BestTranscription property.
If you requested partial results from the speech recognizer, the transcriptions may represent only part of the total audio content. Use the [SFSpeechRecognitionResult.Final] property to determine if the request contains partial or final results.
Getting transcriptions ¶
- SFSpeechRecognitionResult.BestTranscription: The transcription with the highest confidence level.
- SFSpeechRecognitionResult.Transcriptions: An array of potential transcriptions, sorted in descending order of confidence.
- SFSpeechRecognitionResult.SpeechRecognitionMetadata: An object that contains the metadata results for a speech recognition request.
Determining whether transcriptions are final ¶
- SFSpeechRecognitionResult.IsFinal: A Boolean value that indicates whether speech recognition is complete and whether the transcriptions are final.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionResult
func NewSFSpeechRecognitionResult ¶
func NewSFSpeechRecognitionResult() SFSpeechRecognitionResult
NewSFSpeechRecognitionResult creates a new SFSpeechRecognitionResult instance.
func SFSpeechRecognitionResultFromID ¶
func SFSpeechRecognitionResultFromID(id objc.ID) SFSpeechRecognitionResult
SFSpeechRecognitionResultFromID constructs a SFSpeechRecognitionResult from an objc.ID.
An object that contains the partial or final results of a speech recognition request.
func (SFSpeechRecognitionResult) Autorelease ¶
func (s SFSpeechRecognitionResult) Autorelease() SFSpeechRecognitionResult
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechRecognitionResult) BestTranscription ¶
func (s SFSpeechRecognitionResult) BestTranscription() ISFTranscription
The transcription with the highest confidence level.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionResult/bestTranscription
func (SFSpeechRecognitionResult) EncodeWithCoder ¶
func (s SFSpeechRecognitionResult) EncodeWithCoder(coder foundation.INSCoder)
func (SFSpeechRecognitionResult) Init ¶
func (s SFSpeechRecognitionResult) Init() SFSpeechRecognitionResult
Init initializes the instance.
func (SFSpeechRecognitionResult) IsFinal ¶
func (s SFSpeechRecognitionResult) IsFinal() bool
A Boolean value that indicates whether speech recognition is complete and whether the transcriptions are final.
Discussion ¶
When a speech recognition request is final, its transcriptions don’t change.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionResult/isFinal
func (SFSpeechRecognitionResult) SpeechRecognitionMetadata ¶
func (s SFSpeechRecognitionResult) SpeechRecognitionMetadata() ISFSpeechRecognitionMetadata
An object that contains the metadata results for a speech recognition request.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionResult/speechRecognitionMetadata
func (SFSpeechRecognitionResult) Transcriptions ¶
func (s SFSpeechRecognitionResult) Transcriptions() []SFTranscription
An array of potential transcriptions, sorted in descending order of confidence.
Discussion ¶
All transcriptions correspond to the same utterance, which can be a partial or final result of the overall request. The first transcription in the array has the highest confidence rating, followed by transcriptions with decreasing confidence ratings.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionResult/transcriptions
type SFSpeechRecognitionResultClass ¶
type SFSpeechRecognitionResultClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechRecognitionResultClass ¶
func GetSFSpeechRecognitionResultClass() SFSpeechRecognitionResultClass
GetSFSpeechRecognitionResultClass returns the class object for SFSpeechRecognitionResult.
func (SFSpeechRecognitionResultClass) Alloc ¶
func (sc SFSpeechRecognitionResultClass) Alloc() SFSpeechRecognitionResult
Alloc allocates memory for a new instance of the class.
func (SFSpeechRecognitionResultClass) Class ¶
func (sc SFSpeechRecognitionResultClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechRecognitionResultErrorHandler ¶
type SFSpeechRecognitionResultErrorHandler = func(*SFSpeechRecognitionResult, error)
SFSpeechRecognitionResultErrorHandler handles The block to call when partial or final results are available, or when an error occurs.
- result: A SFSpeechRecognitionResult(<doc://com.apple.speech/documentation/Speech/SFSpeechRecognitionResult>) containing the partial or final transcriptions of the audio content.
- error: An error object if a problem occurred. This parameter is `nil` if speech recognition was successful.
The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.
Used by:
type SFSpeechRecognitionTask ¶
type SFSpeechRecognitionTask struct {
objectivec.Object
}
A task object for monitoring the speech recognition progress.
Overview ¶
Use an SFSpeechRecognitionTask object to determine the state of a speech recognition task, to cancel an ongoing task, or to signal the end of the task.
You don’t create speech recognition task objects directly. Instead, you receive one of these objects after calling SFSpeechRecognizer.RecognitionTaskWithRequestResultHandler or SFSpeechRecognizer.RecognitionTaskWithRequestDelegate on your SFSpeechRecognizer object.
Canceling a speech recognition task ¶
- SFSpeechRecognitionTask.Cancel: Cancels the current speech recognition task.
- SFSpeechRecognitionTask.IsCancelled: A Boolean value that indicates whether the speech recognition task was canceled.
Finishing a speech recognition task ¶
- SFSpeechRecognitionTask.Finish: Stops accepting new audio and finishes processing on the audio input that has already been accepted.
- SFSpeechRecognitionTask.IsFinishing: A Boolean value that indicates whether audio input has stopped.
Monitoring recognition progress ¶
- SFSpeechRecognitionTask.State: The current state of the speech recognition task.
- SFSpeechRecognitionTask.Error: An error object that specifies the error that occurred during a speech recognition task.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask
func NewSFSpeechRecognitionTask ¶
func NewSFSpeechRecognitionTask() SFSpeechRecognitionTask
NewSFSpeechRecognitionTask creates a new SFSpeechRecognitionTask instance.
func SFSpeechRecognitionTaskFromID ¶
func SFSpeechRecognitionTaskFromID(id objc.ID) SFSpeechRecognitionTask
SFSpeechRecognitionTaskFromID constructs a SFSpeechRecognitionTask from an objc.ID.
A task object for monitoring the speech recognition progress.
func (SFSpeechRecognitionTask) Autorelease ¶
func (s SFSpeechRecognitionTask) Autorelease() SFSpeechRecognitionTask
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechRecognitionTask) Cancel ¶
func (s SFSpeechRecognitionTask) Cancel()
Cancels the current speech recognition task.
Discussion ¶
You can cancel recognition tasks for both prerecorded and live audio input. For example, you might cancel a task in response to a user action or because the recording was interrupted.
When canceling a task, be sure to release any resources associated with the task, such as the audio input resources you are using to capture audio samples.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask/cancel()
func (SFSpeechRecognitionTask) Error ¶
func (s SFSpeechRecognitionTask) Error() foundation.NSError
An error object that specifies the error that occurred during a speech recognition task.
Discussion ¶
The system may return one of the errors listed in the table below.
[Table data omitted]
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask/error
func (SFSpeechRecognitionTask) Finish ¶
func (s SFSpeechRecognitionTask) Finish()
Stops accepting new audio and finishes processing on the audio input that has already been accepted.
Discussion ¶
For audio buffer–based recognition, recognition does not finish until this method is called, so be sure to call it when the audio source is exhausted.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask/finish()
func (SFSpeechRecognitionTask) Init ¶
func (s SFSpeechRecognitionTask) Init() SFSpeechRecognitionTask
Init initializes the instance.
func (SFSpeechRecognitionTask) IsCancelled ¶
func (s SFSpeechRecognitionTask) IsCancelled() bool
A Boolean value that indicates whether the speech recognition task was canceled.
Discussion ¶
By default, the value of this property is `false`.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask/isCancelled
func (SFSpeechRecognitionTask) IsFinishing ¶
func (s SFSpeechRecognitionTask) IsFinishing() bool
A Boolean value that indicates whether audio input has stopped.
Discussion ¶
By default, the value of this property is `false`.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask/isFinishing
func (SFSpeechRecognitionTask) State ¶
func (s SFSpeechRecognitionTask) State() SFSpeechRecognitionTaskState
The current state of the speech recognition task.
Discussion ¶
Check the value of this property to get the state of the in-progress speech recognition session. For valid values, see SFSpeechRecognitionTaskState.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTask/state
type SFSpeechRecognitionTaskClass ¶
type SFSpeechRecognitionTaskClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechRecognitionTaskClass ¶
func GetSFSpeechRecognitionTaskClass() SFSpeechRecognitionTaskClass
GetSFSpeechRecognitionTaskClass returns the class object for SFSpeechRecognitionTask.
func (SFSpeechRecognitionTaskClass) Alloc ¶
func (sc SFSpeechRecognitionTaskClass) Alloc() SFSpeechRecognitionTask
Alloc allocates memory for a new instance of the class.
func (SFSpeechRecognitionTaskClass) Class ¶
func (sc SFSpeechRecognitionTaskClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFSpeechRecognitionTaskDelegate ¶
type SFSpeechRecognitionTaskDelegate interface {
objectivec.IObject
}
A protocol with methods for managing multi-utterance speech recognition requests.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTaskDelegate
type SFSpeechRecognitionTaskDelegateConfig ¶
type SFSpeechRecognitionTaskDelegateConfig struct {
// Tracking task progress
// SpeechRecognitionDidDetectSpeech — Tells the delegate when the task first detects speech in the source audio.
SpeechRecognitionDidDetectSpeech func(task SFSpeechRecognitionTask)
// SpeechRecognitionTaskFinishedReadingAudio — Tells the delegate when the task is no longer accepting new audio input, even if final processing is in progress.
SpeechRecognitionTaskFinishedReadingAudio func(task SFSpeechRecognitionTask)
// Getting transcriptions
// SpeechRecognitionTaskDidHypothesizeTranscription — Tells the delegate that a hypothesized transcription is available.
SpeechRecognitionTaskDidHypothesizeTranscription func(task SFSpeechRecognitionTask, transcription SFTranscription)
// Finishing a speech recognition task
// SpeechRecognitionTaskDidFinishRecognition — Tells the delegate when the final utterance is recognized.
SpeechRecognitionTaskDidFinishRecognition func(task SFSpeechRecognitionTask, recognitionResult SFSpeechRecognitionResult)
// SpeechRecognitionTaskDidFinishSuccessfully — Tells the delegate when the recognition of all requested utterances is finished.
SpeechRecognitionTaskDidFinishSuccessfully func(task SFSpeechRecognitionTask, successfully bool)
// SpeechRecognitionTaskDidProcessAudioDuration — Tells the delegate how much audio has been processed by the task.
SpeechRecognitionTaskDidProcessAudioDuration func(task SFSpeechRecognitionTask, duration foundation.NSTimeInterval)
// SpeechRecognitionTaskWasCancelled — Tells the delegate that the task has been canceled.
SpeechRecognitionTaskWasCancelled func(task SFSpeechRecognitionTask)
}
SFSpeechRecognitionTaskDelegateConfig holds optional typed callbacks for SFSpeechRecognitionTaskDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.
See Apple Documentation for protocol details.
type SFSpeechRecognitionTaskDelegateObject ¶
type SFSpeechRecognitionTaskDelegateObject struct {
objectivec.Object
}
SFSpeechRecognitionTaskDelegateObject wraps an existing Objective-C object that conforms to the SFSpeechRecognitionTaskDelegate protocol.
func NewSFSpeechRecognitionTaskDelegate ¶
func NewSFSpeechRecognitionTaskDelegate(config SFSpeechRecognitionTaskDelegateConfig) SFSpeechRecognitionTaskDelegateObject
NewSFSpeechRecognitionTaskDelegate creates an Objective-C object implementing the SFSpeechRecognitionTaskDelegate protocol.
Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.
The returned SFSpeechRecognitionTaskDelegateObject satisfies the SFSpeechRecognitionTaskDelegate interface and can be passed directly to SetDelegate and similar methods.
See Apple Documentation for protocol details.
func SFSpeechRecognitionTaskDelegateObjectFromID ¶
func SFSpeechRecognitionTaskDelegateObjectFromID(id objc.ID) SFSpeechRecognitionTaskDelegateObject
SFSpeechRecognitionTaskDelegateObjectFromID constructs a SFSpeechRecognitionTaskDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.
func (SFSpeechRecognitionTaskDelegateObject) BaseObject ¶
func (o SFSpeechRecognitionTaskDelegateObject) BaseObject() objectivec.Object
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionDidDetectSpeech ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionDidDetectSpeech(task ISFSpeechRecognitionTask)
Tells the delegate when the task first detects speech in the source audio.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidFinishRecognition ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidFinishRecognition(task ISFSpeechRecognitionTask, recognitionResult ISFSpeechRecognitionResult)
Tells the delegate when the final utterance is recognized.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
recognitionResult: A recognized utterance that contains one or more transcription hypotheses in an SFSpeechRecognitionResult object.
Discussion ¶
When this method is called, the delegate should expect no further information about the utterance to be reported.
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidFinishSuccessfully ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidFinishSuccessfully(task ISFSpeechRecognitionTask, successfully bool)
Tells the delegate when the recognition of all requested utterances is finished.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
successfully: A Boolean value that indicates whether the task was successful. When this parameter is `false`, use the SFSpeechRecognitionTask.Error property of the task to get information about why the task was unsuccessful.
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidHypothesizeTranscription ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidHypothesizeTranscription(task ISFSpeechRecognitionTask, transcription ISFTranscription)
Tells the delegate that a hypothesized transcription is available.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
transcription: The hypothesized transcription in an SFTranscription object.
Discussion ¶
This method is called for all recognitions, including partial recognitions.
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidProcessAudioDuration ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskDidProcessAudioDuration(task ISFSpeechRecognitionTask, duration foundation.NSTimeInterval)
Tells the delegate how much audio has been processed by the task.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
duration: The seconds of audio input that the recognizer has processed.
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskFinishedReadingAudio ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskFinishedReadingAudio(task ISFSpeechRecognitionTask)
Tells the delegate when the task is no longer accepting new audio input, even if final processing is in progress.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
func (SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskWasCancelled ¶
func (o SFSpeechRecognitionTaskDelegateObject) SpeechRecognitionTaskWasCancelled(task ISFSpeechRecognitionTask)
Tells the delegate that the task has been canceled.
task: The speech recognition task (an SFSpeechRecognitionTask object) that represents the request.
Discussion ¶
A speech recognition task can be canceled by the user, by your app, or by the system.
type SFSpeechRecognitionTaskHint ¶
type SFSpeechRecognitionTaskHint int
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTaskHint
const ( // SFSpeechRecognitionTaskHintConfirmation: A task that uses captured speech for short, confirmation-style requests. SFSpeechRecognitionTaskHintConfirmation SFSpeechRecognitionTaskHint = 3 // SFSpeechRecognitionTaskHintDictation: A task that uses captured speech for text entry. SFSpeechRecognitionTaskHintDictation SFSpeechRecognitionTaskHint = 1 // SFSpeechRecognitionTaskHintSearch: A task that uses captured speech to specify search terms. SFSpeechRecognitionTaskHintSearch SFSpeechRecognitionTaskHint = 2 // SFSpeechRecognitionTaskHintUnspecified: An unspecified type of task. SFSpeechRecognitionTaskHintUnspecified SFSpeechRecognitionTaskHint = 0 )
func (SFSpeechRecognitionTaskHint) String ¶
func (e SFSpeechRecognitionTaskHint) String() string
type SFSpeechRecognitionTaskState ¶
type SFSpeechRecognitionTaskState int
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognitionTaskState
const ( // SFSpeechRecognitionTaskStateCanceling: Delivery of recognition results has finished, but audio recording may be ongoing. SFSpeechRecognitionTaskStateCanceling SFSpeechRecognitionTaskState = 3 // SFSpeechRecognitionTaskStateCompleted: Delivery of recognition requests has finished and audio recording has stopped. SFSpeechRecognitionTaskStateCompleted SFSpeechRecognitionTaskState = 4 // SFSpeechRecognitionTaskStateFinishing: Audio recording has stopped, but delivery of recognition results may continue. SFSpeechRecognitionTaskStateFinishing SFSpeechRecognitionTaskState = 2 // SFSpeechRecognitionTaskStateRunning: Speech recognition (potentially including audio recording) is in progress. SFSpeechRecognitionTaskStateRunning SFSpeechRecognitionTaskState = 1 // SFSpeechRecognitionTaskStateStarting: Speech recognition (potentially including audio recording) has not yet started. SFSpeechRecognitionTaskStateStarting SFSpeechRecognitionTaskState = 0 )
func (SFSpeechRecognitionTaskState) String ¶
func (e SFSpeechRecognitionTaskState) String() string
type SFSpeechRecognizer ¶
type SFSpeechRecognizer struct {
objectivec.Object
}
An object you use to check for the availability of the speech recognition service, and to initiate the speech recognition process.
Overview ¶
An SFSpeechRecognizer object is the central object for managing the speech recognizer process. Use this object to:
- Request authorization to use speech recognition services. - Specify the language to use during the recognition process. - Initiate new speech recognition tasks.
Set up speech recognition ¶
Each speech recognizer supports only one language, which you specify at creation time. The successful creation of a speech recognizer does not guarantee that speech recognition services are available. For some languages, the recognizer might require an Internet connection. Use the [SFSpeechRecognizer.Available] property to find out if speech recognition services are available for the current language.
To initiate the speech recognition process, do the following:
- Request authorization to use speech recognition. See Asking Permission to Use Speech Recognition. - Create an SFSpeechRecognizer object. - Verify the availability of services using the [SFSpeechRecognizer.Available] property of your speech recognizer object. - Prepare your audio content. - Create a recognition request object—an object that descends from SFSpeechRecognitionRequest. - Call the SFSpeechRecognizer.RecognitionTaskWithRequestDelegate or SFSpeechRecognizer.RecognitionTaskWithRequestResultHandler method to begin the recognition process.
The type of recognition request object you create depends on whether you are processing an existing audio file or an incoming stream of audio. For existing audio files, create a SFSpeechURLRecognitionRequest object. For audio streams, create a SFSpeechAudioBufferRecognitionRequest object.
Create a great user experience for speech recognition ¶
Here are some tips to consider when adding speech recognition support to your app.
- Because speech recognition is a network-based service, limits are enforced so that the service can remain freely available to all apps. Individual devices may be limited in the number of recognitions that can be performed per day, and each app may be throttled globally based on the number of requests it makes per day. If a recognition request fails quickly (within a second or two of starting), check to see if the recognition service became unavailable. If it is, you may want to ask users to try again later. - Speech recognition places a relatively high burden on battery life and network usage. To minimize this burden, the framework stops speech recognition tasks that last longer than one minute. This limit is similar to the one for keyboard-related dictation. - For example, display a visual indicator and play sounds at the beginning and end of speech recognition to help users understand that they’re being actively recorded. You can also display speech as it is being recognized so that users understand what your app is doing and see any mistakes made during the recognition process. - Some speech is not appropriate for recognition. Don’t send passwords, health or financial data, and other sensitive speech for recognition.
Creating a speech recognizer ¶
- SFSpeechRecognizer.InitWithLocale: Creates a speech recognizer associated with the specified locale.
Monitoring speech recognition availability ¶
- SFSpeechRecognizer.Delegate: The delegate object that handles changes to the availability of speech recognition services.
- SFSpeechRecognizer.SetDelegate
- SFSpeechRecognizer.IsAvailable: A Boolean value that indicates whether the speech recognizer is currently available.
- SFSpeechRecognizer.SupportsOnDeviceRecognition: A Boolean value that indicates whether the speech recognizer can operate without network access.
- SFSpeechRecognizer.SetSupportsOnDeviceRecognition
Configuring the speech recognizer ¶
- SFSpeechRecognizer.DefaultTaskHint: A hint that indicates the type of speech recognition being requested.
- SFSpeechRecognizer.SetDefaultTaskHint
- SFSpeechRecognizer.Queue: The queue on which to execute recognition task handlers and delegate methods.
- SFSpeechRecognizer.SetQueue
Performing speech recognition on audio ¶
- SFSpeechRecognizer.RecognitionTaskWithRequestResultHandler: Executes the speech recognition request and delivers the results to the specified handler block.
- SFSpeechRecognizer.RecognitionTaskWithRequestDelegate: Recognizes speech from the audio source associated with the specified request, using the specified delegate to manage the results.
Getting the current language ¶
- SFSpeechRecognizer.Locale: The locale of the speech recognizer.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer
func NewSFSpeechRecognizer ¶
func NewSFSpeechRecognizer() SFSpeechRecognizer
NewSFSpeechRecognizer creates a new SFSpeechRecognizer instance.
func NewSpeechRecognizerWithLocale ¶
func NewSpeechRecognizerWithLocale(locale foundation.NSLocale) SFSpeechRecognizer
Creates a speech recognizer associated with the specified locale.
locale: The locale object representing the language you want to use for speech recognition. For a list of languages supported by the speech recognizer, see SFSpeechRecognizerClass.SupportedLocales.
Return Value ¶
An initialized speech recognizer object, or `nil` if the specified language was not supported.
Discussion ¶
If you specify a language that is not supported by the speech recognizer, this method attempts to fall back to the language used by the keyboard for dictation. If that fails, this method returns `nil`.
Even if this method returns a valid speech recognizer object, the speech recognition services may be temporarily unavailable. To determine whether speech recognition services are available, check the [SFSpeechRecognizer.Available] property.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/init(locale:)
func SFSpeechRecognizerFromID ¶
func SFSpeechRecognizerFromID(id objc.ID) SFSpeechRecognizer
SFSpeechRecognizerFromID constructs a SFSpeechRecognizer from an objc.ID.
An object you use to check for the availability of the speech recognition service, and to initiate the speech recognition process.
func (SFSpeechRecognizer) Autorelease ¶
func (s SFSpeechRecognizer) Autorelease() SFSpeechRecognizer
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechRecognizer) DefaultTaskHint ¶
func (s SFSpeechRecognizer) DefaultTaskHint() SFSpeechRecognitionTaskHint
A hint that indicates the type of speech recognition being requested.
Discussion ¶
By default, the value of this property overrides the SFSpeechRecognitionTaskHint.unspecified value for requests. For possible values, see SFSpeechRecognitionTaskHint.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/defaultTaskHint
func (SFSpeechRecognizer) Delegate ¶
func (s SFSpeechRecognizer) Delegate() SFSpeechRecognizerDelegate
The delegate object that handles changes to the availability of speech recognition services.
Discussion ¶
Provide a delegate object when you want to monitor changes to the availability of speech recognition services. Your delegate object must conform to the SFSpeechRecognizerDelegate protocol.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/delegate
func (SFSpeechRecognizer) Init ¶
func (s SFSpeechRecognizer) Init() SFSpeechRecognizer
Init initializes the instance.
func (SFSpeechRecognizer) InitWithLocale ¶
func (s SFSpeechRecognizer) InitWithLocale(locale foundation.NSLocale) SFSpeechRecognizer
Creates a speech recognizer associated with the specified locale.
locale: The locale object representing the language you want to use for speech recognition. For a list of languages supported by the speech recognizer, see SFSpeechRecognizerClass.SupportedLocales.
Return Value ¶
An initialized speech recognizer object, or `nil` if the specified language was not supported.
Discussion ¶
If you specify a language that is not supported by the speech recognizer, this method attempts to fall back to the language used by the keyboard for dictation. If that fails, this method returns `nil`.
Even if this method returns a valid speech recognizer object, the speech recognition services may be temporarily unavailable. To determine whether speech recognition services are available, check the [SFSpeechRecognizer.Available] property.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/init(locale:)
func (SFSpeechRecognizer) IsAvailable ¶
func (s SFSpeechRecognizer) IsAvailable() bool
A Boolean value that indicates whether the speech recognizer is currently available.
Discussion ¶
When the value of this property is `true`, you may create new speech recognition tasks. When value of this property is `false`, speech recognition services are not available.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/isAvailable
func (SFSpeechRecognizer) Locale ¶
func (s SFSpeechRecognizer) Locale() foundation.NSLocale
The locale of the speech recognizer.
Discussion ¶
The locale of the speech recognizer is an [NSLocale] object. The default value of this property is the system locale (that is, `+[NSLocale systemLocale]`).
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/locale
func (SFSpeechRecognizer) Queue ¶
func (s SFSpeechRecognizer) Queue() foundation.OperationQueue
The queue on which to execute recognition task handlers and delegate methods.
Discussion ¶
The default value of this property is the app’s main queue. Assign a different queue if you want delegate methods and handlers to be executed on a background queue.
The handler you pass to the SFSpeechRecognizerClass.RequestAuthorization method does not use this queue.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/queue
func (SFSpeechRecognizer) RecognitionTaskWithRequestDelegate ¶
func (s SFSpeechRecognizer) RecognitionTaskWithRequestDelegate(request ISFSpeechRecognitionRequest, delegate SFSpeechRecognitionTaskDelegate) ISFSpeechRecognitionTask
Recognizes speech from the audio source associated with the specified request, using the specified delegate to manage the results.
request: A request (encapsulated in an SFSpeechRecognitionRequest object) to recognize speech from an audio source.
delegate: An object that can handle results from the speech recognition task. This object must conform to the SFSpeechRecognitionTaskDelegate protocol.
Return Value ¶
The task object you can use to manage an in-progress recognition request.
Discussion ¶
Use this method to initiate the speech recognition process on the audio contained in the request object. This method executes asynchronously and returns a SFSpeechRecognitionTask object that you can use to cancel or finalize the recognition process later. As results become available, the method calls the methods of the provided `delegate` object.
Note that the SFSpeechRecognitionTask object returned by this method does not retain your delegate object. You must maintain a strong reference to your delegate while speech recognition is in progress.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/recognitionTask(with:delegate:)
func (SFSpeechRecognizer) RecognitionTaskWithRequestResultHandler ¶
func (s SFSpeechRecognizer) RecognitionTaskWithRequestResultHandler(request ISFSpeechRecognitionRequest, resultHandler SFSpeechRecognitionResultErrorHandler) ISFSpeechRecognitionTask
Executes the speech recognition request and delivers the results to the specified handler block.
request: A request (in an SFSpeechRecognitionRequest object) to recognize speech from an audio source.
resultHandler: The block to call when partial or final results are available, or when an error occurs. If the SFSpeechRecognitionRequest.ShouldReportPartialResults property is `true`, this block may be called multiple times to deliver the partial and final results. The block has no return value and takes the following parameters:
result: A SFSpeechRecognitionResult containing the partial or final transcriptions of the audio content. error: An error object if a problem occurred. This parameter is `nil` if speech recognition was successful.
Return Value ¶
The task object you can use to manage an in-progress recognition request.
Discussion ¶
Use this method to initiate the speech recognition process on the audio contained in the request object. This method executes asynchronously and returns a SFSpeechRecognitionTask object that you can use to cancel or finalize the recognition process later. As results become available, the method calls the block in the `resultHandler` parameter.
func (SFSpeechRecognizer) RecognitionTaskWithRequestResultHandlerSync ¶
func (s SFSpeechRecognizer) RecognitionTaskWithRequestResultHandlerSync(ctx context.Context, request ISFSpeechRecognitionRequest) (*SFSpeechRecognitionResult, error)
RecognitionTaskWithRequestResultHandlerSync is a synchronous wrapper around SFSpeechRecognizer.RecognitionTaskWithRequestResultHandler. It blocks until the completion handler fires or the context is cancelled.
func (SFSpeechRecognizer) SetDefaultTaskHint ¶
func (s SFSpeechRecognizer) SetDefaultTaskHint(value SFSpeechRecognitionTaskHint)
func (SFSpeechRecognizer) SetDelegate ¶
func (s SFSpeechRecognizer) SetDelegate(value SFSpeechRecognizerDelegate)
func (SFSpeechRecognizer) SetQueue ¶
func (s SFSpeechRecognizer) SetQueue(value foundation.OperationQueue)
func (SFSpeechRecognizer) SetSupportsOnDeviceRecognition ¶
func (s SFSpeechRecognizer) SetSupportsOnDeviceRecognition(value bool)
func (SFSpeechRecognizer) SupportsOnDeviceRecognition ¶
func (s SFSpeechRecognizer) SupportsOnDeviceRecognition() bool
A Boolean value that indicates whether the speech recognizer can operate without network access.
Discussion ¶
An SFSpeechRecognitionRequest can only honor its SFSpeechRecognitionRequest.RequiresOnDeviceRecognition property if SFSpeechRecognizer.SupportsOnDeviceRecognition is `true`. If SFSpeechRecognizer.SupportsOnDeviceRecognition is `false`, the SFSpeechRecognizer requires a network in order to recognize speech.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/supportsOnDeviceRecognition
type SFSpeechRecognizerAuthorizationStatus ¶
type SFSpeechRecognizerAuthorizationStatus int
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizerAuthorizationStatus
const ( // SFSpeechRecognizerAuthorizationStatusAuthorized: The user granted your app’s request to perform speech recognition. SFSpeechRecognizerAuthorizationStatusAuthorized SFSpeechRecognizerAuthorizationStatus = 3 // SFSpeechRecognizerAuthorizationStatusDenied: The user denied your app’s request to perform speech recognition. SFSpeechRecognizerAuthorizationStatusDenied SFSpeechRecognizerAuthorizationStatus = 1 // SFSpeechRecognizerAuthorizationStatusNotDetermined: The app’s authorization status has not yet been determined. SFSpeechRecognizerAuthorizationStatusNotDetermined SFSpeechRecognizerAuthorizationStatus = 0 // SFSpeechRecognizerAuthorizationStatusRestricted: The device prevents your app from performing speech recognition. SFSpeechRecognizerAuthorizationStatusRestricted SFSpeechRecognizerAuthorizationStatus = 2 )
func (SFSpeechRecognizerAuthorizationStatus) String ¶
func (e SFSpeechRecognizerAuthorizationStatus) String() string
type SFSpeechRecognizerAuthorizationStatusHandler ¶
type SFSpeechRecognizerAuthorizationStatusHandler = func(SFSpeechRecognizerAuthorizationStatus)
SFSpeechRecognizerAuthorizationStatusHandler handles The block to execute when your app’s authorization status is known.
Used by:
- [SFSpeechRecognizer.RequestAuthorization]
type SFSpeechRecognizerClass ¶
type SFSpeechRecognizerClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechRecognizerClass ¶
func GetSFSpeechRecognizerClass() SFSpeechRecognizerClass
GetSFSpeechRecognizerClass returns the class object for SFSpeechRecognizer.
func (SFSpeechRecognizerClass) Alloc ¶
func (sc SFSpeechRecognizerClass) Alloc() SFSpeechRecognizer
Alloc allocates memory for a new instance of the class.
func (SFSpeechRecognizerClass) AuthorizationStatus ¶
func (_SFSpeechRecognizerClass SFSpeechRecognizerClass) AuthorizationStatus() SFSpeechRecognizerAuthorizationStatus
Returns your app’s current authorization to perform speech recognition.
Return Value ¶
The app’s current authorization status value. For a list of values, see SFSpeechRecognizerAuthorizationStatus.
Discussion ¶
The user can reject your app’s request to perform speech recognition, but your request can also be denied if speech recognition is not supported on the device. The app can also change your app’s authorization status at any time from the Settings app.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/authorizationStatus()
func (SFSpeechRecognizerClass) Class ¶
func (sc SFSpeechRecognizerClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
func (SFSpeechRecognizerClass) RequestAuthorization ¶
func (_SFSpeechRecognizerClass SFSpeechRecognizerClass) RequestAuthorization(handler SFSpeechRecognizerAuthorizationStatusHandler)
Asks the user to allow your app to perform speech recognition.
handler: The block to execute when your app’s authorization status is known. The status parameter of the block contains your app’s authorization status. The system does not guarantee the execution of this block on your app’s main dispatch queue.
Discussion ¶
Call this method before performing any other tasks associated with speech recognition. This method executes asynchronously, returning shortly after you call it. At some point later, the system calls the provided `handler` block with the results.
When your app’s authorization status is SFSpeechRecognizerAuthorizationStatus.notDetermined, this method causes the system to prompt the user to grant or deny permission for your app to use speech recognition. The prompt includes the custom message you specify in the [NSSpeechRecognitionUsageDescription] key of your app’s `Info.Plist()` file. The user’s response is saved so that future calls to this method do not prompt the user again.
For more information about requesting authorization, see Asking Permission to Use Speech Recognition.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/requestAuthorization(_:)
func (SFSpeechRecognizerClass) RequestAuthorizationSync ¶
func (sc SFSpeechRecognizerClass) RequestAuthorizationSync(ctx context.Context) (SFSpeechRecognizerAuthorizationStatus, error)
RequestAuthorizationSync is a synchronous wrapper around [SFSpeechRecognizer.RequestAuthorization]. It blocks until the completion handler fires or the context is cancelled.
func (SFSpeechRecognizerClass) SupportedLocales ¶
func (_SFSpeechRecognizerClass SFSpeechRecognizerClass) SupportedLocales() foundation.INSSet
Returns the set of locales that are supported by the speech recognizer.
Return Value ¶
A set of locales that support speech recognition.
Discussion ¶
This method returns the locales for which speech recognition is supported. Support for a locale does not guarantee that speech recognition is currently possible for that locale. For some locales, the speech recognizer requires an active Internet connection to communicate with Apple’s servers. If the speech recognizer is currently unable to process requests, [SFSpeechRecognizer.Available] returns `false`.
Speech recognition supports the same locales that are supported by the keyboard’s dictation feature. For a list of these locales, see QuickType Keyboard: Dictation.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizer/supportedLocales()
type SFSpeechRecognizerDelegate ¶
type SFSpeechRecognizerDelegate interface {
objectivec.IObject
}
A protocol that you adopt in your objects to track the availability of a speech recognizer.
See: https://developer.apple.com/documentation/Speech/SFSpeechRecognizerDelegate
type SFSpeechRecognizerDelegateConfig ¶
type SFSpeechRecognizerDelegateConfig struct {
// Monitoring speech recognizer availability
// SpeechRecognizerAvailabilityDidChange — Tells the delegate that the availability of its associated speech recognizer changed.
SpeechRecognizerAvailabilityDidChange func(speechRecognizer SFSpeechRecognizer, available bool)
}
SFSpeechRecognizerDelegateConfig holds optional typed callbacks for SFSpeechRecognizerDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.
See Apple Documentation for protocol details.
type SFSpeechRecognizerDelegateObject ¶
type SFSpeechRecognizerDelegateObject struct {
objectivec.Object
}
SFSpeechRecognizerDelegateObject wraps an existing Objective-C object that conforms to the SFSpeechRecognizerDelegate protocol.
func NewSFSpeechRecognizerDelegate ¶
func NewSFSpeechRecognizerDelegate(config SFSpeechRecognizerDelegateConfig) SFSpeechRecognizerDelegateObject
NewSFSpeechRecognizerDelegate creates an Objective-C object implementing the SFSpeechRecognizerDelegate protocol.
Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.
The returned SFSpeechRecognizerDelegateObject satisfies the SFSpeechRecognizerDelegate interface and can be passed directly to SetDelegate and similar methods.
See Apple Documentation for protocol details.
func SFSpeechRecognizerDelegateObjectFromID ¶
func SFSpeechRecognizerDelegateObjectFromID(id objc.ID) SFSpeechRecognizerDelegateObject
SFSpeechRecognizerDelegateObjectFromID constructs a SFSpeechRecognizerDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.
func (SFSpeechRecognizerDelegateObject) BaseObject ¶
func (o SFSpeechRecognizerDelegateObject) BaseObject() objectivec.Object
func (SFSpeechRecognizerDelegateObject) SpeechRecognizerAvailabilityDidChange ¶
func (o SFSpeechRecognizerDelegateObject) SpeechRecognizerAvailabilityDidChange(speechRecognizer ISFSpeechRecognizer, available bool)
Tells the delegate that the availability of its associated speech recognizer changed.
speechRecognizer: The SFSpeechRecognizer object whose availability changed.
available: A Boolean value that indicates the new availability of the speech recognizer.
type SFSpeechURLRecognitionRequest ¶
type SFSpeechURLRecognitionRequest struct {
SFSpeechRecognitionRequest
}
A request to recognize speech in a recorded audio file.
Overview ¶
Use this object to perform speech recognition on the contents of an audio file.
The following example shows a method that performs recognition on an audio file based on the user’s default language and prints out the transcription.
Listing 1. Getting a speech recognizer and making a recognition request
Creating a speech recognition request ¶
- SFSpeechURLRecognitionRequest.InitWithURL: Creates a speech recognition request, initialized with the specified URL.
Accessing the audio file URL ¶
- SFSpeechURLRecognitionRequest.URL: The URL of the audio file.
See: https://developer.apple.com/documentation/Speech/SFSpeechURLRecognitionRequest
func NewSFSpeechURLRecognitionRequest ¶
func NewSFSpeechURLRecognitionRequest() SFSpeechURLRecognitionRequest
NewSFSpeechURLRecognitionRequest creates a new SFSpeechURLRecognitionRequest instance.
func NewSpeechURLRecognitionRequestWithURL ¶
func NewSpeechURLRecognitionRequestWithURL(URL foundation.NSURL) SFSpeechURLRecognitionRequest
Creates a speech recognition request, initialized with the specified URL.
Discussion ¶
Use this method to create a request to recognize speech in a recorded audio file that resides at the specified URL. Pass the request to the recognizer’s SFSpeechRecognizer.RecognitionTaskWithRequestDelegate method to start recognition.
See: https://developer.apple.com/documentation/Speech/SFSpeechURLRecognitionRequest/init(url:)
func SFSpeechURLRecognitionRequestFromID ¶
func SFSpeechURLRecognitionRequestFromID(id objc.ID) SFSpeechURLRecognitionRequest
SFSpeechURLRecognitionRequestFromID constructs a SFSpeechURLRecognitionRequest from an objc.ID.
A request to recognize speech in a recorded audio file.
func (SFSpeechURLRecognitionRequest) Autorelease ¶
func (s SFSpeechURLRecognitionRequest) Autorelease() SFSpeechURLRecognitionRequest
Autorelease adds the receiver to the current autorelease pool.
func (SFSpeechURLRecognitionRequest) Init ¶
func (s SFSpeechURLRecognitionRequest) Init() SFSpeechURLRecognitionRequest
Init initializes the instance.
func (SFSpeechURLRecognitionRequest) InitWithURL ¶
func (s SFSpeechURLRecognitionRequest) InitWithURL(URL foundation.NSURL) SFSpeechURLRecognitionRequest
Creates a speech recognition request, initialized with the specified URL.
Discussion ¶
Use this method to create a request to recognize speech in a recorded audio file that resides at the specified URL. Pass the request to the recognizer’s SFSpeechRecognizer.RecognitionTaskWithRequestDelegate method to start recognition.
See: https://developer.apple.com/documentation/Speech/SFSpeechURLRecognitionRequest/init(url:)
func (SFSpeechURLRecognitionRequest) URL ¶
func (s SFSpeechURLRecognitionRequest) URL() foundation.NSURL
The URL of the audio file.
See: https://developer.apple.com/documentation/Speech/SFSpeechURLRecognitionRequest/url
type SFSpeechURLRecognitionRequestClass ¶
type SFSpeechURLRecognitionRequestClass struct {
// contains filtered or unexported fields
}
func GetSFSpeechURLRecognitionRequestClass ¶
func GetSFSpeechURLRecognitionRequestClass() SFSpeechURLRecognitionRequestClass
GetSFSpeechURLRecognitionRequestClass returns the class object for SFSpeechURLRecognitionRequest.
func (SFSpeechURLRecognitionRequestClass) Alloc ¶
func (sc SFSpeechURLRecognitionRequestClass) Alloc() SFSpeechURLRecognitionRequest
Alloc allocates memory for a new instance of the class.
func (SFSpeechURLRecognitionRequestClass) Class ¶
func (sc SFSpeechURLRecognitionRequestClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFTranscription ¶
type SFTranscription struct {
objectivec.Object
}
A textual representation of the specified speech in its entirety, as recognized by the speech recognizer.
Overview ¶
Use SFTranscription to obtain all the recognized utterances from your audio content. An is a vocalized word or group of words that represent a single meaning to the speech recognizer (SFSpeechRecognizer).
Use the SFTranscription.FormattedString property to retrieve the entire transcription of utterances, or use the SFTranscription.Segments property to retrieve an individual utterance (SFTranscriptionSegment).
You don’t create an SFTranscription directly. Instead, you retrieve it from an SFSpeechRecognitionResult instance. The speech recognizer sends a speech recognition result to your app in one of two ways, depending on how your app started a speech recognition task.
You can start a speech recognition task by using the speech recognizer’s SFSpeechRecognizer.RecognitionTaskWithRequestResultHandler method. When the task is complete, the speech recognizer sends an SFSpeechRecognitionResult instance to your `resultHandler` closure. Alternatively, you can use the speech recognizer’s SFSpeechRecognizer.RecognitionTaskWithRequestDelegate method to start a speech recognition task. When the task is complete, the speech recognizer uses your SFSpeechRecognitionTaskDelegate to send an SFSpeechRecognitionResult by using the delegate’s [SpeechRecognitionTaskDidFinishRecognition] method.
An SFTranscription represents only a potential version of the speech. It might not be an accurate representation of the utterances.
Transcribing utterances ¶
- SFTranscription.FormattedString: The entire transcription of utterances, formatted into a single, user-displayable string.
Getting individual utterances ¶
- SFTranscription.Segments: An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.
See: https://developer.apple.com/documentation/Speech/SFTranscription
func NewSFTranscription ¶
func NewSFTranscription() SFTranscription
NewSFTranscription creates a new SFTranscription instance.
func SFTranscriptionFromID ¶
func SFTranscriptionFromID(id objc.ID) SFTranscription
SFTranscriptionFromID constructs a SFTranscription from an objc.ID.
A textual representation of the specified speech in its entirety, as recognized by the speech recognizer.
func (SFTranscription) Autorelease ¶
func (t SFTranscription) Autorelease() SFTranscription
Autorelease adds the receiver to the current autorelease pool.
func (SFTranscription) EncodeWithCoder ¶
func (t SFTranscription) EncodeWithCoder(coder foundation.INSCoder)
func (SFTranscription) FormattedString ¶
func (t SFTranscription) FormattedString() string
The entire transcription of utterances, formatted into a single, user-displayable string.
See: https://developer.apple.com/documentation/Speech/SFTranscription/formattedString
func (SFTranscription) Init ¶
func (t SFTranscription) Init() SFTranscription
Init initializes the instance.
func (SFTranscription) Segments ¶
func (t SFTranscription) Segments() []SFTranscriptionSegment
An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.
Discussion ¶
The order of the segments in the array matches the order in which the corresponding utterances occur in the spoken content.
See: https://developer.apple.com/documentation/Speech/SFTranscription/segments
type SFTranscriptionClass ¶
type SFTranscriptionClass struct {
// contains filtered or unexported fields
}
func GetSFTranscriptionClass ¶
func GetSFTranscriptionClass() SFTranscriptionClass
GetSFTranscriptionClass returns the class object for SFTranscription.
func (SFTranscriptionClass) Alloc ¶
func (sc SFTranscriptionClass) Alloc() SFTranscription
Alloc allocates memory for a new instance of the class.
func (SFTranscriptionClass) Class ¶
func (sc SFTranscriptionClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFTranscriptionSegment ¶
type SFTranscriptionSegment struct {
objectivec.Object
}
A discrete part of an entire transcription, as identified by the speech recognizer.
Overview ¶
Use SFTranscriptionSegment to get details about a part of an overall SFTranscription. An SFTranscriptionSegment represents an utterance, which is a vocalized word or group of words that represent a single meaning to the speech recognizer (SFSpeechRecognizer).
You don’t create transcription object segments directly. Instead, you access them from a transcription’s SFTranscription.Segments property.
A transcription segment includes the following information:
- The text of the utterance, plus any alternative interpretations of the spoken word. - The character range of the segment within the SFTranscription.FormattedString of its parent SFTranscription. - A SFTranscriptionSegment.Confidence value, indicating how likely it is that the specified string matches the audible speech. - A SFTranscriptionSegment.Timestamp and SFTranscriptionSegment.Duration value, indicating the position of the segment within the provided audio stream.
Transcribing the segment ¶
- SFTranscriptionSegment.Substring: The string representation of the utterance in the transcription segment.
- SFTranscriptionSegment.SubstringRange: The range information for the transcription segment’s substring, relative to the overall transcription.
- SFTranscriptionSegment.AlternativeSubstrings: An array of alternate interpretations of the utterance in the transcription segment.
Assessing the recognition confidence level ¶
- SFTranscriptionSegment.Confidence: The level of confidence the speech recognizer has in its recognition of the speech transcribed for the segment.
Getting audio timing information ¶
- SFTranscriptionSegment.Timestamp: The start time of the segment in the processed audio stream.
- SFTranscriptionSegment.Duration: The number of seconds it took for the user to speak the utterance represented by the segment.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment
func NewSFTranscriptionSegment ¶
func NewSFTranscriptionSegment() SFTranscriptionSegment
NewSFTranscriptionSegment creates a new SFTranscriptionSegment instance.
func SFTranscriptionSegmentFromID ¶
func SFTranscriptionSegmentFromID(id objc.ID) SFTranscriptionSegment
SFTranscriptionSegmentFromID constructs a SFTranscriptionSegment from an objc.ID.
A discrete part of an entire transcription, as identified by the speech recognizer.
func (SFTranscriptionSegment) AlternativeSubstrings ¶
func (t SFTranscriptionSegment) AlternativeSubstrings() []string
An array of alternate interpretations of the utterance in the transcription segment.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment/alternativeSubstrings
func (SFTranscriptionSegment) Autorelease ¶
func (t SFTranscriptionSegment) Autorelease() SFTranscriptionSegment
Autorelease adds the receiver to the current autorelease pool.
func (SFTranscriptionSegment) Confidence ¶
func (t SFTranscriptionSegment) Confidence() float32
The level of confidence the speech recognizer has in its recognition of the speech transcribed for the segment.
Discussion ¶
This property reflects the overall confidence in the recognition of the entire phrase. The value is `0` if there was no recognition, and it is closer to `1` when there is a high certainty that a transcription matches the user’s speech exactly. For example, a confidence value of `0.94` represents a very high confidence level, and is more likely to be correct than a transcription with a confidence value of `0.72`.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment/confidence
func (SFTranscriptionSegment) Duration ¶
func (t SFTranscriptionSegment) Duration() foundation.NSTimeInterval
The number of seconds it took for the user to speak the utterance represented by the segment.
Discussion ¶
The SFTranscriptionSegment.Duration contains the number of seconds it took for the user to speak the one or more words (utterance) represented by the segment. For example, the SFSpeechRecognizer sets SFTranscriptionSegment.Duration to `0.6` if the user took `0.6` seconds to say `“time”` in the transcription of `“What time is it?"`.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment/duration
func (SFTranscriptionSegment) EncodeWithCoder ¶
func (t SFTranscriptionSegment) EncodeWithCoder(coder foundation.INSCoder)
func (SFTranscriptionSegment) Init ¶
func (t SFTranscriptionSegment) Init() SFTranscriptionSegment
Init initializes the instance.
func (SFTranscriptionSegment) Substring ¶
func (t SFTranscriptionSegment) Substring() string
The string representation of the utterance in the transcription segment.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment/substring
func (SFTranscriptionSegment) SubstringRange ¶
func (t SFTranscriptionSegment) SubstringRange() foundation.NSRange
The range information for the transcription segment’s substring, relative to the overall transcription.
Discussion ¶
Use the range information to find the position of the segment within the SFTranscription.FormattedString property of the SFTranscription object containing this segment.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment/substringRange
func (SFTranscriptionSegment) Timestamp ¶
func (t SFTranscriptionSegment) Timestamp() foundation.NSTimeInterval
The start time of the segment in the processed audio stream.
Discussion ¶
The SFTranscriptionSegment.Timestamp is the number of seconds between the beginning of the audio content and when the user spoke the word represented by the segment. For example, if the user said the word “time” one second into the transcription “What time is it”, the timestamp would be equal to `1.0`.
See: https://developer.apple.com/documentation/Speech/SFTranscriptionSegment/timestamp
type SFTranscriptionSegmentClass ¶
type SFTranscriptionSegmentClass struct {
// contains filtered or unexported fields
}
func GetSFTranscriptionSegmentClass ¶
func GetSFTranscriptionSegmentClass() SFTranscriptionSegmentClass
GetSFTranscriptionSegmentClass returns the class object for SFTranscriptionSegment.
func (SFTranscriptionSegmentClass) Alloc ¶
func (sc SFTranscriptionSegmentClass) Alloc() SFTranscriptionSegment
Alloc allocates memory for a new instance of the class.
func (SFTranscriptionSegmentClass) Class ¶
func (sc SFTranscriptionSegmentClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type SFVoiceAnalytics ¶
type SFVoiceAnalytics struct {
objectivec.Object
}
A collection of vocal analysis metrics.
Overview ¶
Use an SFAcousticFeature object to access the SFVoiceAnalytics insights. Voice analytics include the following features:
- Use SFVoiceAnalytics.Jitter to measure how pitch varies in audio. - Use SFVoiceAnalytics.Shimmer to measure how amplitude varies in audio. - Use SFVoiceAnalytics.Pitch to measure the highness and lowness of the tone. - Use SFVoiceAnalytics.Voicing to identify voiced regions in speech.
These results are part of the SFTranscriptionSegment object and are available when the system sends the [SFSpeechRecognitionResult.Final] flag.
Analyzing voice ¶
- SFVoiceAnalytics.Voicing: The likelihood of a voice in each frame of a transcription segment.
- SFVoiceAnalytics.Pitch: The highness or lowness of the tone (fundamental frequency) in each frame of a transcription segment, expressed as a logarithm.
- SFVoiceAnalytics.Jitter: The variation in pitch in each frame of a transcription segment, expressed as a percentage of the frame’s fundamental frequency.
- SFVoiceAnalytics.Shimmer: The variation in vocal volume stability (amplitude) in each frame of a transcription segment, expressed in decibels.
See: https://developer.apple.com/documentation/Speech/SFVoiceAnalytics
func NewSFVoiceAnalytics ¶
func NewSFVoiceAnalytics() SFVoiceAnalytics
NewSFVoiceAnalytics creates a new SFVoiceAnalytics instance.
func SFVoiceAnalyticsFromID ¶
func SFVoiceAnalyticsFromID(id objc.ID) SFVoiceAnalytics
SFVoiceAnalyticsFromID constructs a SFVoiceAnalytics from an objc.ID.
A collection of vocal analysis metrics.
func (SFVoiceAnalytics) Autorelease ¶
func (v SFVoiceAnalytics) Autorelease() SFVoiceAnalytics
Autorelease adds the receiver to the current autorelease pool.
func (SFVoiceAnalytics) EncodeWithCoder ¶
func (v SFVoiceAnalytics) EncodeWithCoder(coder foundation.INSCoder)
func (SFVoiceAnalytics) Init ¶
func (v SFVoiceAnalytics) Init() SFVoiceAnalytics
Init initializes the instance.
func (SFVoiceAnalytics) Jitter ¶
func (v SFVoiceAnalytics) Jitter() ISFAcousticFeature
The variation in pitch in each frame of a transcription segment, expressed as a percentage of the frame’s fundamental frequency.
See: https://developer.apple.com/documentation/Speech/SFVoiceAnalytics/jitter
func (SFVoiceAnalytics) Pitch ¶
func (v SFVoiceAnalytics) Pitch() ISFAcousticFeature
The highness or lowness of the tone (fundamental frequency) in each frame of a transcription segment, expressed as a logarithm.
Discussion ¶
The value is a logarithm (base `e`) of the normalized pitch estimate for each frame.
See: https://developer.apple.com/documentation/Speech/SFVoiceAnalytics/pitch
func (SFVoiceAnalytics) Shimmer ¶
func (v SFVoiceAnalytics) Shimmer() ISFAcousticFeature
The variation in vocal volume stability (amplitude) in each frame of a transcription segment, expressed in decibels.
See: https://developer.apple.com/documentation/Speech/SFVoiceAnalytics/shimmer
func (SFVoiceAnalytics) Voicing ¶
func (v SFVoiceAnalytics) Voicing() ISFAcousticFeature
The likelihood of a voice in each frame of a transcription segment.
Discussion ¶
The `voicing` value is expressed as a probability in the range `[0.0, 1.0]`.
See: https://developer.apple.com/documentation/Speech/SFVoiceAnalytics/voicing
type SFVoiceAnalyticsClass ¶
type SFVoiceAnalyticsClass struct {
// contains filtered or unexported fields
}
func GetSFVoiceAnalyticsClass ¶
func GetSFVoiceAnalyticsClass() SFVoiceAnalyticsClass
GetSFVoiceAnalyticsClass returns the class object for SFVoiceAnalytics.
func (SFVoiceAnalyticsClass) Alloc ¶
func (sc SFVoiceAnalyticsClass) Alloc() SFVoiceAnalytics
Alloc allocates memory for a new instance of the class.
func (SFVoiceAnalyticsClass) Class ¶
func (sc SFVoiceAnalyticsClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
Source Files
¶
- blocks.gen.go
- delegate_class_counter.gen.go
- doc.gen.go
- enums.gen.go
- functions.gen.go
- generate.go
- global_vars.gen.go
- sf_acoustic_feature.gen.go
- sf_speech_audio_buffer_recognition_request.gen.go
- sf_speech_language_model.gen.go
- sf_speech_language_model_configuration.gen.go
- sf_speech_recognition_metadata.gen.go
- sf_speech_recognition_request.gen.go
- sf_speech_recognition_result.gen.go
- sf_speech_recognition_task.gen.go
- sf_speech_recognizer.gen.go
- sf_speech_url_recognition_request.gen.go
- sf_transcription.gen.go
- sf_transcription_segment.gen.go
- sf_voice_analytics.gen.go
- speech_recognition_task_delegate_protocol.gen.go
- speech_recognizer_delegate_protocol.gen.go
- types.gen.go
- undefined_types.gen.go