Exemplo n.º 1
0
u32 RunHTKDec(void *par)
{
	BitStream *bs;
	char *szWord;
	s32 word_index;
	u32 len, val, i;
	Float word_score;
	SLHeader slh;
	unsigned char *buf;
	u32 buf_size;


	ISPriv *is_dec = (ISPriv *)par;
//	while (is_dec->htk_running)

	HTK_DoDetection();
	szWord = HTK_GetWord();
	word_index = HTK_GetWordIndex();
	word_score = HTK_GetWordScore();

	fprintf(stdout, "HTK result: %s %d %f\n", szWord, word_index, word_score);

	bs = NewBitStream(NULL, 0, BS_WRITE);
	
	/*HTK sensor buffer format: SFString - SFInt32 - SFFloat*/
	BS_WriteInt(bs, 1, 1); 
	len = strlen(szWord);
	val = GetNumBits(len);
	BS_WriteInt(bs, val, 5);
	BS_WriteInt(bs, len, val);
	for (i=0; i<len; i++) BS_WriteInt(bs, szWord[i], 8);

	BS_WriteInt(bs, 1, 1); 
	BS_WriteInt(bs, word_index, 32);
	BS_WriteInt(bs, 1, 1); 
	BS_WriteFloat(bs, word_score);

	BS_Align(bs);
	BS_GetContent(bs, &buf, &buf_size);
	DeleteBitStream(bs);

	memset(&slh, 0, sizeof(SLHeader));
	slh.accessUnitStartFlag = slh.accessUnitEndFlag = 1;
	slh.compositionTimeStamp = 0;

	/*get all IS keySensor decoders and send frame*/
	for (i=0; i<ChainGetCount(is_dec->scene->root_od->term->input_streams); i++) {
		GenericCodec *cod = ChainGetEntry(is_dec->scene->root_od->term->input_streams, i);
		ISPriv *is = cod->decio->privateStack;
		if (is != is_dec) continue;
		if (is->type==IS_HTKSensor) {
			Channel *ch = ChainGetEntry(cod->inChannels, 0);
			Channel_RecieveSLP(ch->service, ch, buf, buf_size, &slh, M4OK);
		}
	}
	free(buf);

	is_dec->htk_running = 0;
	return 0;
}
Exemplo n.º 2
0
u32 RunHTKDec(void *par)
{
	GF_BitStream *bs;
	char *szWord;
	s32 word_index;
	u32 len, val, i;
	Float word_score;
	GF_SLHeader slh;
	GF_Codec *cod;
	unsigned char *buf;
	u32 buf_size;


	ISPriv *is_dec = (ISPriv *)par;
//	while (is_dec->htk_running)

	HTK_DoDetection();
	szWord = HTK_GetWord();
	word_index = HTK_GetWordIndex();
	word_score = HTK_GetWordScore();

	bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);
	
	/*HTK sensor buffer format: SFString - SFInt32 - SFFloat*/
	gf_bs_write_int(bs, 1, 1); 
	len = strlen(szWord);
	val = gf_get_bit_size(len);
	gf_bs_write_int(bs, val, 5);
	gf_bs_write_int(bs, len, val);
	for (i=0; i<len; i++) gf_bs_write_int(bs, szWord[i], 8);

	gf_bs_write_int(bs, 1, 1); 
	gf_bs_write_int(bs, word_index, 32);
	gf_bs_write_int(bs, 1, 1); 
	gf_bs_write_float(bs, word_score);

	gf_bs_align(bs);
	gf_bs_get_content(bs, &buf, &buf_size);
	gf_bs_del(bs);

	memset(&slh, 0, sizeof(GF_SLHeader));
	slh.accessUnitStartFlag = slh.accessUnitEndFlag = 1;
	slh.compositionTimeStamp = 0;

	/*get all IS keySensor decoders and send frame*/
	i=0; 
	while ((cod = gf_list_enum(is_dec->scene->root_od->term->input_streams, &i))) {
		ISPriv *is = cod->decio->privateStack;
		if (is != is_dec) continue;
		if (is->type==IS_HTKSensor) {
			GF_Channel *ch = gf_list_get(cod->inChannels, 0);
			gf_es_receive_sl_packet(ch->service, ch, buf, buf_size, &slh, GF_OK);
		}
	}
	free(buf);

	is_dec->htk_running = 0;
	return 0;
}