Example #1
0
void SpeechSystem::setup()
{
	// ewwww
	jconf = j_config_load_file_new(const_cast<char*>(jconf_filename.c_str()));

	/* 2. create recognition instance according to the jconf */
	/* it loads models, setup final parameters, build lexicon
     and set up work area for recognition */
	recog = j_create_instance_from_jconf(jconf);
	if (recog == NULL)
	{
		fprintf(stderr, "Error in startup\n");
		return;
	}

	/*********************/
	/* Register callback */
	/*********************/
	/* register result callback functions */
	callback_add(recog, CALLBACK_EVENT_SPEECH_READY, recready, this);
	callback_add(recog, CALLBACK_EVENT_SPEECH_START, recstart, this);
	callback_add(recog, CALLBACK_RESULT, recdone, this);

	/**************************/
	/* Initialize audio input */
	/**************************/
	/* initialize audio input device */
	/* ad-in thread starts at this time for microphone */
	if (j_adin_init(recog) == FALSE) {    /* error */
		return;
	}

//#ifdef JULIUS_DEBUG
	/* output system information to log */
	j_recog_info(recog);
//#endif

	/***********************************/
	/* Open input stream and recognize */
	/***********************************/
	/* raw speech input (microphone etc.) */

	switch(j_open_stream(recog, NULL)) {
		case 0:			/* succeeded */
			break;
		case -1:      		/* error */
			fprintf(stderr, "error in input stream\n");
			return;
		case -2:			/* end of recognition process */
			fprintf(stderr, "failed to begin input stream\n");
			return;
	}

	startThread(true, false); // blocking, verbose
}
Example #2
0
//===================
// Load a Jconf file
//===================
bool cJulius::loadJconf( char *filename )
{
	if (m_jconf) {
		if (j_config_load_file(m_jconf, filename) == -1) {
			return false;
		}
	} else {
		m_jconf = j_config_load_file_new( filename );
		if (m_jconf == NULL) {		/* error */
		    return false;
		}
	}
	return true;
}
Example #3
0
bool SpRecog::loadConfigFile(Application *app)
{
  char conf_file_name[] = "julius.conf";
  jconf = j_config_load_file_new(conf_file_name);
  if (jconf == NULL) {
    app->tell("error in j_config_load_file_new");
    fprintf(stderr, "error in j_config_load_file_new\n");
    return false;
  }
  recog = j_create_instance_from_jconf(jconf);
  if (recog == NULL) {
    app->tell("error in j_create_instance_from_jconf");
    return false;
  }
  return true;
}