int main(int argc, char *argv[]) { int i, num; long acc = 0; struct timespec t1; struct timespec t2; cst_voice * v = NULL; mimic_init(); mimic_set_lang_list(); if (argc < 3) { print_usage(argv[0]); return -1; } else if (argc < 3) num = 1; else num = atoi(argv[2]); for(i = 0; i < num; i++) { current_utc_time(&t1); v = mimic_voice_load(argv[1]); current_utc_time(&t2); acc += (t2.tv_sec - t1.tv_sec) * 1000000000 + (t2.tv_nsec - t1.tv_nsec); } if (v != NULL) { printf("voice name: %s, %ld\n", v->name, acc); } return 0; }
/** * Initialize the mimic encoder and prepare for encoding by * initializing internal state and allocating resources as * needed. * * After initializing use #mimic_get_property to determine * the size of the output buffer needed for calls to * #mimic_encode_frame. Use #mimic_set_property to set * encoding quality. * * Note that once a given context has been initialized * for either encoding or decoding it is not possible * to initialize it again. * * @param ctx the mimic context to initialize * @param resolution a #MimicResEnum used to specify the resolution * @returns #TRUE on success */ gboolean mimic_encoder_init(MimCtx *ctx, const MimicResEnum resolution) { gint width, height; /* Check if we've been initialized before. */ if (ctx->encoder_initialized || ctx->decoder_initialized) return FALSE; /* Check resolution. */ if (resolution == MIMIC_RES_LOW) { width = 160; height = 120; } else if (resolution == MIMIC_RES_HIGH) { width = 320; height = 240; } else { return FALSE; } /* Initialize! */ mimic_init(ctx, width, height); /* Set a default quality setting. */ ctx->quality = ENCODER_QUALITY_DEFAULT; ctx->encoder_initialized = TRUE; return TRUE; }
void common_init(void) { mimic_init(); mimic_set_lang_list(); if (mimic_voice_list == NULL) mimic_set_voice_list(VOICE_LIST_DIR); }
int main(int argc, char **argv) { cst_voice *v; char thetime[1024]; char b[3]; int hour, min; cst_regex *timex; char *output = "play"; if (argc != 2) { fprintf(stderr, "usage: mimic_time HH:MM\n"); exit(-1); } timex = new_cst_regex("[012][0-9]:[0-5][0-9]"); if (!cst_regex_match(timex, argv[1])) { fprintf(stderr, "not a valid time\n"); fprintf(stderr, "usage: mimic_time HH:MM\n"); exit(-1); } delete_cst_regex(timex); b[2] = '\0'; b[0] = argv[1][0]; b[1] = argv[1][1]; hour = atoi(b); b[0] = argv[1][3]; b[1] = argv[1][4]; min = atoi(b); mimic_init(); v = register_cmu_time_awb(NULL); sprintf(thetime, "The time is now, %s %s %s, %s.", time_approx(hour, min), time_min(hour, min), time_hour(hour, min), time_tod(hour, min)); printf("%s\n", thetime); mimic_text_to_speech(thetime, v, output); mimic_exit(); return 0; }
/** * Initialize the mimic decoder. The frame passed in frame_buffer * is used to determine the resolution so that the internal state * can be prepared and resources allocated accordingly. Note that * the frame passed has to be a keyframe. * * After initializing use #mimic_get_property to determine required * buffer-size, resolution, quality, etc. * * Note that once a given context has been initialized * for either encoding or decoding it is not possible * to initialize it again. * * @param ctx the mimic context to initialize * @param frame_buffer buffer containing the first frame to decode * @returns #TRUE on success */ gboolean mimic_decoder_init(MimCtx *ctx, const guchar *frame_buffer) { gint width, height; gboolean is_keyframe; /* Check if we've been initialized before and that * frame_buffer is not NULL. */ if (ctx->encoder_initialized || ctx->decoder_initialized || frame_buffer == NULL) { return FALSE; } /* Check resolution. */ width = GUINT16_FROM_LE(*((guint16 *) (frame_buffer + 4))); height = GUINT16_FROM_LE(*((guint16 *) (frame_buffer + 6))); if (!(width == 160 && height == 120) && !(width == 320 && height == 240)) return FALSE; /* Check that we're initialized with a keyframe. */ is_keyframe = (GUINT32_FROM_LE(*((guint32 *) (frame_buffer + 12))) == 0); if (!is_keyframe) return FALSE; /* Get quality setting (in case we get queried for it before decoding). */ ctx->quality = GUINT16_FROM_LE(*((guint16 *) (frame_buffer + 2))); /* Initialize! */ mimic_init(ctx, width, height); ctx->decoder_initialized = TRUE; return TRUE; }