KeenASR Framework v2.2 (c662ac9)
Keen Research
Loading...
Searching...
No Matches
KIOSRecognizer.h
1//
2// KIOSRecognizer.h
3// KeenASR
4//
5// Created by Ognjen Todic on 2/29/16.
6// Copyright © 2016 Keen Research. All rights reserved.
7//
8
9#ifndef KIOSRecognizer_h
10#define KIOSRecognizer_h
11
12@class KIOSRecognizer;
13@class KIOSResponse;
14
15// @name Constants
16
18typedef NS_ENUM(NSInteger, KIOSRecognizerType) {
20 KIOSRecognizerTypeUnknown = -1,
22 KIOSRecognizerTypeGMM,
24 KIOSRecognizerTypeNNet,
26 KIOSRecognizerTypeNNet3,
28 KIOSRecognizerTypeNNet3Chain
29};
30
31
33typedef NS_ENUM(NSInteger, KIOSRecognizerLogLevel) {
35 KIOSRecognizerLogLevelDebug=0,
37 KIOSRecognizerLogLevelInfo,
39 KIOSRecognizerLogLevelWarning,
40};
41
43typedef NS_ENUM(NSInteger, KIOSRecognizerState) {
46 KIOSRecognizerStateNeedsDecodingGraph=0,
48 KIOSRecognizerStateReadyToListen,
50 KIOSRecognizerStateListening,
56 KIOSRecognizerStateFinalProcessing,
57};
58
62//typedef NS_ENUM(NSInteger, KIOSResponseDataKey) {
64// KIOSResponseDataKeyExpectedResult,
66// KIOSResponseDataKeyPrompt,
68// KIOSResponseDataKeyCustomJSONData,
69//};
70
76typedef NS_ENUM(NSInteger, KIOSVadParameter) {
79 KIOSVadTimeoutForNoSpeech=0,
80
83 KIOSVadTimeoutEndSilenceForGoodMatch,
84
87 KIOSVadTimeoutEndSilenceForAnyMatch,
88
92 KIOSVadTimeoutMaxDuration
93};
94
95
96
97/* ################## KIOSResult #############*/
98
99@class KIOSWord;
100
103@interface KIOSResult : NSObject
104
106@property(nonatomic, readonly, nonnull) NSString *text;
107
109@property(nonatomic, readonly, nonnull) NSString *cleanText;
110
112@property(nonatomic, strong, readonly, nullable) NSArray<KIOSWord *> *words;
113
114@property(nonatomic, readonly, nullable) NSNumber *confidence DEPRECATED_MSG_ATTRIBUTE("Deprecated");
115
116
117- (nonnull NSString *)description;
118
140- (nullable NSString *)toJSON;
141
142- (nullable NSDictionary *)toDictionary;
143
144@end
145
146
147@class KIOSPhone;
154@interface KIOSWord : NSObject
156@property (nonatomic, readonly, nonnull) NSString *text;
157
159@property (nonatomic, strong, nullable, readonly) NSNumber *startTime;
160
162@property (nonatomic, strong, nullable, readonly) NSNumber *duration;
163
164@property (nonatomic, strong, nullable, readonly) NSNumber *confidence
165__deprecated_msg("Deprecated. Result will most likely contain <SPOKEN_NOISE> word");
166
168@property(nonatomic, strong, nullable) NSArray<KIOSPhone *> *phones;
169
170
172@property (nonatomic, assign, readonly, getter=isTag) BOOL tag
173__deprecated_msg("Temporarily deprecated");
174
175- (nonnull NSString *)description;
176
177@end
178
185@interface KIOSPhone : NSObject
186@property (nonatomic, readonly, nonnull) NSString *text;
187
188@property (nonatomic, strong, nullable, readonly) NSNumber *startTime;
189
190@property (nonatomic, strong, nullable, readonly) NSNumber *duration;
191
192@property (nonatomic, strong, nullable, readonly) NSNumber *pronunciationScore;
193
194@end
195
196/* ################## KIOSRecognizerDelegate #############*/
197
198
209@protocol KIOSRecognizerDelegate <NSObject>
210
212
226
228
229@optional
235- (void)triggerPhraseDetected:(nonnull KIOSRecognizer *)recognizer;
236
237- (void)recognizerTriggerPhraseDetectedForRecognizer:(nonnull KIOSRecognizer *)recognizer
238__deprecated_msg("Please see triggerPhraseDetected");
239;
240
241
250- (void)recognizerPartialResult:(nonnull KIOSResult *)result
251 forRecognizer:(nonnull KIOSRecognizer *)recognizer;
252
253
261- (void)recognizerFinalResponse:(nonnull KIOSResponse *)response
262 forRecognizer:(nonnull KIOSRecognizer *)recognizer;
263
264
279- (void)recognizerReadyToListenAfterInterrupt:(nonnull KIOSRecognizer *)recognizer;
280
281
283// is about to re-init its audio stack. This callback will be called *before*
284// KIOSRecognizer audio stack is reinitialized and you would use it to setup your
285// own audio stack, if necessary.
286//
287// */
288//- (void)setupAppAudioAfterInterrupt;
289
290
291@end
292
293
294
295/* ################## KIOSRecognizer #############*/
296
346@interface KIOSRecognizer : NSObject
347
348
350
357
358
360@property(nonatomic, weak, nullable) id<KIOSRecognizerDelegate> delegate;
361
364@property(assign, readonly) KIOSRecognizerState recognizerState;
365
368@property(nonatomic, readonly, nonnull) NSString *asrBundlePath;
369
373@property(nonatomic, readonly, nonnull) NSString *asrBundleName;
374
386@property(nonatomic, readonly, copy, nullable) NSString *asrBundleLang;
387
389@property(nonatomic, readonly, nullable) NSString *currentDecodingGraphName;
390
392@property(nonatomic, readonly, nullable) NSString *recordingsDir;
393
395@property(nonatomic, readonly, nullable) NSString *miscDataDirectory;
396
401//@property(nonatomic, readonly, nonnull) NSString *langCode; // TODO
402
414@property(nonatomic, assign) BOOL rescore;
415
416
422
423
449
450+ (BOOL)initWithASRBundle:(nonnull NSString *)bundleName;
451
452
469
470+ (BOOL)initWithASRBundleAtPath:(nonnull NSString *)pathToASRBundle;
471
472
473//+ (instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead")));
474//- (instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead")));
475+ (nullable instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead")));
476
490
491+ (BOOL)teardown;
492
493
508- (void) setVadGating:(BOOL)value;
509
510
527- (BOOL)prepareForListeningWithDecodingGraphWithName:(nonnull NSString *)dgName
528 withGoPComputation:(BOOL)computeGoP;
529
530
551- (BOOL)prepareForListeningWithDecodingGraphAtPath:(nonnull NSString *)pathToDecodingGraphDirectory
552 withGoPComputation:(BOOL)computeGoP;
553
574- (BOOL)prepareForListeningWithContextualDecodingGraphWithName:(nonnull NSString *)dgName
575 andContextId:(nonnull NSNumber *) contextId
576 withGoPComputation:(BOOL)computeGoP;
577
601- (BOOL)prepareForListeningWithContextualDecodingGraphAtPath:(nonnull NSString *)dgPath
602 andContextId:(nonnull NSNumber *)contextId
603 withGoPComputation:(BOOL)computeGoP;
604
605
606
653- (BOOL)startListening:(NSString *_Nullable*_Nullable) responseId;
654
655
656
657
664
665
668
695- (void)adaptToSpeakerWithName:(nonnull NSString *)speakerName;
696
697
732
733
741
742
743
748
754+ (BOOL)removeSpeakerAdaptationProfiles:(nonnull NSString *)speakerName;
755
756
757/*
758 @name Audio Interruption Management
759 When audio interruption occurs, due to a phone call, SMS, etc. SDK will
760 automatically stop listening if necessary, and tear down the internal audio setup.
761 When interrupt ends audio will be automatically reinitialized. You can define
762 a callback method recognizerReadyToListenAfterInterrupt: to track when these
763 changes happen.
764 */
765
768//- (void)audioInterruptionEndedHandler:(nonnull void (^)(void))callbackBlock;
769
770
787@property(nonatomic, assign, setter=setHandleNotifications:) BOOL handleNotifications;
788
789
798- (float)inputLevel;
799
806
807
822- (BOOL)performEchoCancellation:(BOOL)value;
823
824
825
831- (void)setBluetoothA2DPOutput:(BOOL)value;
832
833
834
853
854
864
870
872
885- (void)setVADParameter:(KIOSVadParameter)parameter toValue:(float)value;
886
887
888
890
892+ (nonnull NSString *)version;
893
894
901
902+ (void)setLogLevel:(KIOSRecognizerLogLevel)logLevel;
903
904
905
907
908@property(nonatomic, readonly, nullable) NSString *lastRecordingFilename
909__deprecated_msg("Please see KIOSResponse for more details");
910
911@property(nonatomic, readonly, nullable) NSString *lastJSONMetadataFilename
912__deprecated_msg("Please see KIOSResponse for more details");
913
914- (BOOL)prepareForListeningWithCustomDecodingGraphWithName:(nonnull NSString *)dgName
915__deprecated_msg("Please use prepareForListeningWithDecodingGraphWithName");
916
917- (BOOL)prepareForListeningWithCustomDecodingGraphAtPath:(nonnull NSString *)pathToDecodingGraphDirectory
918__deprecated_msg("Please use prepareForListeningWithDecodingGraphAtPath");
919
920- (BOOL)startListeningFromAudioFile:(nonnull NSString *)pathToAudioFile
921__deprecated_msg("Temporarily deprecated; methods to feed audio directly to the recognizer will be provided in the future");
922
923
924//- (BOOL)setResponseDataForKey:(KIOSResponseDataKey) key
925// value:(nonnull NSObject *) value
926//__deprecated_msg("Temporarily disabled");
927
928
929- (void)enableBluetoothOutput:(BOOL)value __attribute__((deprecated("use setBluetoothA2DPOutput instead")));
930
931- (void)enableBluetoothA2DPOutput:(BOOL)value __attribute__((deprecated("use setBluetoothA2DPOutput instead")));
932
933@end
934
935#endif /* KIOSRecognizer_h */
Definition KIOSRecognizer.h:186
Definition KIOSRecognizer.h:347
NSString * miscDataDirectory
Definition KIOSRecognizer.h:395
BOOL handleNotifications
Definition KIOSRecognizer.h:787
BOOL removeAllSpeakerAdaptationProfiles()
BOOL deactivateAudioStack()
void reinitAudioStack()
BOOL echoCancellationAvailable()
nonnull NSString * version()
NSString * asrBundleLang
Language code of the ASR Bundle backing this recognizer.
Definition KIOSRecognizer.h:386
KIOSRecognizerState recognizerState
Definition KIOSRecognizer.h:364
void resetSpeakerAdaptation()
nullable KIOSRecognizer * sharedInstance()
NSString * asrBundleName
Definition KIOSRecognizer.h:373
NSString * recordingsDir
Definition KIOSRecognizer.h:392
NSString * asrBundlePath
Definition KIOSRecognizer.h:368
BOOL activateAudioStack()
BOOL rescore
Definition KIOSRecognizer.h:414
void saveSpeakerAdaptationProfile()
NSString * currentDecodingGraphName
Definition KIOSRecognizer.h:389
id< KIOSRecognizerDelegate > delegate
Definition KIOSRecognizer.h:360
Definition KIOSResponse.h:19
Definition KIOSRecognizer.h:104
nullable NSString * toJSON()
NSString * cleanText
Definition KIOSRecognizer.h:109
NSString * text
Definition KIOSRecognizer.h:106
NSArray< KIOSWord * > * words
Definition KIOSRecognizer.h:112
Definition KIOSRecognizer.h:155
NSString * text
Definition KIOSRecognizer.h:156
BOOL tag __deprecated_msg("Temporarily deprecated")
NSNumber * duration
Definition KIOSRecognizer.h:162
NSNumber * startTime
Definition KIOSRecognizer.h:159
NSArray< KIOSPhone * > * phones
Definition KIOSRecognizer.h:168