-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTweak.xm
More file actions
30 lines (23 loc) · 935 Bytes
/
Tweak.xm
File metadata and controls
30 lines (23 loc) · 935 Bytes
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
#import <libactivator/libactivator.h>
#import <AVFoundation/AVFoundation.h>
@interface STActivatorListener : NSObject <LAListener> {}
@end
@implementation STActivatorListener
-(void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event {
@autoreleasepool {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"hh:mm a"];
NSString *formattedDateString = [dateFormatter stringFromDate:[NSDate date]];
[dateFormatter release];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:formattedDateString];
utterance.rate = 0.4;
AVSpeechSynthesizer *speechSynthesizer = [[[AVSpeechSynthesizer alloc] init] autorelease];
[speechSynthesizer speakUtterance:utterance];
}
}
+(void)load {
@autoreleasepool {
[LASharedActivator registerListener:[self new] forName:@"Speak current time"];
}
}
@end