Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
The following problem has been solved. Below the second code block is a quote from the post that helped me most.

I am using the PocketSphynx library. I chose not to install the Xcode binaries because it seems that to do so would require that I run autoconfig, which in turn would require that I download tools that I do not want to download.

I have placed a C method inside the implementation file of a subclass of NSObject, but when I call that function inside an Objective-C method, I get the error I have mentioned.

EDIT: Directly below this sentence is the line of code that is given me the error. This line is located in the relevant implementation block.
Code:
int pocketSphinxInitialized = [initializePocketSphinx()];

Directly below this sentence is the code that is located in the implementation file that the above line is located in.
Code:
#import "PocketSphinx.h"
#define MODELDIR "c:/sphinx/model"

int initializePocketSphinx()
{
    ps_decoder_t *ps;
    cmd_ln_t *config;
    
    config = cmd_ln_init(NULL, ps_args(), TRUE,
                         "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
                         "-lm", MODELDIR "/lm/en/turtle.DMP",
                         "-dict", MODELDIR "/lm/en/turtle.dic",
                         NULL);
    if (config == NULL)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

@implementation PocketSphinx

+(PocketSphinx *)initialize
{
    PocketSphinx *pocketSphinx = [[PocketSphinx alloc] init];
    int pocketSphinxInitialized = [initializePocketSphinx()];
    return pocketSphinx;
}
@end

The post that helped me most:
You don't need the square brackets for a call to a C function.
 
Last edited:
Which line is giving you the error?

Also, I'd replace your if ... return 1 else return 0 with just return config == NULL.
 
Code:
#import "PocketSphinx.h"
#define MODELDIR "c:/sphinx/model"

int initializePocketSphinx()
{
    ps_decoder_t *ps;
    cmd_ln_t *config;
    
    config = cmd_ln_init(NULL, ps_args(), TRUE,
                         "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
                         "-lm", MODELDIR "/lm/en/turtle.DMP",
                         "-dict", MODELDIR "/lm/en/turtle.dic",
                         NULL);
    if (config == NULL)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

@implementation PocketSphinx

+(PocketSphinx *)initialize
{
    PocketSphinx *pocketSphinx = [[PocketSphinx alloc] init];
    int pocketSphinxInitialized = [COLOR="Red"][initializePocketSphinx()][/COLOR];
    return pocketSphinx;
}
@end

You don't need the square brackets for a call to a C function.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.