OpenEars 㯠Politepix 社ããæä¾ããã¦ããããªã¼ã® iOS åãé³å£°èªèï¼é³å£°åæï¼Text to Speech, TTSï¼ã©ã¤ãã©ãªã§ãã
話ããè¨èãèªèããããå ¥åããæååãèªã¿ä¸ãããï¼mac ã® say ã³ãã³ãã¿ãããªãã®ï¼ãããã¨ãã§ãã¾ãã
試ãã¦ã¿ãã¨ããè¶
ç°¡åã«ä½¿ããã®ã§ãèªåã®ã¢ããªã« OpenEars ãå°å
¥ããæ¹æ³ãç´¹ä»ãã¾ãã
é³å£°åæã®å°å ¥æ¹æ³
ãã¬ã¼ã ã¯ã¼ã¯è¿½å ããããã¤ã³ãã¼ãã¨ãã£ãä¸è¬çãªã©ã¤ãã©ãªã®å°å
¥æé ãã®ããã°ãåºæ¬çã«ã¯ã¡ã½ããã1ã¤å¼ã¶ã ãã§å°å
¥ã§ãã¾ãã
1. ãã¬ã¼ã ã¯ã¼ã¯ãããã¸ã§ã¯ãã«è¿½å
解åãããã©ã«ãé ä¸ã«ããFrameworkãã©ã«ããã¨ããã¸ã§ã¯ãã«è¿½å ãã¾ãããã©ã«ãã«ã¯ OpenEars.frameworkãSlt.framework ã»ããè¨èªã¢ãã«ãè¾æ¸ãå ¥ã£ã¦ãã¾ãã
ã¾ããä¾åãã¬ã¼ã ã¯ã¼ã¯ã§ãã
- AVFoundation.framework
- AudioToolbox.framework
ãããã¸ã§ã¯ãã«è¿½å ãã¦ããã¾ãã
2. ããããã¤ã³ãã¼ã
#import <Slt/Slt.h> #import <OpenEars/FliteController.h>
3. ãªãã¸ã§ã¯ããçæ
FliteController, Slt ãªãã¸ã§ã¯ããçæãã¾ãã
ããããã£ãå®ç¾©ãã¦ããã
@property (strong, nonatomic) FliteController *fliteController; @property (strong, nonatomic) Slt *slt;
alloc / init ãã¾ãã
self.fliteController = [[FliteController alloc] init]; self.slt = [[Slt alloc] init];
4. say: ã¡ã½ãããã³ã¼ã«
ãã¨ã¯é³å£°åæã§çºå£°ããããæååã渡ã㦠say: ã¡ã½ãããã³ã¼ã«ããã ãã§ãã
[self.fliteController say:@"Hello world!" withVoice:self.slt];
ï¼è£è¶³ãã®ï¼ï¼æ¥æ¬èªãçºå£°ããã
OpenEars ï¼å°ãªãã¨ãä¸è¨ã®ä½¿ãæ¹ã§ã¯ï¼æ¥æ¬èªã«ã¯å¯¾å¿ãã¦ãã¾ãããããã¼ãåçã«æååã渡ããã¨ã§ããã£ã½ããããã¨ã¯ã§ãã¾ãã
[self.fliteController say:@"Ai ou es apuri kaihatsu. Tatsujinn no recipe hyaku. Hatsubai chuu" withVoice:self.slt];
ï¼è£è¶³ãã®ï¼ï¼å£°ãå¤ãã
Bitbucket ã« openearsextras ã¨ãããªãã¸ããªããããããã«å£°ãå¤ããããã®ãã¼ã¿ï¼.framework ã¨ãã¦æä¾ããã¦ããï¼ãç½®ãã¦ããã¾ãã
ãã¨ãã°ä¸è¨ã§ã¯ SLT.framework ãç¨ãã¾ããããopenearsextras ã®ä¸ã«ãã Awb.framework ãç¨ããã¨ãç·æ§ã®å£°ã§èªã¿ä¸ãããã¾ãã
å質ã«ã¤ãã¦
é³å£°åæã®å質ã¯ãè±èªã®å ´åã§ãããããããã§ããææãå¤ãã¾ã ããã¥ã¡ã³ãã詳ããèªãã§ãªãã®ã§ãããç´°ãããã¥ã¼ãã³ã°ãã§ããããã«ãªã£ã¦ããããããã¾ããã
é³å£°èªèã®å°å ¥æ¹æ³
æ¬ããã°ã« VocalKitの使い方 ã¨ããè¨äºãããã¾ãããå·çæãã3å¹´è¿ãçµã£ã¦ããã®ã§ãå 容ãå¤ããªã£ã¦ããå¯è½æ§ãããã¾ããVocalKit ã®ãªãã¸ããªã2年以ä¸æ´æ°ããã¦ãã¾ããã
ãã® OpenEars 㯠VocalKit ã¨åæ§ã«é³å£°èªèã¨ã³ã¸ã³ã¨ã㦠CMU Sphinx ã使ç¨ãã¦ããã®ã§ããã®ä»£æ¿ã«ãªãããã§ãã
å®è£ æ¹æ³ã¯ä¸è¨ã®éããé³é¿ã¢ãã«ãè¨èªè¾æ¸ã®è¨å®ããã£ãããé³å£°èªèã®å種ã¹ãã¼ã¿ã¹ãåãåãããã«ãããã³ã«ã®å®è£ ãå¿ è¦ã ã£ãããã¦ä¸è¦ç ©éã§ãããè¦ã¯ startListeningWithã ã¡ã½ãããå¼ãã§èªèçµæãåãåãã ãï¼çºè©±ã®æ¤åºã¨ãã¯åæã«ãã£ã¦ãããï¼ãªã®ã§ãã¨ã¦ãã·ã³ãã«ã§ãã
ï¼â»2014.1.30追è¨ï¼
æ¬è¨äºã«ããã³ã¼ãã¯OpenEarsææ°ãã¼ã¸ã§ã³ã«ããã¦ãã«ãã¨ã©ã¼ãèµ·ããç®æãããã¾ããææ°çã§ã®å®è£ æ¹æ³ã«ã¤ãã¦ã¯ä¸è¨è¨äºããåç §ãã ããã
1. ãã¬ã¼ã ã¯ã¼ã¯ãããã¸ã§ã¯ãã«è¿½å
ããã¯é³å£°åæã¨åæ§ã§ãã
2. ããããã¤ã³ãã¼ã
#import <OpenEars/LanguageModelGenerator.h> #import <OpenEars/PocketsphinxController.h>
3. ãããã³ã«ã¸ã®æºæ
@interface ã§ãé³å£°èªèã®å種ã¹ãã¼ã¿ã¹ãåãåãããã® OpenEarsEventsObserverDelegate ã¸ã®æºæ ã宣è¨ãã¦ããã
<OpenEarsEventsObserverDelegate>
å種ã¡ã½ãããå®è£
ãã¾ãã
- (void)pocketsphinxDidReceiveHypothesis:(NSString *)hypothesis recognitionScore:(NSString *)recognitionScore utteranceID:(NSString *)utteranceID { NSLog(@"The received hypothesis is %@ with a score of %@ and an ID of %@", hypothesis, recognitionScore, utteranceID); }
OpenEarsEventsObserverDelegate ãããã³ã«ã«ã¯å¤ãã®ã¡ã½ãããå®ç¾©ããã¦ãã¾ãããå
¨é¨ optional ãªã®ã§ãã¨ããããèªèçµæãåãåãããã®ä¸è¨ã¡ã½ãããå®è£
ãã¦ããã ãã§ãé°å²æ°ã¯ã¤ããããã¨æãã¾ãã
4. ãªãã¸ã§ã¯ããçæ
å種ããããã£ãå®ç¾©ãã¦ããã
@property (strong, nonatomic) NSString *lmPath; @property (strong, nonatomic) NSString *dicPath; @property (strong, nonatomic) PocketsphinxController *pocketsphinxController; @property (strong, nonatomic) OpenEarsEventsObserver *openEarsEventsObserver;
è¨èªã¢ãã«ï¼è¾æ¸ã®ãã¹ã¨ãå種ãªãã¸ã§ã¯ããä¿æãã¦ããã¾ããdelegate ããããã£ã®ã»ãããå¿ããã«ã
NSString *resorcePath = [[NSBundle mainBundle] resourcePath]; self.lmPath = [NSString stringWithFormat:@"%@/%@", resorcePath, @"OpenEars1.languagemodel"]; self.dicPath = [NSString stringWithFormat:@"%@/%@", resorcePath, @"OpenEars1.dic"]; self.pocketsphinxController = [[PocketsphinxController alloc] init]; self.openEarsEventsObserver = [[OpenEarsEventsObserver alloc] init]; [self.openEarsEventsObserver setDelegate:self];
5. èªèã¹ã¿ã¼ã
startListeningWithLanguageModelAtPath: ã¡ã½ãããã³ã¼ã«ããã¨é³å£°å ¥åãã¹ã¿ã¼ããããã¨ã¯åæã«çºè©±ãæ¤åºï¼ä¸å®ã¬ãã«ã®é³å£°å ¥åãæ¤åºãã¦çºè©±éå§ã¨å¤å®ãä¸å®æéã®ç©ºç½ãæ¤åºãã¦çºè©±çµäºã¨å¤å®ï¼ãã¦èªèãã¦ããã¾ãã
- (void)startListening { [self.pocketsphinxController startListeningWithLanguageModelAtPath:self.lmPath dictionaryAtPath:self.dicPath languageModelIsJSGF:NO]; }
çºè©±ãæ¤åºãããã³ã«èªèå¦çãèµ°ããæé 3ã§å®è£
ãã pocketsphinxDidReceiveHypothesis:recognitionScore:utteranceID: ãå¼ã°ãã¾ããHypothesis ãåè£ã®æååãrecognitionScore ã¯ãã®ã¹ã³ã¢ã§ãã
ï¼è£è¶³ãã®ï¼ï¼èªèçµäº
stopListening ã¡ã½ãããå¼ã¶ã¨èªèå¦çï¼é³å£°å ¥åã®å¾ ã¡åãã¨ãèªèå¦çï¼ãçµäºãã¾ãã
[self.pocketsphinxController stopListening];
ï¼è£è¶³ãã®ï¼ï¼è¨èªã¢ãã«ã®åççæ
LanguageModelGenerator ãç¨ããã¨ãèªèãããè¨èã®é åããè¨èªã¢ãã«ãåçã«çæãããã¨ãã§ãã¾ãã
èªèãããè¨èï¼åèªï¼ãã¬ã¼ãºï¼ã®é åãçæãã
NSArray *words = @[ @"SUNDAY", @"MONDAY", @"TUESDAY", @"WEDNESDAY", @"THURSDAY", @"FRIDAY", @"SATURDAY", @"QUIDNUNC", @"CHANGE MODEL", ];
generateLanguageModelFromArray:withFilesNamed: ã¡ã½ãããã³ã¼ã«ãã¾ãã
LanguageModelGenerator *lmGenerator = [[LanguageModelGenerator alloc] init]; NSError *error = [lmGenerator generateLanguageModelFromArray:words withFilesNamed:@"OpenEarsDynamicGrammar"]; if (error.code != noErr) { NSLog(@"Error: %@",[error localizedDescription]); } else { NSDictionary *languageGeneratorResults = [error userInfo]; self.lmPath = [languageGeneratorResults objectForKey:@"LMPath"]; self.dicPath = [languageGeneratorResults objectForKey:@"DictionaryPath"]; }
NSError ã® userInfo ã«å¦ççµæãå ¥ã£ã¦ãããã¨ããã®ã¯ã¡ãã£ã¨å¤ãªæãããã¾ãããã