forked from KingOfBrian/VocalKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVKController.m
More file actions
103 lines (79 loc) · 2.29 KB
/
VKController.m
File metadata and controls
103 lines (79 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// VKController.m
// VocalKit
//
// Created by Brian King on 4/29/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "VKController.h"
#import "VKPocketSphinxDecoder.h"
#import "VKAQRecorder.h"
NSString * const VKRecognizedPhraseNotification = @"VKRecognizedPhraseNotification";
NSString * const VKRecognizedPhraseNotificationTextKey = @"VKRecognizedPhraseNotificationTextKey";
NSString * const VKRecognizedPhraseNotificationIDKey = @"VKRecognizedPhraseNotificationIDKey";
NSString * const VKRecognizedPhraseNotificationScoreKey = @"VKRecognizedPhraseNotificationScoreKey";
@interface VKController(Private)
- (void) configureConnector;
@end
@implementation VKController
- (id) initWithType:(VKDecoderType)dType configFile:(NSString*)configFile {
self = [super init];
if (self) {
if (type == VKDecoderTypePocketSphinx) {
VKPocketSphinxDecoder *psDecoder = [[VKPocketSphinxDecoder alloc] initWithConfigFile:configFile];
decoder = psDecoder;
type = dType;
} else {
NSAssert(false, @"Unsupported Decoder Type");
}
[self configureConnector];
}
return self;
}
- (void) setMode:(VKDecoderMode)dMode {
mode = dMode;
}
- (void) setConfigString:(NSString*)str forKey:(NSString*)key {
VKPocketSphinxDecoder *psDecoder = (VKPocketSphinxDecoder*)decoder;
[psDecoder setConfigString:str forKey:key];
}
- (void) setConfigInt:(int)iValue forKey:(NSString*)key {
VKPocketSphinxDecoder *psDecoder = (VKPocketSphinxDecoder*)decoder;
[psDecoder setConfigInt:iValue forKey:key];
}
- (void) setConfigFloat:(float)fValue forKey:(NSString*)key {
VKPocketSphinxDecoder *psDecoder = (VKPocketSphinxDecoder*)decoder;
[psDecoder setConfigFloat:fValue forKey:key];
}
- (void) configureConnector {
connector = [[VKAQRecorder alloc] initWithDecorder:decoder];
}
- (void) startListening {
[decoder startDecode];
[connector startListening];
}
- (void) stopListening {
[connector stopListening];
[decoder stopDecode];
}
- (BOOL) isListening {
return [connector listening];
}
- (void) postNotificationOfRecognizedText {
[decoder postNotificationOfRecognizedText];
}
- (void) showListened {
[decoder printDebug];
}
- (void) dealloc {
if (decoder) {
[decoder release];
decoder = nil;
}
if (connector) {
[connector release];
connector = nil;
}
[super dealloc];
}
@end