blob: e38b51745ea662018c940e0ab6988be008ca180b (
plain)
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
|
// SDLSpeak.m
//
#import "SDLSpeak.h"
#import "SDLNames.h"
#import "SDLTTSChunk.h"
#import "SDLTTSChunkFactory.h"
NS_ASSUME_NONNULL_BEGIN
@implementation SDLSpeak
- (instancetype)init {
if (self = [super initWithName:SDLNameSpeak]) {
}
return self;
}
- (instancetype)initWithTTS:(NSString *)ttsText {
NSMutableArray *ttsChunks = [SDLTTSChunk textChunksFromString:ttsText];
return [self initWithTTSChunks:ttsChunks];
}
- (instancetype)initWithTTSChunks:(NSArray<SDLTTSChunk *> *)ttsChunks {
self = [self init];
if (!self) {
return nil;
}
self.ttsChunks = [ttsChunks mutableCopy];
return self;
}
- (void)setTtsChunks:(NSMutableArray<SDLTTSChunk *> *)ttsChunks {
if (ttsChunks != nil) {
[parameters setObject:ttsChunks forKey:SDLNameTTSChunks];
} else {
[parameters removeObjectForKey:SDLNameTTSChunks];
}
}
- (NSMutableArray<SDLTTSChunk *> *)ttsChunks {
NSMutableArray<SDLTTSChunk *> *array = [parameters objectForKey:SDLNameTTSChunks];
if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) {
return array;
} else {
NSMutableArray<SDLTTSChunk *> *newList = [NSMutableArray arrayWithCapacity:[array count]];
for (NSDictionary<NSString *, id> *dict in array) {
[newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSDictionary *)dict]];
}
return newList;
}
}
@end
NS_ASSUME_NONNULL_END
|