NTPocketSphinxDecoder Class Reference
Inherits from | NSObject |
---|---|
Declared in | NTPocketSphinxDecoder.h NTPocketSphinxDecoder.m |
Overview
A class that wraps the pocketsphinx decoder (psdecodert). Like the underlying psdecodert the decoder is not thread safe, so don’t call methods from different threads at the same time.
Other Methods
dictionary
The dictionary currently is active.
@property (nonatomic, strong, readonly) NTPronunciationDictionary *dictionary
Discussion
The dictionary currently is active.
Declared In
NTPocketSphinxDecoder.h
activeSearch
The search currently is active.
@property (nonatomic, strong, readonly) NTSpeechSearch *activeSearch
Discussion
The search currently is active.
Declared In
NTPocketSphinxDecoder.h
– reinitWithConfiguration:
Reinitialize the decoder with updated configuration. This function allows you to switch the acoustic model, dictionary, or other configuration without creating an entirely new decoding object.
- (BOOL)reinitWithConfiguration:(NTPocketSphinxConfig *)config
Parameters
config |
Config |
---|
Return Value
YES on succes, NO on failure
Discussion
Reinitialize the decoder with updated configuration. This function allows you to switch the acoustic model, dictionary, or other configuration without creating an entirely new decoding object.
Declared In
NTPocketSphinxDecoder.h
– loadPronunciationDictionaryFromFile:
Load the dictionary from a file
- (BOOL)loadPronunciationDictionaryFromFile:(NSString *)pronunciationDictPath
Parameters
pronunciationDictPath |
Path to the dictionary file |
---|
Return Value
YES on succes, NO on failure
Discussion
Load the dictionary from a file
Declared In
NTPocketSphinxDecoder.h
– loadPronunciationDictionaryFromFile:andFillerDictionary:
Load pronunciation and filler dictionary from files
- (BOOL)loadPronunciationDictionaryFromFile:(NSString *)pronunciationDictPath andFillerDictionary:(NSString *)fillerDictPath
Parameters
pronunciationDictPath |
Path to pronunciation file |
---|---|
fillerDictPath |
Path to filler file |
Return Value
YES on succes, NO on failure
Discussion
Load pronunciation and filler dictionary from files
Declared In
NTPocketSphinxDecoder.h
– loadPronunciationDictionary:
Load pronunciation dictionary
- (BOOL)loadPronunciationDictionary:(NTPronunciationDictionary *)dictionary
Parameters
dictionary |
Dictionary |
---|
Return Value
YES on succes, NO on failure
Discussion
Load pronunciation dictionary
Declared In
NTPocketSphinxDecoder.h
– savePronunciationDictionaryToFile:
Save the dictionary to a file
- (BOOL)savePronunciationDictionaryToFile:(NSString *)path
Parameters
path |
Path to write to |
---|
Return Value
YES on succes, NO on failure
Discussion
Save the dictionary to a file
Declared In
NTPocketSphinxDecoder.h
– addWord:withPhones:update:
Add word to the dictionary
- (BOOL)addWord:(NSString *)word withPhones:(NSString *)phones update:(BOOL)update
Parameters
word |
Word |
---|---|
phones |
Phonemes |
update |
If YES, update the search module (whichever one is currently active) to recognize the newly added word. If adding multiple words, it is more efficient to pass NO here in all but the last word. |
Return Value
YES on succes, NO on failure
Discussion
Add word to the dictionary
Declared In
NTPocketSphinxDecoder.h
– lookupWord:
Lookup a word
- (NSArray<NSString*> *)lookupWord:(NSString *)word
Parameters
word |
Word |
---|
Return Value
Array of phone strings or empty array if word not present.
Discussion
Lookup a word
Declared In
NTPocketSphinxDecoder.h
– setActiveSearchWithName:
Activates search with the provided name. The search must be added before.
- (BOOL)setActiveSearchWithName:(NSString *)name
Parameters
name |
Name |
---|
Return Value
YES on succes, NO on failure
Discussion
Activates search with the provided name. The search must be added before.
Declared In
NTPocketSphinxDecoder.h
– addSearch:
Adds new search. The search can be activated using @link -setActiveSearchWithName @/link
- (BOOL)addSearch:(NTSpeechSearch *)search
Parameters
search |
search |
---|
Return Value
Yes on succes, NO on failure
Discussion
Adds new search. The search can be activated using @link -setActiveSearchWithName @/link
Declared In
NTPocketSphinxDecoder.h
– removeSearchWithName:
Removes the search with the given name
- (BOOL)removeSearchWithName:(NSString *)name
Parameters
name |
Name |
---|
Return Value
Yes on succes, NO on failure
Discussion
Removes the search with the given name
Declared In
NTPocketSphinxDecoder.h
– searchWithName:
Get search with the given name.
- (NTSpeechSearch *)searchWithName:(NSString *)name
Parameters
name |
name |
---|
Return Value
Search if existing, otherwise nil
Discussion
Get search with the given name.
Declared In
NTPocketSphinxDecoder.h
– startUtterance
Start utterance processing.
- (BOOL)startUtterance
Return Value
YES on success, NO on error
Discussion
Start utterance processing.
This function should be called before any utterance data is passed to the decoder. It marks the start of a new utterance and reinitializes internal data structures.
Declared In
NTPocketSphinxDecoder.h
– endUtterance
End utterance processing.
- (BOOL)endUtterance
Return Value
YES on success, NO on error
Discussion
End utterance processing.
Declared In
NTPocketSphinxDecoder.h
– inSpeech
Checks if the last feed audio buffer contained speech.
- (BOOL)inSpeech
Return Value
YES if last buffer contained speech, NO otherwise
Discussion
Checks if the last feed audio buffer contained speech.
Declared In
NTPocketSphinxDecoder.h
– processData:samples:
Decode raw audio data.
- (int)processData:(SInt16 *)data samples:(size_t)numberOfSamples
Parameters
data |
Data |
---|---|
numberOfSamples |
Number of Samples |
Return Value
Number of frames of data searched, or <0 for error.
Discussion
Decode raw audio data.
Declared In
NTPocketSphinxDecoder.h
– processData:samples:noSearch:fullUtterance:
Decode raw audio data.
- (int)processData:(SInt16 *)data samples:(size_t)numberOfSamples noSearch:(BOOL)noSearch fullUtterance:(BOOL)isFullUtterance
Parameters
data |
Data |
---|---|
numberOfSamples |
Number of Samples |
noSearch |
If YES, perform feature extraction but don’t do any recognition yet. This may be necessary if your processor has trouble doing recognition in real-time. |
isFullUtterance |
If YES, this block of data is a full utterance worth of data. This may allow the recognizer to produce more accurate results. |
Return Value
Number of frames of data searched, or <0 for error.
Discussion
Decode raw audio data.
Declared In
NTPocketSphinxDecoder.h
– getHypothesis
Get hypothesis.
- (NTHypothesis *)getHypothesis
Return Value
Best hypothesis at this point in decoding. Nil if no hyp is available.
Discussion
Get hypothesis.
Declared In
NTPocketSphinxDecoder.h
– getHypothesisFinal:
Get hypothesis final flag.
- (NTHypothesis *)getHypothesisFinal:(BOOL *)isFinal
Parameters
isFinal |
Flag which is set to YES if hypothesis is reached final state in the grammar. |
---|
Return Value
Best hypothesis at this point in decoding. nil if no hypothesis is available.
Discussion
Get hypothesis final flag.
Declared In
NTPocketSphinxDecoder.h
+ pathToEnglishAcousticModel
Default English acoustic model
+ (NSString *)pathToEnglishAcousticModel
Return Value
Path to the default english acoustic model
Discussion
Default English acoustic model
Declared In
NTPocketSphinxDecoder.h
+ pathToCMUDict
CMU Pronunciation Dictionary
+ (NSString *)pathToCMUDict
Return Value
Path to the CMU Dictionary
Discussion
CMU Pronunciation Dictionary
Declared In
NTPocketSphinxDecoder.h
+ pathToCMULanguageModel
CMU Language Model (The one shipped with PocketSphinx)
+ (NSString *)pathToCMULanguageModel
Return Value
Path to the CMU Language model
Discussion
CMU Language Model (The one shipped with PocketSphinx)
Declared In
NTPocketSphinxDecoder.h
Other Methods
Extension Methods
internalSearches
@property (nonatomic, strong) NSMutableDictionary<NSString*NTSpeechSearch*> *internalSearches