Ejemplo n.º 1
0
S_API const SFeatProcessor *SVoiceGetFeatProc(const SVoice *self, const char *key,
											  s_erc *error)
{
	const SFeatProcessor *tmp;


	S_CLR_ERR(error);

	if (self == NULL)
	{
		S_CTX_ERR(error, S_ARGERROR,
				  "SVoiceGetFeatProc",
				  "Argument \"self\" is NULL");
		return NULL;
	}

	if (key == NULL)
	{
		S_CTX_ERR(error, S_ARGERROR,
				  "SVoiceGetFeatProc",
				  "Argument \"key\" is NULL");
		return NULL;
	}

	tmp = S_FEATPROCESSOR(SMapGetObjectDef(self->featProcessors, key, NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "SVoiceGetFeatProc",
				  "Call to \"SMapGetObjectDef\" failed"))
		return NULL;

	return tmp;
}
Ejemplo n.º 2
0
static void Initialize(SUttProcessor *self, const SVoice *voice, s_erc *error)
{
	const SObject *tmp;
	const SMap *syllInfo;
	const char *plugin_name;
	const char *featproc_class;
	const char *class_name;
	SPlugin *sylPlugin;
	SFeatProcessor *stressProc;
	SSyllabification *syllab;


	S_CLR_ERR(error);

	/* check if a syllabification function is defined as a feature,
	 * and if so, create the syllabification object */
	tmp = SMapGetObjectDef(self->features, "syllabification function", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	/* nothing, return */
	if (tmp == NULL)
		return;

	syllInfo = S_CAST(tmp, SMap, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"S_CAST (SMap)\" failed"))
		return;

	plugin_name = SMapGetString(syllInfo, "plug-in", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapGetString\" failed"))
		return;

	if (plugin_name == NULL)
		return;

	class_name = SMapGetString(syllInfo, "class", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapGetString\" failed"))
		return;

	if (class_name == NULL)
		return;

	/* load the plug-in */
	sylPlugin = s_pm_load_plugin(plugin_name, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"s_pm_load_plugin\" failed"))
		return;

	/* create a syllabification object */
	syllab = (SSyllabification*)S_NEW_FROM_NAME(class_name, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Failed to create new '%s' object", class_name))
	{
		S_DELETE(sylPlugin, "Initialize", error);
		return;
	}

	/* add them to the features */
	SMapSetObject(self->features, "_syll_func_plugin", S_OBJECT(sylPlugin), error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapSetObject\" failed"))
	{
		S_DELETE(syllab, "Initialize", error);
		S_DELETE(sylPlugin, "Initialize", error);
		return;
	}

	SMapSetObject(self->features, "_syll_func", S_OBJECT(syllab), error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapSetObject\" failed"))
	{
		/* plugin will be deleted when utt processor is deleted */
		S_DELETE(syllab, "Initialize", error);
		return;
	}

	/* check if a stress function is defined as a feature,
	 * and if so, create the stress object */
	tmp = SMapGetObjectDef(self->features, "syllable stress processor", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	/* nothing, return */
	if (tmp == NULL)
		return;

	syllInfo = S_CAST(tmp, SMap, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"S_CAST (SMap)\" failed"))
		return;

	plugin_name = SMapGetString(syllInfo, "plug-in", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapGetString\" failed"))
		return;

	if (plugin_name == NULL)
		return;

	featproc_class = SMapGetString(syllInfo, "class", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapGetString\" failed"))
		return;

	/* load the plug-in */
	sylPlugin = s_pm_load_plugin(plugin_name, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"s_pm_load_plugin\" failed"))
		return;

	stressProc  = S_FEATPROCESSOR(S_NEW_FROM_NAME(featproc_class, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SNEW_FROM_NAME\" failed"))
		return;

	/* add them to the features */
	SMapSetObject(self->features, "_stress_func_plugin", S_OBJECT(sylPlugin), error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapSetObject\" failed"))
	{
		S_DELETE(stressProc, "Initialize", error);
		S_DELETE(sylPlugin, "Initialize", error);
		return;
	}

	SMapSetObject(self->features, "_stress_func", S_OBJECT(stressProc), error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Initialize",
				  "Call to \"SMapSetObject\" failed"))
	{
		S_DELETE(sylPlugin, "Initialize", error);
		return;
	}


	S_UNUSED(voice);
}