KIOSDecodingGraph Class Reference

Inherits from NSObject
Declared in KIOSDecodingGraph.h
KIOSDecodingGraph.mm

Overview

KIOSDecodingGraph class manages decoding graphs in the filesystem. For more details on the concept of decoding graphs in automated speech recognition see this page.

For ASR tasks in which domain and vocabulary are defined ahead of time and not dependent on information available only during the runtime, it is recommended that decoding graph is created offline and packaged in the ASR bundle directory.

If user specific information is necessary to create decoding graphs, you can use various KIOSDecodingGraph class methods to dynamically create decoding graphs, which will be saved in the filesystem on the device. Typically, you will provide a list of sentences/phrases to createDecodingGraphFromSentences:forRecognizer:andSaveWithName: method, which will then create a custom decoding graph. Later on, you can refer to the custom decoding graph by its name. Alternatively, instead of list of sentences/phrases you can provide an ARPA language model (bundled with your app), which will be used to build a custom decoding graph.

Decoding graphs can only be built dynamically if the lang/ subdirectory in the ASR bundle exists.

Warning: When dynamically creating decoding graphs, any words that do not have phonetic representation in the lexicon (ASRBUNDLE/lang/lexicon.txt) will be assigned one algorithmically. For English langauge algorithmic representation is imperfect, thus you should aim to manually augment the lexicon text file with pronunciations for as many additional words that are likely to be encountered in your app. For example, if your app is dealing with ASR of names you would augment the lexicon with additional names and their proper pronunciation before releasing your app.

Warning: In the current versio of the framework, creating of decoding graph can take on the order of 10-30sec (on iPhone 6 and equivalaent devices) for medium size vocabulary task (more than thousand words). For larger language models we recommend you create decoding graph ahead of time and bundle it with your app.

+ createDecodingGraphFromArpaFileAtURL:forRecognizer:andSaveWithName:

Create custom decoding graph using the language model specifed in an ARPA file and save it in the filesystem for later use. Custom decoding graphs can be referenced by their name by various methods in the framework.

+ (BOOL)createDecodingGraphFromArpaFileAtURL:(nonnull NSURL *)arpaURL forRecognizer:(nonnull KIOSRecognizer *)recognizer andSaveWithName:(nonnull NSString *)decodingGraphName

Parameters

arpaURL

a URL for an ARPA file that defines the language model for which decoding graph needs to be created. Words in the ARPA file should all be in uppercase.

recognizer

KIOSRecognizer object that will be used to perform recognition with this decoding graph. Note that decoding graph is persisted in the filesystem and can be resued at the later time with a different KIOSRecognizer object as long as such recognizer uses the same ASR bundle as the KIOSRecognizer object used to create the decoding graph.

decodingGraphName

name of the custom decoding graph. All graph resources will be stored in a directory named DECODING_GRAPH_NAME-ASR_BUNDLE_NAME in Library/Application Support/KaldiIOS-decoding-graphs/

Return Value

TRUE on success, FALSE otherwise

Declared In

KIOSDecodingGraph.h

+ createDecodingGraphFromSentences:forRecognizer:andSaveWithName:

Create custom decoding graph from an array of sentences/phrases and save it in the filesystem under for later use. Custom decoding graphs can be referenced by their name by various methods in the framework.

+ (BOOL)createDecodingGraphFromSentences:(nonnull NSArray *)sentences forRecognizer:(nonnull KIOSRecognizer *)recognizer andSaveWithName:(nonnull NSString *)decodingGraphName

Parameters

sentences

an NSArray of NSString objects that specify sentences/phrases recognizer should listen for. These sentences are used to create an ngram language model, from which decoding graph is created. Text in sentences should be normalized (e.g. numbers and dates should be represented by words, so ‘two hunded dollars’ not $200)

recognizer

KIOSRecognizer object that will be used to perform recognition with this decoding graph. Note that decoding graph is persisted in the filesystem and can be resued at the later time with a different KIOSRecognizer object as long as such recognizer uses the same ASR bundle as the KIOSRecognizer object used to create the decoding graph.

decodingGraphName

a name of the custom decoding graph. All graph resources will be stored in a directy named DECODING_GRAPH_NAME-ASR_BUNDLE_NAME in Library/Application Support/KaldiIOS-decoding-graphs/

Return Value

TRUE on success, FALSE otherwise

Declared In

KIOSDecodingGraph.h

+ decodingGraphWithNameExists:forRecognizer:

Returns TRUE if valid custom decoding graph with the given name exists in the filesystem.

+ (BOOL)decodingGraphWithNameExists:(nonnull NSString *)decodingGraphName forRecognizer:(nonnull KIOSRecognizer *)recognizer

Parameters

decodingGraphName

name of the custom decoding graph

recognizer

KIOSRecognizer object equivalent to the KIOSRecognizer object that was used to create the decoding graph.

Return Value

TRUE if decoding graph with such name exists, FALSE otherwise. This method will also check for existance of all the necessary files in the decoding graph directory.

Declared In

KIOSDecodingGraph.h

+ decodingGraphExistsAtPath:

Returns TRUE if a valid decoding graph exists at the given absolute filepath.

+ (BOOL)decodingGraphExistsAtPath:(nonnull NSString *)absolutePathToDecodingGraphDirectory

Parameters

absolutePathToDecodingGraphDirectory

absolute path to the decoding graph directory.

Return Value

TRUE if decoding graph with such name exists, FALSE otherwise. This method will also check for existance of all the necessary files in the decoding graph directory.

Declared In

KIOSDecodingGraph.h

+ decodingGraphCreationDate:forRecognizer:

Returns date when custom decoding graph was created.

+ (nullable NSDate *)decodingGraphCreationDate:(nonnull NSString *)decodingGraphName forRecognizer:(nonnull KIOSRecognizer *)recognizer

Parameters

decodingGraphName

name of the decodingGraph

recognizer

KIOSRecognizer object equivalent to the KIOSRecognizer object that was used to create the decoding graph.

Return Value

date when decoding graph was created and saved in the filesystem. nil if not available.

Declared In

KIOSDecodingGraph.h