Responding to Speech Recognition

Home Forums OpenEars Responding to Speech Recognition

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

  • Author
    Posts
  • #1021981
    ThatGuy
    Participant

    Hello All,

    I’m very new to OpenEars and I come to ask you a simple question. How do you respond to speech recognition? I’m sorry to burden you guys, but I’m still learning how all of this works.

    So this was my attempt on how to respond to speech recognition. I put an if statement under the pocketsphinxDidReceiveHypothesis void. The condition was if the hypothesis equaled a certain piece of text.

    - (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);
        
        if ((hypothesis = @"WORD")) {
            
            //Whatever Code I Need
            
        }
    } 

    It ends up with a lot of bugs and glitches, but how do you guys do it?

    #1021984
    Halle Winkler
    Politepix

    Welcome,

    OK, I think this may be more about getting started with Objective-C than with OpenEars specifically, and I can unfortunately only provide a very limited amount of help with general programming questions here since support time and resources are limited. But, I can see if I can help a bit in this question to get you on the right track while you can look into more general programming sites in order to connect with people who can help with getting started.

    A few things that would help:

    • it’s always very important to provide some specific information about what happened when things didn’t work correctly. So, in order to get good help with bugs and glitches, it’s really important to show the full errors you receive or to very specifically describe the bugs and the glitches, or there isn’t any way to give help from the other side.

    • in C, which includes the C aspects of Objective-C, this kind of equal sign is for assignment (giving variables new values): “=” and this kind of equal sign is for equality (comparing values as you have done above): “==”. You can’t use a single equal sign to see if two values are the same. That will instead assign a new value and will always evaluate as true in an if statement. To see if two values are the same you have to compare them with “==”.

    • But more importantly, in Objective-C, NSStrings are not compared with each other with “==” in order to see if they have the same characters in them because they are pointers to objects and not primitive types like a single char or int value that could be compared with “==”. There is a method of NSString called isEqualToString: which performs this comparison check and returns a BOOL that is true or false, so that is what has to be used in order to check if your NSString is the same as some other NSString.

    There are examples of doing exactly this kind of comparison in the sample app that ships with OpenEars, so check it out and you can see many different kinds of processes that are part of a speech recognition app.

    #1021986
    ThatGuy
    Participant

    Thanks Halle, yeah I might need to read up on objective c… Anyways, I fixed it. I just added isEqual.

    if ([hypothesis  isEqual: @"WORD"]) {
            
            //Whatever Code I Need
            
        }
    #1021987
    ThatGuy
    Participant

    Also, I’m only a young teen trying to embark on my journey into the computer world. :D

    #1021991
    Halle Winkler
    Politepix

    Also, I’m only a young teen trying to embark on my journey into the computer world. :D

    Just keep in mind when you find a better place to ask starter questions that it’s very important to be specific about what isn’t working and show any errors you receive, and if you get answers to your questions, give them a read instead of tuning them out and continuing to copy and paste other non-working code – you never know what you’ll learn.

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