コード例 #1
0
ファイル: kb_symbol.c プロジェクト: dyustc/Khepera_III
/*! 
 * This function destroys all elements in a given symbol table. 
 *
 * \param table A pointer to the given symbol table
 *
 * \remark table is never freed.
 */
void kb_destroy_symbol_table( kb_symbol_table_t * table )
{
  unsigned int index;
  kb_symbol_t * sym , *next;

  (void)pthread_mutex_destroy( &table->lock );
  table->count = 0;
 
  for (index=0; index<KB_SYMBOL_TABLE_SIZE; index++) {
  
    sym = table->symbols[index];
    
    while ( sym != NULL ) {
      //printf("toto\n");
      //printf("sym=%08X\n" , sym );
      //printf("sym->name=%s\n"  , sym->name );
      //printf("sym->type=%u\n" , sym->type );
      //printf("sym->alloc=%u\n" , sym->alloc );
      //printf("sym->value=%u\n" , sym->value );
      //printf("sym->next=%08X\n" , sym->next );

      next = sym->next;
      if ( sym->alloc != 0 ) {
	kb_free( (void *)sym->value );
      }
      kb_free( sym );
      sym = next;
    }
  }
}
コード例 #2
0
void
ld_finish(live_decoder_t * _decoder)
{
    assert(_decoder != NULL);

    if (_decoder->fe != NULL) {
        fe_close(_decoder->fe);
    }
    if (_decoder->features != NULL) {
        /* consult the implementation of feat_array_alloc() for how to free our
         * internal feature vector buffer */
        ckd_free((void *) **_decoder->features);
        ckd_free_2d((void **) _decoder->features);
    }
    if (_decoder->internal_cmdln == TRUE) {
        cmd_ln_free();
    }
    kb_free(&_decoder->kb);
    ld_free_hyps(_decoder);
    if (_decoder->uttid != NULL) {
        ckd_free(_decoder->uttid);
        _decoder->uttid = NULL;
    }
    _decoder->ld_state = LD_STATE_FINISHED;
}
コード例 #3
0
int32
main(int32 argc, char *argv[])
{
    kb_t kb;
    stat_t *st;
    cmd_ln_t *config;

    print_appl_info(argv[0]);
    cmd_ln_appl_enter(argc, argv, "default.arg", arg);

    unlimit();

    config = cmd_ln_get();
    kb_init(&kb, config);
    st = kb.stat;
    fprintf(stdout, "\n");

    if (cmd_ln_str_r(config, "-ctl")) {
        /* When -ctlfile is speicified, corpus.c will look at -ctl_lm and
           -ctl_mllr to get the corresponding LM and MLLR for the utterance */
        st->tm = ctl_process(cmd_ln_str_r(config, "-ctl"),
                             cmd_ln_str_r(config, "-ctl_lm"),
                             cmd_ln_str_r(config, "-ctl_mllr"),
                             cmd_ln_int32_r(config, "-ctloffset"),
                             cmd_ln_int32_r(config, "-ctlcount"), utt_decode, &kb);
    }
    else if (cmd_ln_str_r(config, "-utt")) {
        /* When -utt is specified, corpus.c will wait for the utterance to
           change */
        st->tm = ctl_process_utt(cmd_ln_str_r(config, "-utt"),
                                 cmd_ln_int32_r(config, "-ctlcount"),
                                 utt_decode, &kb);

    }
    else {
        /* Is error checking good enough?" */
        E_FATAL("Both -utt and -ctl are not specified.\n");

    }

    if (kb.matchsegfp)
        fclose(kb.matchsegfp);
    if (kb.matchfp)
        fclose(kb.matchfp);

    stat_report_corpus(kb.stat);

    kb_free(&kb);

#if (! WIN32)
#if defined(_SUN4)
    system("ps -el | grep sphinx3_decode");
#else
    system("ps aguxwww | grep sphinx3_decode");
#endif
#endif

    cmd_ln_free_r(config);
    exit(0);
}
コード例 #4
0
ファイル: live.c プロジェクト: wdebeaum/cabot
/* RAH Apr.13.2001: Memory was being held, Added Call fe_close to release 
 * memory held by fe and then release locally allocated memory 
 */
int32 live_free_memory ()
{
    parse_args_free();		/* Free memory allocated during the argument parseing stage */
    fe_close (fe);			/*  */
    ckd_free(kb->uttid);	/* Free memory allocated in live_initialize_decoder() */
    kb_free (kb);			/*  */
    ckd_free ((void *) dummyframe);	/*  */
    ckd_free ((void *) parthyp);	/*  */
    return (0);
}
コード例 #5
0
/* RAH Apr.13.2001: Memory was being held, Added Call fe_close to release memory held by fe and then release locally allocated memory */
int32 live_free_memory ()
{
  parse_args_free();		/* Free memory allocated during the argument parseing stage */
  fe_close (fe);		/*  */
  ckd_free(kb->uttid);  /* Free memory allocated in live_initialize_decoder() */
  kb_free (kb);		/*  */
  ckd_free ((void *) dummyframe); /*  */
  ckd_free ((void *) parthyp);  /*  */
#if defined(THRD)
  thread_barrier_destroy(score_barrier);
#endif
  return (0);
}
コード例 #6
0
ファイル: s3_decode.c プロジェクト: Ankit77/cmusphinx
void
s3_decode_close(s3_decode_t * _decode)
{
    if (_decode == NULL)
        return;

    kb_free(&_decode->kb);
    s3_decode_free_hyps(_decode);
    if (_decode->uttid != NULL) {
        ckd_free(_decode->uttid);
        _decode->uttid = NULL;
    }
    _decode->state = S3_DECODE_STATE_FINISHED;
}
コード例 #7
0
ファイル: live2.c プロジェクト: wdebeaum/cabot
int
ld_finish(live_decoder_t *decoder)
{
  cmd_ln_free();
  /* lgalescu@ihmc -- this is not right! the string is allocated with decoder!
  ckd_free(decoder->kb.uttid);
   */
  kb_free(&decoder->kb);
	
  /* consult the implementation of feat_array_alloc() for the following two
   * lines
   */
  /* lgalescu@ihmc -- what's going on here?
  ckd_free((void *)decoder->features);
  ckd_free_2d((void **)decoder->features);
   */
  /* lgalescu@ihmc -- replaced the two calls above with the following:
   */
  ckd_free_3d((void ***)decoder->features);
	
  decoder->ld_state = LD_STATE_IDLE;
	
  return 0;
}
コード例 #8
0
ファイル: soundtest.c プロジェクト: dyustc/Khepera_III
int main(int argc, char * argv[])
{
    WAV wav;
    int rc;
    snd_t snd;
    short *buf;
    unsigned int size = 2048;

    /* Checking args */
    if(argc < 2)
    {
        printf("usage: soundtest <file.wav>\r\n");
        return 1;
    }

    buf = kb_alloc( size );

    kb_snd_init(&snd , "/dev/sound/dsp", "/dev/sound/mixer");

    if ( kb_snd_open(&snd ) < 0 ) {
        printf("cannot open sound devices\r\n");
        return 1;
    }

    kb_wav_init( &wav );

    if ((rc = kb_wav_open( &wav , argv[1], 1 )) == -1 ) {
        printf("cannot open %s\r\n",argv[1]);
        return 1;
    }

    if ( wav.fmt.bit_per_sample != 16  && wav.fmt.nb_channel != 2 ) {
        printf("wrong bit_per_sample or nb_channel in wav file\r\n");
        return 1;
    }

    /* Set Sample Rate */
    if ( kb_snd_setSampleRate( &snd, wav.fmt.sample_rate ) == -1 ) {
        printf("unable to set sample rate\r\n");
        return 1;
    }

    for (;;) {
        rc = kb_wav_read_data( &wav , buf , size);
        if ( rc <= 0 ) {
            if ( rc < 0 )
                printf( "i/o error in reading file '%s' !" , argv[1]);
            break;
        }

        do {
            rc = kb_snd_play( &snd , buf , size );
            if ( rc < 0 ) {
                if ( errno != EAGAIN ) {
                    printf( "error in playing sample errno=%d", errno );
                    break;
                }
                continue;
            }
        }
        while (0);
    }

    kb_free( buf );
    kb_wav_close( &wav );
}