本文整理汇总了C++中HTS_error函数的典型用法代码示例。如果您正苦于以下问题:C++ HTS_error函数的具体用法?C++ HTS_error怎么用?C++ HTS_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HTS_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HTS_Stream_load_pdf_and_tree
/* HTS_Stream_load_pdf_and_tree: load PDFs and trees */
static void HTS_Stream_load_pdf_and_tree(HTS_Stream * stream, FILE ** pdf_fp,
FILE ** tree_fp, HTS_Boolean msd_flag,
int interpolation_size)
{
int i;
/* initialize */
stream->msd_flag = msd_flag;
stream->interpolation_size = interpolation_size;
stream->model =
(HTS_Model *) HTS_calloc(interpolation_size, sizeof(HTS_Model));
/* load */
for (i = 0; i < stream->interpolation_size; i++) {
if (!pdf_fp[i])
HTS_error(1,
"HTS_Stream_load_pdf_and_tree: File for duration PDFs is not specified.\n");
if (!tree_fp[i])
HTS_error(1,
"HTS_Stream_load_pdf_and_tree: File for duration trees is not specified.\n");
HTS_Model_initialize(&stream->model[i]);
HTS_Model_load_tree(&stream->model[i], tree_fp[i]);
HTS_Model_load_pdf(&stream->model[i], pdf_fp[i], stream->model[i].ntree,
stream->msd_flag);
}
/* check */
for (i = 1; i < stream->interpolation_size; i++)
if (stream->model[0].vector_length != stream->model[i].vector_length)
HTS_error(1,
"HTS_Stream_load_pdf_and_tree: Vector sizes of state output vectors are different in between given modelsets.\n");
/* set */
stream->vector_length = stream->model[0].vector_length;
}
示例2: HTS_Audio_open
/* HTS_Audio_open: open audio device */
static void HTS_Audio_open(HTS_Audio * audio, int sampling_rate, int max_buff_size)
{
if (audio->sampling_rate == sampling_rate && audio->max_buff_size == max_buff_size)
return;
HTS_Audio_close(audio);
audio->sampling_rate = sampling_rate;
audio->max_buff_size = max_buff_size;
if (audio->max_buff_size <= 0)
return;
audio->err = Pa_Initialize();
if (audio->err != paNoError)
HTS_error(0, "hts_engine: Failed to initialize your output audio device to play waveform.\n");
audio->parameters.device = Pa_GetDefaultOutputDevice();
audio->parameters.channelCount = 1;
audio->parameters.sampleFormat = paInt16;
audio->parameters.suggestedLatency = Pa_GetDeviceInfo(audio->parameters.device)->defaultLowOutputLatency;
audio->parameters.hostApiSpecificStreamInfo = NULL;
audio->err = Pa_OpenStream(&audio->stream, NULL, &audio->parameters, sampling_rate, max_buff_size, paClipOff, NULL, NULL);
if (audio->err != paNoError)
HTS_error(0, "hts_engine: Failed to open your output audio device to play waveform.\n");
audio->err = Pa_StartStream(audio->stream);
if (audio->err != paNoError)
HTS_error(0, "hts_engine: Failed to start your output audio device to play waveform.\n");
audio->buff = (short *) HTS_calloc(max_buff_size, sizeof(short));
audio->buff_size = 0;
}
示例3: HTS_ModelSet_load_parameter
/* HTS_ModelSet_load_parameter: load model */
void HTS_ModelSet_load_parameter(HTS_ModelSet * ms, FILE ** pdf_fp,
FILE ** tree_fp, FILE ** win_fp,
int stream_index, HTS_Boolean msd_flag,
int window_size, int interpolation_size)
{
int i;
/* check */
if (pdf_fp == NULL)
HTS_error(1,
"HTS_ModelSet_load_parameter: File for pdfs is not specified.\n");
if (tree_fp == NULL)
HTS_error(1,
"HTS_ModelSet_load_parameter: File for wins is not specified.\n");
if (win_fp == NULL)
HTS_error(1,
"HTS_ModelSet_load_parameter: File for wins is not specified.\n");
/* initialize */
if (!ms->stream) {
ms->stream = (HTS_Stream *) HTS_calloc(ms->nstream, sizeof(HTS_Stream));
for (i = 0; i < ms->nstream; i++)
HTS_Stream_initialize(&ms->stream[i]);
}
/* load */
HTS_Stream_load_pdf_and_tree(&ms->stream[stream_index], pdf_fp, tree_fp,
msd_flag, interpolation_size);
HTS_Stream_load_dynamic_window(&ms->stream[stream_index], win_fp,
window_size);
}
示例4: HTS_Audio_close
/* HTS_Audio_close: close audio device */
static void HTS_Audio_close(HTS_Audio * audio)
{
MMRESULT error;
if (audio->max_buff_size <= 0)
return;
/* stop audio */
error = waveOutReset(audio->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot stop and reset your output audio device.\n");
/* unprepare */
error = waveOutUnprepareHeader(audio->hwaveout, &(audio->buff_1), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
error = waveOutUnprepareHeader(audio->hwaveout, &(audio->buff_2), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
/* close */
error = waveOutClose(audio->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Failed to close your output audio device.\n");
HTS_free(audio->buff_1.lpData);
HTS_free(audio->buff_2.lpData);
HTS_free(audio->buff);
}
示例5: HTS_ModelSet_load_duration
/* HTS_ModelSet_load_duration: load duration model and number of state */
HTS_Boolean HTS_ModelSet_load_duration(HTS_ModelSet * ms, HTS_File ** pdf_fp, HTS_File ** tree_fp, int interpolation_size)
{
/* check */
if (ms == NULL) {
return FALSE;
}
if (interpolation_size <= 0) {
HTS_ModelSet_clear(ms);
return FALSE;
}
if (pdf_fp == NULL) {
HTS_error(1, "HTS_ModelSet_load_duration: File for duration PDFs is not specified.\n");
HTS_ModelSet_clear(ms);
return FALSE;
}
if (tree_fp == NULL) {
HTS_error(1, "HTS_ModelSet_load_duration: File for duration trees is not specified.\n");
HTS_ModelSet_clear(ms);
return FALSE;
}
if (HTS_Stream_load_pdf_and_tree(&ms->duration, pdf_fp, tree_fp, interpolation_size) == FALSE) {
HTS_ModelSet_clear(ms);
return FALSE;
}
ms->nstate = ms->duration.vector_length;
return TRUE;
}
示例6: HTS_Audio_close
/* HTS_Audio_close: close audio device */
void HTS_Audio_close(HTS_Audio * as)
{
MMRESULT error;
if (as->buff_size != 0)
HTS_Audio_write_buffer(as);
while (as->now_buff_1 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
while (as->now_buff_2 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
/* stop audio */
error = waveOutReset(as->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0,
"hts_engine: Cannot stop and reset your output audio device.\n");
/* unprepare */
error = waveOutUnprepareHeader(as->hwaveout, &(as->buff_1), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0,
"hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
error = waveOutUnprepareHeader(as->hwaveout, &(as->buff_2), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0,
"hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
/* close */
error = waveOutClose(as->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Failed to close your output audio device.\n");
HTS_free(as->buff_1.lpData);
HTS_free(as->buff_2.lpData);
HTS_free(as->buff);
}
示例7: HTS_Model_load_tree
/* HTS_Model_load_tree: load trees */
static void HTS_Model_load_tree(HTS_Model * model, FILE * fp)
{
char buff[HTS_MAXBUFLEN];
HTS_Question *question, *last_question;
HTS_Tree *tree, *last_tree;
int state;
/* check */
if (fp == NULL)
HTS_error(1, "HTS_Model_load_tree: File for trees is not specified.\n");
model->ntree = 0;
last_question = NULL;
last_tree = NULL;
while (!feof(fp)) {
HTS_get_pattern_token(fp, buff);
/* parse questions */
if (strcmp(buff, "QS") == 0) {
question = (HTS_Question *) HTS_calloc(1, sizeof(HTS_Question));
HTS_Question_load(question, fp);
if (model->question)
last_question->next = question;
else
model->question = question;
question->next = NULL;
last_question = question;
}
/* parse trees */
state = HTS_get_state_num(buff);
if (state != 0) {
tree = (HTS_Tree *) HTS_calloc(1, sizeof(HTS_Tree));
tree->next = NULL;
tree->root = NULL;
tree->head = NULL;
tree->state = state;
HTS_Tree_parse_pattern(tree, buff);
HTS_Tree_load(tree, fp, model->question);
if (model->tree)
last_tree->next = tree;
else
model->tree = tree;
tree->next = NULL;
last_tree = tree;
model->ntree++;
}
}
/* No Tree information in tree file */
if (model->tree == NULL)
HTS_error(1, "HTS_Model_load_tree: No trees are loaded.\n");
}
示例8: HTS_ModelSet_load_duration
/* HTS_ModelSet_load_duration: load duration model and number of state */
void HTS_ModelSet_load_duration(HTS_ModelSet * ms, FILE ** pdf_fp,
FILE ** tree_fp, int interpolation_size)
{
/* check */
if (pdf_fp == NULL)
HTS_error(1,
"HTS_ModelSet_load_duration: File for duration PDFs is not specified.\n");
if (tree_fp == NULL)
HTS_error(1,
"HTS_ModelSet_load_duration: File for duration trees is not specified.\n");
HTS_Stream_load_pdf_and_tree(&ms->duration, pdf_fp, tree_fp, FALSE,
interpolation_size);
ms->nstate = ms->duration.vector_length;
}
示例9: HTS_Stream_load_pdf
/* HTS_Stream_load_pdf: load pdf */
static HTS_Boolean HTS_Stream_load_pdf(HTS_Stream * stream, HTS_File ** fp, int ntree, int interpolation_size)
{
int i;
HTS_Boolean result = TRUE;
/* initialize */
stream->interpolation_size = interpolation_size;
stream->model = (HTS_Model *) HTS_calloc(interpolation_size, sizeof(HTS_Model));
/* load pdfs */
for (i = 0; i < stream->interpolation_size; i++) {
HTS_Model_initialize(&stream->model[i]);
if (HTS_Model_load_pdf(&stream->model[i], fp[i], ntree, &stream->msd_flag) == FALSE)
result = FALSE;
}
if (result == FALSE) {
HTS_Stream_clear(stream);
return FALSE;
}
/* check */
for (i = 1; i < stream->interpolation_size; i++) {
if (stream->model[0].vector_length != stream->model[1].vector_length) {
HTS_error(1, "HTS_Stream_load_pdf: # of states are different in between given modelsets.\n");
HTS_Stream_clear(stream);
return FALSE;
}
}
/* set */
stream->vector_length = stream->model[0].vector_length;
return TRUE;
}
示例10: HTS_ModelSet_get_gv_switch_index
/* HTS_ModelSet_get_gv_switch_index: get index of GV switch tree and PDF */
void HTS_ModelSet_get_gv_switch_index(HTS_ModelSet * ms, char *string, int *tree_index, int *pdf_index)
{
HTS_Tree *tree;
HTS_Pattern *pattern;
HTS_Boolean find;
find = FALSE;
(*tree_index) = 2;
(*pdf_index) = 1;
for (tree = ms->gv_switch.tree; tree; tree = tree->next) {
pattern = tree->head;
if (!pattern)
find = TRUE;
for (; pattern; pattern = pattern->next)
if (HTS_pattern_match(string, pattern->string)) {
find = TRUE;
break;
}
if (find)
break;
(*tree_index)++;
}
if (tree == NULL) {
HTS_error(1, "HTS_ModelSet_get_gv_switch_index: Cannot find model %s.\n", string);
return;
}
(*pdf_index) = HTS_Tree_search_node(tree, string);
}
示例11: HTS_Audio_write_buffer
/* HTS_Audio_write_buffer: send buffer to audio device */
static void HTS_Audio_write_buffer(HTS_Audio * audio)
{
MMRESULT error;
if (audio->which_buff == 1) {
while (audio->now_buff_1 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
audio->now_buff_1 = TRUE;
audio->which_buff = 2;
memcpy(audio->buff_1.lpData, audio->buff, audio->buff_size * sizeof(short));
audio->buff_1.dwBufferLength = audio->buff_size * sizeof(short);
error = waveOutWrite(audio->hwaveout, &(audio->buff_1), sizeof(WAVEHDR));
} else {
while (audio->now_buff_2 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
audio->now_buff_2 = TRUE;
audio->which_buff = 1;
memcpy(audio->buff_2.lpData, audio->buff, audio->buff_size * sizeof(short));
audio->buff_2.dwBufferLength = audio->buff_size * sizeof(short);
error = waveOutWrite(audio->hwaveout, &(audio->buff_2), sizeof(WAVEHDR));
}
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot send datablocks to your output audio device to play waveform.\n");
}
示例12: HTS_fread
/* HTS_fread: wrapper for fread */
static size_t HTS_fread(void *buf, size_t size, size_t n, HTS_File * fp)
{
if (fp == NULL || size == 0 || n == 0) {
return 0;
}
if (fp->type == HTS_FILE) {
return fread(buf, size, n, (FILE *) fp->pointer);
} else if (fp->type == HTS_DATA) {
HTS_Data *d = (HTS_Data *) fp->pointer;
size_t i, length = size * n;
unsigned char *c = (unsigned char *) buf;
for (i = 0; i < length; i++) {
if (d->index < d->size)
c[i] = d->data[d->index++];
else
break;
}
if (i == 0)
return 0;
else
return i / size;
}
HTS_error(0, "HTS_fread: Unknown file type.\n");
return 0;
}
示例13: HTS_ModelSet_get_parameter_index
/* HTS_ModelSet_get_parameter_index: get index of parameter tree and PDF */
void HTS_ModelSet_get_parameter_index(HTS_ModelSet * ms, char *string,
int *tree_index, int *pdf_index,
int stream_index, int state_index,
int interpolation_index)
{
HTS_Tree *tree;
HTS_Pattern *pattern;
HTS_Boolean find;
find = FALSE;
(*tree_index) = 2;
(*pdf_index) = 1;
for (tree = ms->stream[stream_index].model[interpolation_index].tree; tree;
tree = tree->next) {
if (tree->state == state_index) {
pattern = tree->head;
if (!pattern)
find = TRUE;
for (; pattern; pattern = pattern->next)
if (HTS_pattern_match(string, pattern->string)) {
find = TRUE;
break;
}
if (find)
break;
}
(*tree_index)++;
}
if (tree == NULL)
HTS_error(1, "HTS_ModelSet_get_parameter_index: Cannot find model %s.\n",
string);
(*pdf_index) = HTS_Tree_search_node(tree, string);
}
示例14: HTS_ModelSet_load_parameter
/* HTS_ModelSet_load_parameter: load model */
HTS_Boolean HTS_ModelSet_load_parameter(HTS_ModelSet * ms, HTS_File ** pdf_fp, HTS_File ** tree_fp, HTS_File ** win_fp, int stream_index, int window_size, int interpolation_size)
{
int i;
/* check */
if (ms == NULL) {
return FALSE;
}
if (stream_index < 0 || stream_index >= ms->nstream || window_size <= 0 || interpolation_size <= 0) {
HTS_ModelSet_clear(ms);
return FALSE;
}
if (pdf_fp == NULL) {
HTS_error(1, "HTS_ModelSet_load_parameter: File for pdfs is not specified.\n");
HTS_ModelSet_clear(ms);
return FALSE;
}
if (tree_fp == NULL) {
HTS_error(1, "HTS_ModelSet_load_parameter: File for wins is not specified.\n");
HTS_ModelSet_clear(ms);
return FALSE;
}
if (win_fp == NULL) {
HTS_error(1, "HTS_ModelSet_load_parameter: File for wins is not specified.\n");
HTS_ModelSet_clear(ms);
return FALSE;
}
/* initialize */
if (!ms->stream) {
ms->stream = (HTS_Stream *) HTS_calloc(ms->nstream, sizeof(HTS_Stream));
for (i = 0; i < ms->nstream; i++)
HTS_Stream_initialize(&ms->stream[i]);
}
/* load */
if (HTS_Stream_load_pdf_and_tree(&ms->stream[stream_index], pdf_fp, tree_fp, interpolation_size) == FALSE) {
HTS_ModelSet_clear(ms);
return FALSE;
}
if (HTS_Stream_load_dynamic_window(&ms->stream[stream_index], win_fp, window_size) == FALSE) {
HTS_ModelSet_clear(ms);
return FALSE;
}
return TRUE;
}
示例15: HTS_error
/* HTS_Node_find: find node for given number */
static HTS_Node *HTS_Node_find(HTS_Node * node, const int num)
{
for (; node; node = node->next)
if (node->index == num)
return node;
HTS_error(1, "HTS_Node_find: Cannot find node %d.\n", num);
return NULL; /* make compiler happy */
}