Here is an Example of How to Use CeedVocal SDK Step by Step
1. Loading the Acoustic Model
Loading the acoustic model for the appropriate language is needed before any speech recognition can happen. Add both .enchmm and .fastied files to the resources of you app and create the recognizer with this call:
speechRecognizer = [[CVSpeechRecognizer alloc] initWithLanguage:CV_LANGUAGE_ENGLISH acousticModel:[[NSBundle mainBundle] pathForResource:@"ceedmodel-en" ofType:@"enchmm"]];
2. Setting the Recognizer Delegate
To be notified when speech is recognized, you should add a delegate to the recognizer. This is done this way (assuming self is the delegate):
speechRecognizer.delegate = self;
result = [NSMutableString new];
for(id res in [recognizer recognizedPhrases])
NSLog(@"%@ (score=%f)", res, [recognizer scoreForRecognizedPhrase:res]);
[(NSMutableString*)result appendString:[NSString stringWithFormat:@"%d. %@ (score=%f)\n", ++i, res, [recognizer scoreForRecognizedPhrase:res]]];
// Call to UI on main thread only !!!
[self performSelectorOnMainThread:@selector(updateResult:) withObject:nil waitUntilDone:YES];
// If you need to stop the recognizer, do it on main thread
//[self performSelectorOnMainThread:@selector(stopRecognition:) withObject:nil waitUntilDone:YES];
This method will be invoked from the recognizer thread. Therefore, you should not make any direct UI call from there, but instead do it through a main thread invocation. The same holds true if you want to stop the recognizer (only from the main thread).
3. Adding some Words to be Recognized
Adding the words to be recognized is next done. Do not forget to call prepareRecognizer after that.
[speechRecognizer addPhrase:@"flower"]; [speechRecognizer addPhrase:@"sun"]; [speechRecognizer addPhrase:@"mountain"]; [speechRecognizer addPhrase:@"river"]; [speechRecognizer addPhrase:@"sky"]; [speechRecognizer addPhrase:@"clouds"]; [speechRecognizer prepareRecognizer];
4. Starting Speech Recognition
Starting the recognizer is done that way:
© 2008–2017 Creaceed SPRL. Apple, Mac, Macbook, iOS, OS X, the Apple logo, iPad, and iPhone are trademarks of Apple Inc., registered in the U.S. and other countries. App Store is a service mark of Apple Inc.