Beispiel #1
0
int Phrasing( ChewingData *pgdata )
{
	TreeDataType treeData;

	InitPhrasing( &treeData );

	FindInterval( pgdata, &treeData );
	SetInfo( pgdata->nPhoneSeq, &treeData );
	Discard1( &treeData );
	Discard2( &treeData );
	SaveList( &treeData );
	CountMatchCnnct( &treeData, pgdata->bUserArrCnnct, pgdata->nPhoneSeq );
	SortListByScore( &treeData );
	NextCut( &treeData, &pgdata->phrOut );

#ifdef ENABLE_DEBUG
	ShowList( &treeData );
	DEBUG_FLUSH;
#endif

	/* set phrasing output */
	OutputRecordStr(
		pgdata,
		pgdata->phrOut.chiBuf, sizeof(pgdata->phrOut.chiBuf),
		( treeData.phList )->arrIndex, 
		( treeData.phList )->nInter, 
		pgdata->phoneSeq,
		pgdata->nPhoneSeq,
		pgdata->selectStr, pgdata->selectInterval, pgdata->nSelect, &treeData );
	SaveDispInterval( &pgdata->phrOut, &treeData );

	/* free "phrase" */
	CleanUpMem( &treeData );
	return 0;
}
float InterpolateSpectrumSamples(const float *lambda, const float *vals, int n,
                                 float l) {
    for (int i = 0; i < n - 1; ++i) Assert_(lambda[i + 1] > lambda[i]);
    if (l <= lambda[0]) return vals[0];
    if (l >= lambda[n - 1]) return vals[n - 1];
    int offset = FindInterval(n, [&](int index) { return l >= lambda[index]; });
    Assert_(l >= lambda[offset] && l <= lambda[offset + 1]);
    float t = (l - lambda[offset]) / (lambda[offset + 1] - lambda[offset]);
    return SpectrumLerp(t, vals[offset], vals[offset + 1]);
}
Beispiel #3
0
int Phrasing(
		ChewingData *pgdata, /* FIXME: Remove other parameters since they are all in pgdata. */
		PhrasingOutput *ppo, uint16_t phoneSeq[], int nPhoneSeq,
		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
		IntervalType selectInterval[], int nSelect, 
		int bArrBrkpt[], int bUserArrCnnct[] ) 
{
	TreeDataType treeData;

	InitPhrasing( &treeData );

	FindInterval( 
		pgdata,
		phoneSeq, nPhoneSeq, selectStr, selectInterval, nSelect, 
		bArrBrkpt, &treeData );
	SetInfo( nPhoneSeq, &treeData );
	Discard1( &treeData );
	Discard2( &treeData );
	SaveList( &treeData );
	CountMatchCnnct( &treeData, bUserArrCnnct, nPhoneSeq );
	SortListByScore( &treeData );
	NextCut( &treeData, ppo );

#ifdef ENABLE_DEBUG
	ShowList( &treeData );
	DEBUG_FLUSH;
#endif

	/* set phrasing output */
	OutputRecordStr(
		pgdata,
		ppo->chiBuf, sizeof(ppo->chiBuf),
		( treeData.phList )->arrIndex, 
		( treeData.phList )->nInter, 
		phoneSeq, 
		nPhoneSeq, 
		selectStr, selectInterval, nSelect, &treeData );
	SaveDispInterval( ppo, &treeData );

	/* free "phrase" */
	CleanUpMem( &treeData );
	return 0;
}