/* 初期化: プログラム起動時に一度だけ実行 */ void initialize() { void setRun(); /*******↓for server mode *******/ if (s_mode) { server_init( nPort ); } /*******↑***********************/ #ifndef WIN32 setpgrp(); #endif set_da_signal(); init_slot_prop(); init_text_analysis(); init_hmmsynth(); read_phonemes( phlist_file ); read_dic( dic_file ); init_tag(); init_mora(); init_morph(); init_aphrase(); init_breath(); init_phoneme(); init_sentence(); strcpy( slot_Speak_stat, "IDLE" ); setRun( "=", "LIVE" ); strcpy( slot_Log_file, "NO" ); logfp = NULL; slot_Log_chasen= slot_Log_tag = slot_Log_phoneme = 0; slot_Log_mora = slot_Log_morph = slot_Log_aphrase = 0; slot_Log_breath = slot_Log_sentence = 0; strcpy( slot_Err_file, "CONSOLE" ); slot_Speech_file[0] = '\0'; slot_Pros_file[0] = '\0'; prosBuf.nPhoneme = 0; slot_Speak_syncinterval = 1000; }
int main(int argc, char ** argv) { try { tts::stress_type stress = tts::stress_type::as_transcribed; phoneme_mode mode = phoneme_mode::joined; bool no_pauses = false; bool show_features = false; const char *phoneme_map = nullptr; const char *accent = nullptr; const option_group general_options = { nullptr, { { 's', "separate", bind_value(mode, phoneme_mode::separate), i18n("Display each phoneme on a new line") }, { 'f', "features", bind_value(show_features, true), i18n("Show the features along with the transcription") }, { 0, "no-pauses", bind_value(no_pauses, true), i18n("Do not process pause phonemes") }, { 'M', "phoneme-map", phoneme_map, "PHONEME_MAP", i18n("Use PHONEME_MAP to convert phonemes (e.g. accent conversion)") }, { 'a', "accent", accent, "ACCENT", i18n("Use ACCENT to convert phonemes to the specified accent") }, }}; const option_group stress_options = { i18n("Phoneme Stress Placement:"), { { 0, "syllables", bind_value(mode, phoneme_mode::syllables), i18n("Show the syllable structure") }, { 0, "vowel-stress", bind_value(stress, tts::stress_type::vowel), i18n("Place the stress on vowels (e.g. espeak, arpabet)") }, { 0, "syllable-stress", bind_value(stress, tts::stress_type::syllable), i18n("Place the stress on syllable boundaries") }, }}; const option_group marker_options = { i18n("Phoneme Markers:"), { { 0, "broad", bind_value(mode, phoneme_mode::broad_markers), i18n("Use /.../ between phonetic transcriptions") }, { 0, "narrow", bind_value(mode, phoneme_mode::narrow_markers), i18n("Use [...] between phonetic transcriptions") }, { 0, "espeak", bind_value(mode, phoneme_mode::espeak_markers), i18n("Use [[...]] between phonetic transcriptions") }, }}; const std::initializer_list<const option_group *> options = { &general_options, &stress_options, &marker_options }; const std::initializer_list<const char *> usage = { i18n("phoneme-converter [OPTION..] FROM TO TRANSCRIPTION"), i18n("phoneme-converter [OPTION..] FROM TO"), }; if (!parse_command_line(options, usage, argc, argv)) return 0; if (argc != 2 && argc != 3) { print_help(options, usage); return 0; } auto from = tts::createPhonemeReader(argv[0]); auto to = tts::createPhonemeWriter(argv[1]); auto data = argc == 3 ? cainteoir::make_file_buffer(argv[2]) : cainteoir::make_file_buffer(stdin); if (phoneme_map) from = tts::createPhonemeToPhonemeConverter(phoneme_map, from); if (accent) from = tts::createAccentConverter(accent, from); if (mode == phoneme_mode::syllables) { auto syllables = tts::create_syllable_reader(); ipa::phonemes phonemes; from->reset(data); while (read_phonemes(from, phonemes)) { tts::make_stressed(phonemes, stress); print_phonemes(phonemes, to, syllables); } } else { ipa::phonemes phonemes; from->reset(data); while (read_phonemes(from, phonemes)) { tts::make_stressed(phonemes, stress); print_phonemes(phonemes, to, mode, no_pauses, show_features); } } } catch (std::runtime_error &e) { fprintf(stderr, i18n("error: %s\n"), e.what()); return EXIT_FAILURE; } return EXIT_SUCCESS; }