예제 #1
0
/*
 * Initialize resources and variables for EM Service.
 */
void mod_em_service_init()
{
	// Set up variables
	mes_state = EM_TEST;
	mes_rate = 5;
	mes_kerning = false;
	mes_continuous = false;
	mes_seriesLength = 0;
	
	// Set up hardware
	ld_init();

	// Load default Icon into display buffer.
	ld_loadIcon( 0, 0 );
}
예제 #2
0
파일: main2.c 프로젝트: wdebeaum/cabot
int
main(int argc, char **argv)
{
  HANDLE thread;
  char buffer[1024];
  char *hypstr;

  /////////////////////////////////////////////////////////////////////////////
  // Initializing
  //
  if (argc < 2) {
    printf("Usage:  livedecoder2 [ARGS] \n");
    return -1;
  }

  if (ld_init(&decoder, argc, argv)) {
    printf(">>>>> ld_init() failed.\n");
    return -1;
  }

  if (ld_utt_begin(&decoder, 0)) {
    printf(">>>>> ld_utt_begin() failed.\n");
    return -1;
  }

  startEvent = CreateEvent(NULL,
			   TRUE,
			   FALSE,
			   "StartEvent");

  finishEvent = CreateEvent(NULL,
			    TRUE,
			    FALSE,
			    "FinishEvent");

  thread = CreateThread(NULL,
			0,
			process_thread,
			NULL,
			0,
			NULL);

  /////////////////////////////////////////////////////////////////////////////
  // Wait for some user input, then signal the processing thread to start
  // recording/decoding
  //
  printf("press ENTER to start recording\n");
  fgets(buffer, 1024, stdin);
  SetEvent(startEvent);

  /////////////////////////////////////////////////////////////////////////////
  // Wait for some user input again, then signal the processing thread to end
  // recording/decoding
  //
  printf("press ENTER to finish recording\n");
  fgets(buffer, 1024, stdin);
  SetEvent(finishEvent);

  /////////////////////////////////////////////////////////////////////////////
  // Wait for the working thread to join
  //
  WaitForSingleObject(thread, INFINITE);

  /////////////////////////////////////////////////////////////////////////////
  // Print the decoding output
  //
  if (ld_utt_hyps(&decoder, &hypstr, 0)) {
    printf(">>>>> ld_utt_hyps() failed\n");
  }
  else {
    printf(">>>>> decoder returned:\n%s\n", hypstr);
  }

  return 0;
}
예제 #3
0
파일: main2.c 프로젝트: wdebeaum/cabot
int
main(int argc, char **argv)
{
  live_decoder_t decoder;
  FILE *infile;
  ad_rec_t *ad;
  char *hypstr;
  int16 samples[BUFSIZE];
  int32 num_samples;
  int32 tot_samples = 0;

  if (argc < 2) {
    printf("Usage:  livedecoder2 [ARGS] INPUT_FILE\n");
    return -1;
  }

  if (ld_init(&decoder, argc - ((argc - 1) % 2), argv)) {
    printf("ld_init() failed.\n");
    return -1;
  }

  if (ld_utt_begin(&decoder, 0)) {
    printf("ld_utt_begin() failed.\n");
    return -1;
  }

  if (argc % 2) {
    /* record for 5 seconds */
    tot_samples = cmd_ln_int32 ("-samprate") * 5;
    ad = ad_open_sps(cmd_ln_int32 ("-samprate"));
    ad_start_rec(ad);
    while (tot_samples > 0) {
      num_samples = ad_read(ad, samples,
			    tot_samples > BUFSIZE ? BUFSIZE : tot_samples);
      if (num_samples > 0) {
	if (ld_utt_proc_raw(&decoder, samples, num_samples) < 0) {
	  printf("ld_utt_proc_raw() returned unexpectedly.\n");
	  return -1;
	}
	tot_samples -= num_samples;
      }
    }
    ad_stop_rec(ad);
    ad_close(ad);
  }
  else {
    infile = fopen(argv[1], "rb");
    while (!feof(infile)) {
      num_samples = fread(samples, sizeof(int16), BUFSIZE, infile);
      if (num_samples > 0) {
	if (ld_utt_proc_raw(&decoder, samples, num_samples) < 0) {
	  printf("ld_utt_proc_raw() returned unexpectedly.\n");
	  return -1;
	}
      }
    }
    fclose(infile);
  }
	
  if (ld_utt_end(&decoder)) {
    printf("ld_utt_end() failed.\n");
    return -1;
  }

  ld_utt_hyps(&decoder, &hypstr, 0);
  printf("decoder returned:\n%s\n", hypstr);

  return 0;
}
예제 #4
0
int
main(int argc, char **argv)
{
    thread_t thread;
    char buffer[1024];
    char *hypstr;

    /*
     * Initializing
     */
    if (argc != 2) {
        printf("Usage:  livedecode config_file \n");
        return -1;
    }

    if (cmd_ln_parse_file(arg_def, argv[1])) {
        printf("Bad arguments file (%s).\n", argv[1]);
        return -1;
    }

    if (ld_init(&decoder)) {
        printf("Initialization failed.\n");
        return -1;
    }

    if (ld_begin_utt(&decoder, 0)) {
        printf("Cannot start decoding\n");
        return -1;
    }

  /** initializing a file to dump the recorded audio */
    if ((dump = fopen("out.raw", "wb")) == 0) {
        printf("Cannot open dump file out.raw\n");
        return -1;
    }

    create_cond(&startEvent);
    create_cond(&finishEvent);
    create_thread(&thread, &process_thread);

    /*
     * Wait for some user input, then signal the processing thread to start
     * recording/decoding
     */
    printf("press ENTER to start recording\n");
    fgets(buffer, 1024, stdin);
    cond_signal(startEvent);

    /*
     *  Wait for some user input again, then signal the processing thread to end
     *  recording/decoding
     */
    printf("press ENTER to finish recording\n");
    fgets(buffer, 1024, stdin);
    cond_signal(finishEvent);

    /*
     *  Wait for the working thread to join
     */
    join_thread(thread);

    /*
     *  Print the decoding output
     */
    if (ld_retrieve_hyps(&decoder, NULL, &hypstr, NULL)) {
        printf("Cannot retrieve hypothesis.\n");
    }
    else {
        printf("Hypothesis:\n%s\n", hypstr);
    }

    ld_finish(&decoder);

    fclose(dump);

    return 0;
}