One Logo Pool Ball
Speech · IOS API REFERENCE

SFCustomLanguageModelData

class · iOS 17.0+ · SDK 27.1

class SFCustomLanguageModelData

An object that generates and exports custom language model training data.

Members (9)

get · iOS 17.0+

identifier

TypeScript
get identifier(): string
Swift declaration
final let identifier: String
static · iOS 17.0+

supportedPhonemes

TypeScript
static supportedPhonemes(locale: _Foundation_Locale): Array<string>
Swift declaration
static func supportedPhonemes(locale: Locale) -> [String]

List the supported subset of X-SAMPA pronunciations supported by this locale for the Speech framework. SFCustomLanguageModelData accepts custom pronunciations whose phonetic representations are spelled out using an alphabet of pronunciations called the Extended Speech Assessment Methods Public Alphabet, or X-SAMPA. X-SAMPA consists of ASCII characters that, individually or in combination, represents sounds made by people when speaking, and is preferred in this context over the International Phonetic Alphabet (IPA) for ease of typing. Each locale supports only a subset of all possible sounds represented by X-SAMPA symbols, and this method exists to allow developers to query for the set of sounds that can be used for a given locale's custom pronunciations facility. - Parameters: - locale: the region and language whose supported pronunciations are being queried

method · iOS 17.0+

export

TypeScript
export(path: string): Promise<void>
Swift declaration
func export(to path: URL) async throws

Export the accumulated data to a file. The file produced by this method can be provided to `SFSpeechLanguageModel.prepareCustomLanguageModel` to produce language model and vocabulary files that are then ready to be used in conjunction with the `SFSpeechRecognizer`. - Parameters: - path: a URL where the exported data will be saved. - Throws: Errors related to creating directories and files, and deleting files

method · iOS 17.0+

insert

TypeScript
insertPhraseCount(phraseCount: SFCustomLanguageModelData_PhraseCount): void
Swift declaration
func insert(phraseCount: SFCustomLanguageModelData.PhraseCount)

Add a sample to the body of training data. This class accumulates text data that will later be used to train a language model, which can be provided to an `SFSpeechRecognizer` to improve performance on certain phrases. - Parameters: - phraseCount: A sample of text on which to train your custom language model

method · iOS 17.0+

insert

TypeScript
insertPhraseCountGenerator(phraseCountGenerator: SFCustomLanguageModelData_PhraseCountGenerator): void
Swift declaration
func insert(phraseCountGenerator: SFCustomLanguageModelData.PhraseCountGenerator)

Add a stream of samples to the body of training data. This class accumulates text data that will later be used to train a language model, which can be provided to an `SFSpeechRecognizer` to improve performance on certain phrases. - Parameters: - phraseCountGenerator: A generator of phrase counts

method · iOS 17.0+

insert

TypeScript
insertTerm(term: SFCustomLanguageModelData_CustomPronunciation): void
Swift declaration
func insert(term: SFCustomLanguageModelData.CustomPronunciation)

Add a custom term to the vocabulary. This class accumulates vocabulary data (in the form of tokens paired with X-SAMPA representations of the spoken forms of those tokens) which will later be processed and then provided to an `SFSpeechRecognizer`, to enable it to recognize words that are typically out-of-vocabulary. - Parameters: - term: A token, paired with an X-SAMPA representation of the token's pronunciation

get · iOS 17.0+

locale

TypeScript
get locale(): _Foundation_Locale
Swift declaration
final let locale: Locale
init · iOS 17.0+

init

TypeScript
static init(locale: _Foundation_Locale, identifier: string, version: string): SFCustomLanguageModelData
Swift declaration
init(locale: Locale, identifier: String, version: String)

Constructs an empty data container. The `SFCustomLanguageModelData` class accumulates language model training and custom vocabulary data, both associated with a specified locale. This initializer creates an object that initially holds no data. - Parameters: - locale: the region and language of the training data (must match with the locale used to construct the `SFSpeechRecognizer` later) - identifier: used to uniquely identify the resulting language model on the device where it will be processed - version: used to distinguish different versions of the language model on the device where it will be processed

get · iOS 17.0+

version

TypeScript
get version(): string
Swift declaration
final let version: String

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

SFCustomLanguageModelData.init(locale:identifier:version:builder:)

callback cannot propagate synchronous failure

All Speech types →