New: add(words)
API and some code improvements
#34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch has some general code improvements (fix access rights, prefer
guard
overif
, etc) and three important changes:Add a new API to add words to the recognition dictionary on runtime. Be aware that new words can't be added while a recognition is in progress. You should add new words before start a recognition process.
The API expect an array of tuples of String with the form:
(word: "HELLO", phones: "HH EH L OW")
. The first component is the word in plain English. The second is the pronunciation phones as appear in the cmudict (more here: http://www.speech.cs.cmu.edu/tools/lextool.html) In the future the second component should be calculatedThe decode functions now throw exceptions when apply.
There is a new approach to the live decode logic with
AVAudioConverter
. The idea is read the data in a more appealing format for iOS (float 32, 16000 Hz) and convert it to the Sphinx format (int 16, 16000Hz).AVAudioConverter
is only available from iOS 9.0 so the deployment target needs to change. This should address Device does not support required sample rate recording #24 and ps_add_word #33Please let everybody know your thoughts about this changes.
Thanks!