KeenASR Framework v2.1 (8b72cc4)
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
376@property(nonatomic, readonly, nullable) NSString *currentDecodingGraphName;
377
379@property(nonatomic, readonly, nullable) NSString *recordingsDir;
380
382@property(nonatomic, readonly, nullable) NSString *miscDataDirectory;
383
388//@property(nonatomic, readonly, nonnull) NSString *langCode; // TODO
389
401@property(nonatomic, assign) BOOL rescore;
402
403
409
410
436
437+ (BOOL)initWithASRBundle:(nonnull NSString *)bundleName;
438
439
456
457+ (BOOL)initWithASRBundleAtPath:(nonnull NSString *)pathToASRBundle;
458
459
460//+ (instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead")));
461//- (instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead")));
462+ (nullable instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead")));
463
477
478+ (BOOL)teardown;
479
480
495- (void) setVadGating:(BOOL)value;
496
497
514- (BOOL)prepareForListeningWithDecodingGraphWithName:(nonnull NSString *)dgName
515 withGoPComputation:(BOOL)computeGoP;
516
517
538- (BOOL)prepareForListeningWithDecodingGraphAtPath:(nonnull NSString *)pathToDecodingGraphDirectory
539 withGoPComputation:(BOOL)computeGoP;
540
561- (BOOL)prepareForListeningWithContextualDecodingGraphWithName:(nonnull NSString *)dgName
562 andContextId:(nonnull NSNumber *) contextId
563 withGoPComputation:(BOOL)computeGoP;
564
588- (BOOL)prepareForListeningWithContextualDecodingGraphAtPath:(nonnull NSString *)dgPath
589 andContextId:(nonnull NSNumber *)contextId
590 withGoPComputation:(BOOL)computeGoP;
591
592
593
640- (BOOL)startListening:(NSString *_Nullable*_Nullable) responseId;
641
642
643
644
651
652
655
682- (void)adaptToSpeakerWithName:(nonnull NSString *)speakerName;
683
684
719
720
728
729
730
735
741+ (BOOL)removeSpeakerAdaptationProfiles:(nonnull NSString *)speakerName;
742
743
744/*
745 @name Audio Interruption Management
746 When audio interruption occurs, due to a phone call, SMS, etc. SDK will
747 automatically stop listening if necessary, and tear down the internal audio setup.
748 When interrupt ends audio will be automatically reinitialized. You can define
749 a callback method recognizerReadyToListenAfterInterrupt: to track when these
750 changes happen.
751 */
752
755//- (void)audioInterruptionEndedHandler:(nonnull void (^)(void))callbackBlock;
756
757
774@property(nonatomic, assign, setter=setHandleNotifications:) BOOL handleNotifications;
775
776
785- (float)inputLevel;
786
793
794
809- (BOOL)performEchoCancellation:(BOOL)value;
810
811
812
818- (void)setBluetoothA2DPOutput:(BOOL)value;
819
820
821
840
841
851
857
859
872- (void)setVADParameter:(KIOSVadParameter)parameter toValue:(float)value;
873
874
875
877
879+ (nonnull NSString *)version;
880
881
888
889+ (void)setLogLevel:(KIOSRecognizerLogLevel)logLevel;
890
891
892
894
895@property(nonatomic, readonly, nullable) NSString *lastRecordingFilename
896__deprecated_msg("Please see KIOSResponse for more details");
897
898@property(nonatomic, readonly, nullable) NSString *lastJSONMetadataFilename
899__deprecated_msg("Please see KIOSResponse for more details");
900
901- (BOOL)prepareForListeningWithCustomDecodingGraphWithName:(nonnull NSString *)dgName
902__deprecated_msg("Please use prepareForListeningWithDecodingGraphWithName");
903
904- (BOOL)prepareForListeningWithCustomDecodingGraphAtPath:(nonnull NSString *)pathToDecodingGraphDirectory
905__deprecated_msg("Please use prepareForListeningWithDecodingGraphAtPath");
906
907- (BOOL)startListeningFromAudioFile:(nonnull NSString *)pathToAudioFile
908__deprecated_msg("Temporarily deprecated; methods to feed audio directly to the recognizer will be provided in the future");
909
910
911//- (BOOL)setResponseDataForKey:(KIOSResponseDataKey) key
912// value:(nonnull NSObject *) value
913//__deprecated_msg("Temporarily disabled");
914
915
916- (void)enableBluetoothOutput:(BOOL)value __attribute__((deprecated("use setBluetoothA2DPOutput instead")));
917
918- (void)enableBluetoothA2DPOutput:(BOOL)value __attribute__((deprecated("use setBluetoothA2DPOutput instead")));
919
920@end
921
922#endif /* KIOSRecognizer_h */
Definition KIOSRecognizer.h:186
Definition KIOSRecognizer.h:347
NSString * miscDataDirectory
Definition KIOSRecognizer.h:382
BOOL handleNotifications
Definition KIOSRecognizer.h:774
BOOL removeAllSpeakerAdaptationProfiles()
BOOL deactivateAudioStack()
void reinitAudioStack()
BOOL echoCancellationAvailable()
nonnull NSString * version()
KIOSRecognizerState recognizerState
Definition KIOSRecognizer.h:364
void resetSpeakerAdaptation()
nullable KIOSRecognizer * sharedInstance()
NSString * asrBundleName
Definition KIOSRecognizer.h:373
NSString * recordingsDir
Definition KIOSRecognizer.h:379
NSString * asrBundlePath
Definition KIOSRecognizer.h:368
BOOL activateAudioStack()
BOOL rescore
Definition KIOSRecognizer.h:401
void saveSpeakerAdaptationProfile()
NSString * currentDecodingGraphName
Definition KIOSRecognizer.h:376
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