Here is source code and documentation: http://www.speech.cs.cmu.edu/pocketsphinx/.
I've completed the porting to PSP, it picks up audio input and propose some sentences according to best fit of utterance.
It's fast and nice.
I'm experiencing some crashes at the following procedure where is something that I do not understand.
I've a pointer to unsigned char:
Code: Select all
unsigned char *pid_cw0 ...
Code: Select all
pid_cw0 = (s->OPDF_8B[j][s->f[j][0].codeword]);
Code: Select all
tmp1 = pid_cw0[n] + w0;
I've substituted pid_cw0[n] with forced values: the program flows over to end.
Something is wrong reading pid_cw0[n]. and I'am not able to understand what's the meaning of reading this pointed value at position [n].
Is there missing any alloc of array? or something similar? Any initialization of [n] positions is required?
The original source code is fully and succesfully compiled both for PSP and for PC under Windows, but when running on PSP it crashes at that instruction.
Has anybody any suggestion on investigating or by-pass or complete this original instruction set?
Thanks a lot, here is source code of the procedure, then the structure of s2_Semi_mgau_t.
Code: Select all
static int32
get_scores4_8b(s2_semi_mgau_t * s)
{
register int32 j, n, k;
int32 tmp1, tmp2;
unsigned char *pid_cw0, *pid_cw1, *pid_cw2, *pid_cw3;
int32 w0, w1, w2, w3; /* weights */
memset(senone_scores, 0, s->CdWdPDFMod * sizeof(*senone_scores));
for (j = 0; j < s->n_feat; j++) {
/* ptrs to senone prob ids */
pid_cw0 = (s->OPDF_8B[j][s->f[j][0].codeword]);
pid_cw1 = (s->OPDF_8B[j][s->f[j][1].codeword]);
pid_cw2 = (s->OPDF_8B[j][s->f[j][2].codeword]);
pid_cw3 = (s->OPDF_8B[j][s->f[j][3].codeword]);
w0 = s->f[j][0].val.score;
w1 = s->f[j][1].val.score;
w2 = s->f[j][2].val.score;
w3 = s->f[j][3].val.score;
/* Floor w0..w3 to 256<<10 - 162k */
if (w3 < -99000)
w3 = -99000;
if (w2 < -99000)
w2 = -99000;
if (w1 < -99000)
w1 = -99000;
if (w0 < -99000)
w0 = -99000; /* Condition should never be TRUE */
/* Quantize */
w3 = (511 - w3) >> 10;
w2 = (511 - w2) >> 10;
w1 = (511 - w1) >> 10;
w0 = (511 - w0) >> 10;
for (k = 0; k < n_senone_active; k++) {
n = senone_active[k];
//#### HERE IS CRASHING!
tmp1 = pid_cw0[n] + w0;
//#### HERE IS CRASHING!
tmp2 = pid_cw1[n] + w1;
tmp1 = LOG_ADD(tmp1, tmp2);
tmp2 = pid_cw2[n] + w2;
tmp1 = LOG_ADD(tmp1, tmp2);
tmp2 = pid_cw3[n] + w3;
tmp1 = LOG_ADD(tmp1, tmp2);
senone_scores[n] -= tmp1 << 10;
}
}
return 0;
}
Code: Select all
typedef struct {
union {
int32 score;
int32 dist; /* distance to next closest vector */
} val;
int32 codeword; /* codeword (vector index) */
} vqFeature_t;
typedef vqFeature_t *vqFrame_t;
typedef struct s2_semi_mgau_s s2_semi_mgau_t;
struct s2_semi_mgau_s {
int32 **dets; /* det values foreach feature */
mean_t **means; /* mean vectors foreach feature */
var_t **vars; /* var vectors foreach feature */
unsigned char ***OPDF_8B; /* mixture weights */
int32 n_feat; /* Number of feature streams */
int32 *veclen; /* Length of feature streams */
int32 n_density; /* Number of mixtures per codebook */
int32 topN; /* Number of top densities to compute (<S2_MAX_TOPN) */
int32 CdWdPDFMod; /* Legacy thing, actually means number of mixw */
kd_tree_t **kdtrees;
uint32 n_kdtrees;
uint32 kd_maxdepth;
int32 kd_maxbbi;
int32 num_frames;
int32 ds_ratio;
int32 use_mmap; /**< Are mixture weights mmap()ed? */
/* Top-N scores and codewords from current, last frame. */
vqFeature_t **f, **lastf;
int32 *score_tmp;
};