problems using generateGrammarFromDictionary

Home Forums OpenEars problems using generateGrammarFromDictionary

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)

  • Author
    Posts
  • #1022081
    geofftowell
    Participant

    I am trying to use the new generateGrammarFromDictionary command on v1.71. The problem I am having is that the app seems to simply hang during pocketSphinx startup.

    To get started, I just modified the sample code, touching only the viewDidLoad method, as follows:

    – (void)viewDidLoad {
    [super viewDidLoad];
    [OpenEarsLogging startOpenEarsLogging];
    self.restartAttemptsDueToPermissionRequests = 0;
    self.startupFailedDueToLackOfPermissions = FALSE;

    //[OpenEarsLogging startOpenEarsLogging]; // Uncomment me for OpenEarsLogging

    [self.openEarsEventsObserver setDelegate:self]; // Make this class the delegate of OpenEarsObserver so we can get all of the messages about what OpenEars is doing.

    // This is the language model we’re going to start up with. The only reason I’m making it a class property is that I reuse it a bunch of times in this example,
    // but you can pass the string contents directly to PocketsphinxController:startListeningWithLanguageModelAtPath:dictionaryAtPath:languageModelIsJSGF:

    NSArray *firstLanguageArray = [[NSArray alloc] initWithArray:[NSArray arrayWithObjects: // All capital letters.
    @”ONE”, @”TWO”, @”TWENTY”, @”10″, @”30″, @”24″,
    @”HELLO”, @”COMPUTER”, @”GREETINGS”, @”ROBOT”
    @”TWENTY FIVE”,
    @”BACKWARD”,
    @”CHANGE”,
    @”FORWARD”,
    @”GO”,
    @”MOVE”, @”EXECUTE”, @”DO”, @”IT”, @”THANK”, @”YOU”,
    @”LEFT”,
    @”RIGHT”,
    nil]];

    LanguageModelGenerator *languageModelGenerator = [[LanguageModelGenerator alloc] init];

    NSError *error = [languageModelGenerator generateLanguageModelFromArray:firstLanguageArray withFilesNamed:@”FirstOpenEarsDynamicLanguageModel” forAcousticModelAtPath:[AcousticModel pathToModel:@”AcousticModelEnglish”]]; // Change “AcousticModelEnglish” to “AcousticModelSpanish” in order to create a language model for Spanish recognition instead of English.

    NSDictionary *dd = @{
    ThisWillBeSaidOnce : @[
    @{ OneOfTheseCanBeSaidOnce : @[@”HELLO COMPUTER”, @”GREETINGS ROBOT”]},
    @{ OneOfTheseWillBeSaidOnce : @[@”DO THE FOLLOWING”, @”INSTRUCTION”]},
    @{ OneOfTheseWillBeSaidOnce : @[@”GO”, @”MOVE”]},
    @{ThisWillBeSaidWithOptionalRepetitions : @[
    @{ OneOfTheseWillBeSaidOnce : @[@”10″, @”20″,@”30″]},
    @{ OneOfTheseWillBeSaidOnce : @[@”LEFT”, @”RIGHT”, @”FORWARD”]}
    ]},
    @{ OneOfTheseWillBeSaidOnce : @[@”EXECUTE”, @”DO IT”]},
    @{ ThisCanBeSaidOnce : @[@”THANK YOU”]}
    ]
    };
    NSError *error2 = [languageModelGenerator generateGrammarFromDictionary:dd withFilesNamed:@”FirstOpenEarsDynamicLanguageModelG” forAcousticModelAtPath:[AcousticModel pathToModel:@”AcousticModelEnglish”]];

    // no changes past this point

    As I understand it, this grammar should accept statements like
    “hello computer do the following move 10 left execute”

    it should not accept statements like:
    10 10 10 left left left

    In all my testing, I have been unable to get the grammar to be actually used. I have the feeling that I am missing something pretty trivial, but cannot figure what that is.

    Here is a log taken from a run on the simulator. The behavior on an iPad is essentially identical.
    2014-07-28 11:55:50.943 OpenEarsSampleApp[3012:60b] Starting OpenEars logging for OpenEars version 1.7 on 32-bit device: iPad Simulator running iOS version: 7.100000
    2014-07-28 11:55:50.944 OpenEarsSampleApp[3012:60b] acousticModelPath is /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle
    2014-07-28 11:55:50.946 OpenEarsSampleApp[3012:60b] Starting dynamic language model generation
    2014-07-28 11:55:50.947 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/FirstOpenEarsDynamicLanguageModel.corpus for reading
    2014-07-28 11:55:50.947 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/FirstOpenEarsDynamicLanguageModel_pipe.txt for writing
    2014-07-28 11:55:50.948 OpenEarsSampleApp[3012:60b] Starting text2wfreq_impl
    2014-07-28 11:55:50.951 OpenEarsSampleApp[3012:60b] Done with text2wfreq_impl
    2014-07-28 11:55:50.952 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/FirstOpenEarsDynamicLanguageModel_pipe.txt for reading.
    2014-07-28 11:55:50.952 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/FirstOpenEarsDynamicLanguageModel.vocab for reading.
    2014-07-28 11:55:50.952 OpenEarsSampleApp[3012:60b] Starting wfreq2vocab
    2014-07-28 11:55:50.953 OpenEarsSampleApp[3012:60b] Done with wfreq2vocab
    2014-07-28 11:55:50.953 OpenEarsSampleApp[3012:60b] Starting text2idngram
    2014-07-28 11:55:50.956 OpenEarsSampleApp[3012:60b] Done with text2idngram
    2014-07-28 11:55:50.956 OpenEarsSampleApp[3012:60b] Starting idngram2lm

    2014-07-28 11:55:50.958 OpenEarsSampleApp[3012:60b] Done with idngram2lm
    2014-07-28 11:55:50.958 OpenEarsSampleApp[3012:60b] Starting sphinx_lm_convert
    2014-07-28 11:55:50.960 OpenEarsSampleApp[3012:60b] Finishing sphinx_lm_convert
    2014-07-28 11:55:50.961 OpenEarsSampleApp[3012:60b] Done creating language model with CMUCLMTK in 0.014744 seconds.
    2014-07-28 11:55:50.982 OpenEarsSampleApp[3012:60b] The word 10 was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:50.982 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word 10
    2014-07-28 11:55:50.983 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:50.983 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase 10 which doesn’t appear in the dictionary
    2014-07-28 11:55:51.003 OpenEarsSampleApp[3012:60b] The word 24 was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.003 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word 24
    2014-07-28 11:55:51.003 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.004 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase 24 which doesn’t appear in the dictionary
    2014-07-28 11:55:51.025 OpenEarsSampleApp[3012:60b] The word 30 was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.025 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word 30
    2014-07-28 11:55:51.026 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.026 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase 30 which doesn’t appear in the dictionary
    2014-07-28 11:55:51.046 OpenEarsSampleApp[3012:60b] The word ROBOTTWENTY was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.047 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word ROBOTTWENTY
    2014-07-28 11:55:51.047 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.047 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase ROBOTTWENTY which doesn’t appear in the dictionary
    2014-07-28 11:55:51.053 OpenEarsSampleApp[3012:60b] I’m done running performDictionaryLookup and it took 0.088563 seconds
    2014-07-28 11:55:51.054 OpenEarsSampleApp[3012:60b] I’m done running dynamic language model generation and it took 0.109420 seconds
    2014-07-28 11:55:51.080 OpenEarsSampleApp[3012:60b] The word 10 was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.081 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word 10
    2014-07-28 11:55:51.081 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.081 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase 10 which doesn’t appear in the dictionary
    2014-07-28 11:55:51.100 OpenEarsSampleApp[3012:60b] The word 20 was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.100 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word 20
    2014-07-28 11:55:51.101 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.101 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase 20 which doesn’t appear in the dictionary
    2014-07-28 11:55:51.120 OpenEarsSampleApp[3012:60b] The word 30 was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.120 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word 30
    2014-07-28 11:55:51.120 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.121 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase 30 which doesn’t appear in the dictionary
    2014-07-28 11:55:51.140 OpenEarsSampleApp[3012:60b] I’m done running performDictionaryLookup and it took 0.077583 seconds
    2014-07-28 11:55:51.142 OpenEarsSampleApp[3012:60b] Dynamic language generator completed successfully, you can find your new files FirstOpenEarsDynamicLanguageModel.DMP
    and
    FirstOpenEarsDynamicLanguageModel.dic
    at the paths
    /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/FirstOpenEarsDynamicLanguageModel.DMP
    and
    /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/FirstOpenEarsDynamicLanguageModel.dic
    2014-07-28 11:55:51.142 OpenEarsSampleApp[3012:60b] acousticModelPath is /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle
    2014-07-28 11:55:51.143 OpenEarsSampleApp[3012:60b] Starting dynamic language model generation
    2014-07-28 11:55:51.144 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/SecondOpenEarsDynamicLanguageModel.corpus for reading
    2014-07-28 11:55:51.152 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/SecondOpenEarsDynamicLanguageModel_pipe.txt for writing
    2014-07-28 11:55:51.153 OpenEarsSampleApp[3012:60b] Starting text2wfreq_impl
    2014-07-28 11:55:51.156 OpenEarsSampleApp[3012:60b] Done with text2wfreq_impl
    2014-07-28 11:55:51.156 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/SecondOpenEarsDynamicLanguageModel_pipe.txt for reading.
    2014-07-28 11:55:51.157 OpenEarsSampleApp[3012:60b] Able to open /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/SecondOpenEarsDynamicLanguageModel.vocab for reading.
    2014-07-28 11:55:51.157 OpenEarsSampleApp[3012:60b] Starting wfreq2vocab
    2014-07-28 11:55:51.158 OpenEarsSampleApp[3012:60b] Done with wfreq2vocab
    2014-07-28 11:55:51.177 OpenEarsSampleApp[3012:60b] Starting text2idngram
    2014-07-28 11:55:51.180 OpenEarsSampleApp[3012:60b] Done with text2idngram
    2014-07-28 11:55:51.181 OpenEarsSampleApp[3012:60b] Starting idngram2lm

    2014-07-28 11:55:51.183 OpenEarsSampleApp[3012:60b] Done with idngram2lm
    2014-07-28 11:55:51.183 OpenEarsSampleApp[3012:60b] Starting sphinx_lm_convert
    2014-07-28 11:55:51.184 OpenEarsSampleApp[3012:60b] Finishing sphinx_lm_convert
    2014-07-28 11:55:51.185 OpenEarsSampleApp[3012:60b] Done creating language model with CMUCLMTK in 0.041909 seconds.
    2014-07-28 11:55:51.204 OpenEarsSampleApp[3012:60b] The word QUIDNUNC was not found in the dictionary /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/OpenEarsSampleApp.app/AcousticModelEnglish.bundle/LanguageModelGeneratorLookupList.text/LanguageModelGeneratorLookupList.text.
    2014-07-28 11:55:51.205 OpenEarsSampleApp[3012:60b] Now using the fallback method to look up the word QUIDNUNC
    2014-07-28 11:55:51.205 OpenEarsSampleApp[3012:60b] If this is happening more frequently than you would expect, the most likely cause for it is since you are using the English phonetic lookup dictionary is that your words are not in English or aren’t dictionary words, or that you are submitting the words in lowercase when they need to be entirely written in uppercase.
    2014-07-28 11:55:51.206 OpenEarsSampleApp[3012:60b] Using convertGraphemes for the word or phrase QUIDNUNC which doesn’t appear in the dictionary
    2014-07-28 11:55:51.214 OpenEarsSampleApp[3012:60b] I’m done running performDictionaryLookup and it took 0.026839 seconds
    2014-07-28 11:55:51.215 OpenEarsSampleApp[3012:60b] I’m done running dynamic language model generation and it took 0.072077 seconds
    2014-07-28 11:55:51.215 OpenEarsSampleApp[3012:60b] Dynamic language generator completed successfully, you can find your new files SecondOpenEarsDynamicLanguageModel.DMP
    and
    SecondOpenEarsDynamicLanguageModel.dic
    at the paths
    /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/SecondOpenEarsDynamicLanguageModel.DMP
    and
    /Users/geoffreytowell/Library/Application Support/iPhone Simulator/7.1/Applications/68EBCAC9-1619-4C79-8674-07DCCD64B76E/Library/Caches/SecondOpenEarsDynamicLanguageModel.dic
    2014-07-28 11:55:51.218 OpenEarsSampleApp[3012:60b]

    Welcome to the OpenEars sample project. This project understands the words:
    BACKWARD,
    CHANGE,
    FORWARD,
    GO,
    LEFT,
    MODEL,
    RIGHT,
    TURN,
    and if you say “CHANGE MODEL” it will switch to its dynamically-generated model which understands the words:
    CHANGE,
    MODEL,
    MONDAY,
    TUESDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY,
    QUIDNUNC
    2014-07-28 11:55:51.220 OpenEarsSampleApp[3012:60b] User gave mic permission for this app.
    2014-07-28 11:55:51.221 OpenEarsSampleApp[3012:60b] Leaving sample rate at the default of 16000.
    2014-07-28 11:55:51.221 OpenEarsSampleApp[3012:60b] The audio session has already been initialized but we will override its properties.
    2014-07-28 11:55:51.222 OpenEarsSampleApp[3012:60b] Checking and resetting all audio session settings.
    2014-07-28 11:55:51.222 OpenEarsSampleApp[3012:60b] audioCategory is incorrect, we will change it.
    2014-07-28 11:55:51.222 OpenEarsSampleApp[3012:60b] audioCategory is now on the correct setting of kAudioSessionCategory_PlayAndRecord.
    2014-07-28 11:55:51.223 OpenEarsSampleApp[3012:60b] bluetoothInput is incorrect, we will change it.
    2014-07-28 11:55:51.223 OpenEarsSampleApp[3012:60b] bluetooth input is now on the correct setting of 1.
    2014-07-28 11:55:51.223 OpenEarsSampleApp[3012:60b] Output Device: Speaker.
    2014-07-28 11:55:51.224 OpenEarsSampleApp[3012:60b] categoryDefaultToSpeaker is incorrect, we will change it.
    2014-07-28 11:55:51.224 OpenEarsSampleApp[3012:60b] CategoryDefaultToSpeaker is now on the correct setting of 1.
    2014-07-28 11:55:51.224 OpenEarsSampleApp[3012:60b] preferredBufferSize is incorrect, we will change it.
    2014-07-28 11:55:51.224 OpenEarsSampleApp[3012:60b] PreferredBufferSize is now on the correct setting of 0.128000.
    2014-07-28 11:55:51.225 OpenEarsSampleApp[3012:60b] preferredSampleRateCheck is incorrect, we will change it.
    2014-07-28 11:55:51.225 OpenEarsSampleApp[3012:60b] preferred hardware sample rate is now on the correct setting of 16000.000000.
    2014-07-28 11:55:51.225 OpenEarsSampleApp[3012:60b] AudioSessionManager startAudioSession has reached the end of the initialization.
    2014-07-28 11:55:51.226 OpenEarsSampleApp[3012:60b] Exiting startAudioSession.
    2014-07-28 11:55:51.226 OpenEarsSampleApp[3012:3903] setSecondsOfSilence value of 0.000000 was too large or too small or was NULL, using default of 0.700000.
    2014-07-28 11:55:51.226 OpenEarsSampleApp[3012:3903] Project has these words or phrases in its dictionary:
    10
    24
    30
    BACKWARD
    CHANGE
    COMPUTER
    DO
    EXECUTE
    FIVE
    FORWARD
    GO
    GREETINGS
    HELLO
    HELLO(2)
    IT
    LEFT
    MOVE
    ONE
    ONE(2)
    RIGHT
    ROBOTTWENTY
    THANK
    TWENTY
    TWENTY(2)
    TWO
    YOU
    2014-07-28 11:55:51.227 OpenEarsSampleApp[3012:3903] Recognition loop has started
    2014-07-28 11:55:51.235 OpenEarsSampleApp[3012:60b] Pocketsphinx is starting up.
    2014-07-28 11:55:51.256 OpenEarsSampleApp[3012:3903] Starting openAudioDevice on the simulator. This Simulator-compatible audio driver is only provided to you as a convenience so you can use the Simulator to test recognition logic, however, its audio driver is not supported and bug reports for it will be circular-filed.
    2014-07-28 11:55:51.257 OpenEarsSampleApp[3012:3903] Restoring SmartCMN value of 43.064590
    2014-07-28 11:55:51.303 OpenEarsSampleApp[3012:3903] Calibration has started
    2014-07-28 11:55:51.303 OpenEarsSampleApp[3012:60b] Pocketsphinx calibration has started.
    2014-07-28 11:55:53.505 OpenEarsSampleApp[3012:3903] Calibration has completed
    2014-07-28 11:55:53.505 OpenEarsSampleApp[3012:60b] Pocketsphinx calibration is complete.
    2014-07-28 11:55:53.506 OpenEarsSampleApp[3012:3903] Listening.
    2014-07-28 11:55:53.506 OpenEarsSampleApp[3012:60b] I’m running flite
    2014-07-28 11:55:53.507 OpenEarsSampleApp[3012:60b] Checking and resetting all audio session settings.
    2014-07-28 11:55:53.507 OpenEarsSampleApp[3012:60b] audioCategory is correct, we will leave it as it is.
    2014-07-28 11:55:53.508 OpenEarsSampleApp[3012:60b] bluetoothInput is correct, we will leave it as it is.
    2014-07-28 11:55:53.509 OpenEarsSampleApp[3012:60b] Output Device: Speaker.
    2014-07-28 11:55:53.509 OpenEarsSampleApp[3012:60b] categoryDefaultToSpeaker is correct, we will leave it as it is.
    2014-07-28 11:55:53.510 OpenEarsSampleApp[3012:60b] preferredBufferSize is correct, we will leave it as it is.
    2014-07-28 11:55:53.510 OpenEarsSampleApp[3012:60b] preferredSampleRateCheck is correct, we will leave it as it is.
    2014-07-28 11:55:53.587 OpenEarsSampleApp[3012:60b] I’m done running flite and it took 0.079781 seconds
    2014-07-28 11:55:53.587 OpenEarsSampleApp[3012:60b] Flite audio player was nil when referenced so attempting to allocate a new audio player.
    2014-07-28 11:55:53.587 OpenEarsSampleApp[3012:60b] Loading speech data for Flite concluded successfully.
    2014-07-28 11:55:53.601 OpenEarsSampleApp[3012:60b] Pocketsphinx is now listening.
    2014-07-28 11:55:53.602 OpenEarsSampleApp[3012:60b] Flite sending suspend recognition notification.
    2014-07-28 11:55:53.603 OpenEarsSampleApp[3012:60b] Flite has started speaking
    2014-07-28 11:55:53.604 OpenEarsSampleApp[3012:60b] Pocketsphinx has suspended recognition.
    2014-07-28 11:55:55.227 OpenEarsSampleApp[3012:60b] AVAudioPlayer did finish playing with success flag of 1
    2014-07-28 11:55:55.379 OpenEarsSampleApp[3012:60b] Flite sending resume recognition notification.
    2014-07-28 11:55:55.880 OpenEarsSampleApp[3012:60b] Flite has finished speaking
    2014-07-28 11:55:55.881 OpenEarsSampleApp[3012:60b] setSecondsOfSilence value of 0.000000 was too large or too small or was NULL, using default of 0.700000.
    2014-07-28 11:55:55.882 OpenEarsSampleApp[3012:60b] Pocketsphinx has resumed recognition.
    2014-07-28 11:55:57.457 OpenEarsSampleApp[3012:3903] Speech detected…
    2014-07-28 11:55:57.457 OpenEarsSampleApp[3012:60b] Pocketsphinx has detected speech.
    2014-07-28 11:56:00.488 OpenEarsSampleApp[3012:60b] Pocketsphinx has detected a second of silence, concluding an utterance.
    2014-07-28 11:56:00.488 OpenEarsSampleApp[3012:3903] Processing speech, please wait…
    2014-07-28 11:56:00.527 OpenEarsSampleApp[3012:3903] Pocketsphinx heard “10 10 10 HELLO IT LEFT” with a score of (-4394) and an utterance ID of 000000000.
    2014-07-28 11:56:00.527 OpenEarsSampleApp[3012:60b] The received hypothesis is 10 10 10 HELLO IT LEFT with a score of -4394 and an ID of 000000000
    2014-07-28 11:56:00.528 OpenEarsSampleApp[3012:60b] Heard 10 10 10 HELLO IT LEFT
    2014-07-28 11:56:00.528 OpenEarsSampleApp[3012:60b] I’m running flite
    2014-07-28 11:56:00.528 OpenEarsSampleApp[3012:60b] Checking and resetting all audio session settings.
    2014-07-28 11:56:00.529 OpenEarsSampleApp[3012:60b] audioCategory is correct, we will leave it as it is.
    2014-07-28 11:56:00.529 OpenEarsSampleApp[3012:60b] bluetoothInput is correct, we will leave it as it is.
    2014-07-28 11:56:00.529 OpenEarsSampleApp[3012:60b] Output Device: Speaker.
    2014-07-28 11:56:00.530 OpenEarsSampleApp[3012:60b] categoryDefaultToSpeaker is correct, we will leave it as it is.
    2014-07-28 11:56:00.530 OpenEarsSampleApp[3012:60b] preferredBufferSize is correct, we will leave it as it is.
    2014-07-28 11:56:00.530 OpenEarsSampleApp[3012:60b] preferredSampleRateCheck is correct, we will leave it as it is.
    2014-07-28 11:56:00.532 OpenEarsSampleApp[3012:3903] Listening.
    2014-07-28 11:56:00.650 OpenEarsSampleApp[3012:60b] I’m done running flite and it took 0.121160 seconds
    2014-07-28 11:56:00.650 OpenEarsSampleApp[3012:60b] Flite audio player was nil when referenced so attempting to allocate a new audio player.
    2014-07-28 11:56:00.651 OpenEarsSampleApp[3012:60b] Loading speech data for Flite concluded successfully.
    2014-07-28 11:56:00.660 OpenEarsSampleApp[3012:60b] Flite sending interrupt speech request.
    2014-07-28 11:56:00.661 OpenEarsSampleApp[3012:60b] Pocketsphinx is now listening.
    2014-07-28 11:56:00.662 OpenEarsSampleApp[3012:60b] Flite sending suspend recognition notification.
    2014-07-28 11:56:00.663 OpenEarsSampleApp[3012:60b] Flite has started speaking
    2014-07-28 11:56:00.663 OpenEarsSampleApp[3012:60b] Pocketsphinx has suspended recognition.
    2014-07-28 11:56:03.249 OpenEarsSampleApp[3012:60b] AVAudioPlayer did finish playing with success flag of 1
    2014-07-28 11:56:03.401 OpenEarsSampleApp[3012:60b] Flite sending resume recognition notification.
    2014-07-28 11:56:03.902 OpenEarsSampleApp[3012:60b] Flite has finished speaking
    2014-07-28 11:56:03.903 OpenEarsSampleApp[3012:60b] setSecondsOfSilence value of 0.000000 was too large or too small or was NULL, using default of 0.700000.
    2014-07-28 11:56:03.905 OpenEarsSampleApp[3012:60b] Pocketsphinx has resumed recognition.
    2014-07-28 11:56:04.526 OpenEarsSampleApp[3012:3903] No longer listening.
    2014-07-28 11:56:04.527 OpenEarsSampleApp[3012:60b] Pocketsphinx has stopped listening.

    #1022082
    Halle Winkler
    Politepix

    Welcome,

    Couple things:

    1. If you set PocketsphinxController’s verbosePocketsphinx property to TRUE you can see what happens in the recognition loop when it doesn’t work. This is probably the most important debugging step after turning on OpenEarsLogging (which I see you did).

    2. I see the code where you create a language model and create a grammar, but without seeing the code where you start listening I can’t say why it may or may not be working because I don’t know which of those two items you are starting the loop with and how you invoked the method.

    3. Let’s create smaller test cases in order to share code here, since it’s a bit too much to scan through.

    4. This array is malformed (don’t know why it compiles) due to a lack of a comma and it ends up with a malformed word “ROBOTTWENTY” in your language model which will reduce recognition quality:

    NSArray *firstLanguageArray = [[NSArray alloc] initWithArray:[NSArray arrayWithObjects: // All capital letters.
    @"ONE", @"TWO", @"TWENTY", @"10", @"30", @"24",
    @"HELLO", @"COMPUTER", @"GREETINGS", @"ROBOT"
    @"TWENTY FIVE",
    @"BACKWARD",
    @"CHANGE",
    @"FORWARD",
    @"GO",
    @"MOVE", @"EXECUTE", @"DO", @"IT", @"THANK", @"YOU",
    @"LEFT",
    @"RIGHT",
    nil]];
    
    #1022085
    geofftowell
    Participant

    Overnight I got to thinking and read through the documentation several more times. With some more experimentation, I got recognition with grammars working in the sample code by modifying the viewDidLoad and startListening methods as shown below. (I removed a bunch of comments to make things shorter.)

    The central thing I had missed was changing languageModelIsJSGF to TRUE in the startListeningWithLanguageModelAtPath method

    Thanks for your help.

    – (void) startListening {

    self.pocketsphinxController.returnNullHypotheses=YES;
    self.pocketsphinxController.verbosePocketSphinx=YES;
    [self.pocketsphinxController startListeningWithLanguageModelAtPath:self.pathToFirstDynamicallyGeneratedLanguageModel dictionaryAtPath:self.pathToFirstDynamicallyGeneratedDictionary acousticModelAtPath:[AcousticModel pathToModel:@”AcousticModelEnglish”] languageModelIsJSGF:TRUE]; // Change “AcousticModelEnglish” to “AcousticModelSpanish” in order to perform Spanish recognition instead of English.
    self.pocketsphinxController.verbosePocketSphinx=YES;

    }

    – (void)viewDidLoad {
    [super viewDidLoad];
    [OpenEarsLogging startOpenEarsLogging];
    self.restartAttemptsDueToPermissionRequests = 0;
    self.startupFailedDueToLackOfPermissions = FALSE;

    [self.openEarsEventsObserver setDelegate:self];
    LanguageModelGenerator *languageModelGenerator = [[LanguageModelGenerator alloc] init];
    NSDictionary *dd = @{
    ThisWillBeSaidOnce : @[
    @{ OneOfTheseCanBeSaidOnce : @[@”HELLO COMPUTER”, @”GREETINGS ROBOT”]},
    @{ OneOfTheseWillBeSaidOnce : @[@”GO”, @”MOVE”]},
    @{ OneOfTheseWillBeSaidOnce : @[@”EXECUTE”, @”DO IT”]},
    ]
    };
    NSError *error2 = [languageModelGenerator generateGrammarFromDictionary:dd withFilesNamed:@”FirstOpenEarsDynamicLanguageModelG” forAcousticModelAtPath:[AcousticModel pathToModel:@”AcousticModelEnglish”]];

    NSDictionary *firstDynamicLanguageGenerationResultsDictionary = nil;
    if([error2 code] != noErr) {
    NSLog(@”Dynamic language generator reported error %@”, [error2 description]);
    } else {
    firstDynamicLanguageGenerationResultsDictionary = [error2 userInfo];

    NSString *lmFile = [firstDynamicLanguageGenerationResultsDictionary objectForKey:@”LMFile”];
    NSString *dictionaryFile = [firstDynamicLanguageGenerationResultsDictionary objectForKey:@”DictionaryFile”];
    NSString *lmPath = [firstDynamicLanguageGenerationResultsDictionary objectForKey:@”LMPath”];
    NSString *dictionaryPath = [firstDynamicLanguageGenerationResultsDictionary objectForKey:@”DictionaryPath”];

    NSLog(@”Dynamic language generator completed successfully, you can find your new files %@\n and \n%@\n at the paths \n%@ \nand \n%@”, lmFile,dictionaryFile,lmPath,dictionaryPath);

    self.pathToFirstDynamicallyGeneratedLanguageModel = lmPath;
    self.pathToFirstDynamicallyGeneratedDictionary = dictionaryPath;
    }

    self.usingStartLanguageModel = TRUE;
    [self startListening];
    [self startDisplayingLevels];
    self.startButton.hidden = TRUE;
    self.stopButton.hidden = TRUE;
    self.suspendListeningButton.hidden = TRUE;
    self.resumeListeningButton.hidden = TRUE;
    }

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.