### Install haqumei-cli Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Install the haqumei-cli using cargo. ```bash cargo install haqumei-cli ``` -------------------------------- ### Install haqumei with Pip Source: https://github.com/o24s/haqumei/blob/main/README.md Install the haqumei Python package using pip. ```bash pip install haqumei ``` -------------------------------- ### Retrieve Text as Structured Data per Morpheme Source: https://github.com/o24s/haqumei/blob/main/README.md This example demonstrates how to use g2p_mapping_prosody to get structured linguistic and prosodic data for each morpheme in a given text. It shows how to access morpheme-specific details and phoneme-pitch information. ```rust use haqumei::{Haqumei, PitchAccent, ProsodicPhoneme}; fn main() -> Result<(), Box> { let mut haqumei = Haqumei::new()?; // Retrieve text as structured data per morpheme let mapping = haqumei.g2p_mapping_prosody("青い空が、好きだ!")?; // Morpheme information for "青い" let aoi = &mapping[0]; assert_eq!(aoi.word, "青い"); assert_eq!(aoi.pos, "形容詞"); assert_eq!(aoi.read, "アオイ"); assert_eq!(aoi.accent_nucleus, 2); // 中高型 // Phoneme and pitch information for "青い" (a: Low, o: High, i: Low) assert!(matches!( aoi.phonemes[0], ProsodicPhoneme::Phoneme { pitch: Some(PitchAccent::Low), .. } )); let da = mapping.last().unwrap(); assert_eq!(da.word, "!"); assert!(da.phonemes.contains(&ProsodicPhoneme::Exclamatory)); Ok(()) } ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Sets the minimum CMake version, library version, C++ standard, and package information. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.5) # set library version set(OPEN_JTALK_VERSION 1.11) set(CMAKE_CXX_STANDARD 14) set(PACKAGE "open_jtalk") set(PACKAGE_BUGREPORT "https://github.com/tsukumijima/open_jtalk/") set(PACKAGE_NAME "open_jtalk") set(PACKAGE_URL "") set(PACKAGE_VERSION ${OPEN_JTALK_VERSION}) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") ``` -------------------------------- ### Install haqumei with Cargo Source: https://github.com/o24s/haqumei/blob/main/README.md Add the haqumei crate to your Rust project dependencies. ```bash cargo add haqumei ``` -------------------------------- ### Define and Configure Open_Jtalk Executable Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/bin/CMakeLists.txt Adds the open_jtalk executable, sets its linker language to CXX, links it with required libraries and include directories, and installs it. ```cmake add_executable(open_jtalk open_jtalk.c) set_target_properties(open_jtalk PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries(open_jtalk PRIVATE openjtalk "${HTS_ENGINE_LIB}") target_include_directories(open_jtalk PRIVATE "${HTS_ENGINE_INCLUDE_DIR}") install(TARGETS open_jtalk DESTINATION bin) ``` -------------------------------- ### JSON Lines Output Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Generate structured JSON output using '--format json'. This example uses '--mode mapping-detailed'. ```bash $ haqumei-cli "テスト" --mode mapping-detailed --format json [{"word":"テスト","phonemes":["t","e","s","U","t","o"],"features":["テスト","名詞","サ変接続","*","*","*","*","テスト","テスト","テスト","1/3","C1"],"pos":"名詞","pos_group1":"サ変接続","pos_group2":"*","pos_group3":"*","ctype":"*","cform":"*","orig":"テスト","read":"テスト","pron":"テス’ト","accent_nucleus":1,"mora_count":3,"chain_rule":"C1","chain_flag":-1,"is_unknown":false,"is_ignored":false}] ``` -------------------------------- ### Install OpenJTalk Library and Headers (Non-MSVC) Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Installs the OpenJTalk library to the 'lib' directory and header files to 'include/openjtalk' when not using MSVC. This ensures the library and its associated headers are correctly placed for use in other projects. ```cmake if(NOT MSVC) install(TARGETS openjtalk DESTINATION lib) install(FILES jpcommon/jpcommon.h mecab/src/mecab.h mecab2njd/mecab2njd.h njd/njd.h njd2jpcommon/njd2jpcommon.h njd_set_accent_phrase/njd_set_accent_phrase.h njd_set_accent_type/njd_set_accent_type.h njd_set_digit/njd_set_digit.h njd_set_long_vowel/njd_set_long_vowel.h njd_set_pronunciation/njd_set_pronunciation.h njd_set_unvoiced_vowel/njd_set_unvoiced_vowel.h text2mecab/text2mecab.h DESTINATION include/openjtalk) endif() ``` -------------------------------- ### Customize G2P Output with Unicode Normalization Source: https://github.com/o24s/haqumei/blob/main/README.md Modify Haqumei's behavior using `Haqumei::with_options`. This example enables Unicode NFC normalization for input text, which is disabled by default. ```rust use haqumei::{Haqumei, HaqumeiOptions, UnicodeNormalization}; fn main() -> Result<(), Box> { let mut haqumei = Haqumei::with_options(HaqumeiOptions { normalize_unicode: UnicodeNormalization::Nfc, ..Default::default() })?; let text = &[ "\u{304B}\u{3099}", // か + ゙ (が) "\u{306F}\u{309a}", // は + ゚ (ぱ) "\u{30B3}\u{3099}", // コ + ゙ (ゴ) ]; println!("{:?}", haqumei.g2p_detailed_batch(text)?); // Output: [["g", "a"], ["p", "a"], ["g", "o"]] Ok(()) } ``` -------------------------------- ### Importing OpenJTalk CVS History with Git Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/README.md This command imports the CVS version of OpenJTalk into a Git repository, preserving its history. Ensure you have Git installed and are in the desired directory. ```bash git cvsimport -v \ -d :pserver:anonymous@open-jtalk.cvs.sourceforge.net:/cvsroot/open-jtalk \ -C open_jtalk open_jtalk ``` -------------------------------- ### Display Help Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Display the help message for haqumei-cli to see all available options. ```bash haqumei-cli --help ``` -------------------------------- ### Get Phoneme Mapping with Original Word String Source: https://github.com/o24s/haqumei/blob/main/README.md Use `g2p_pairs` to get the correspondence between phonemes and their original words. This function traverses the JPCommon structure to link phonemes to their source words. ```rust use haqumei::Haqumei; fn main() -> Result<(), Box> { let mut haqumei = Haqumei::new()?; println!("{:?}", haqumei.g2p_pairs("𰻞𰻞麺&お冷を頼んだ")?); // [WordPhonemePair { // word: "𰻞𰻞", // phonemes: ["pau"] // }, WordPhonemePair { // word: "麺", // phonemes: ["m", "e", "N"] // }, WordPhonemePair { // word: "&", // phonemes: ["a", "N", "d", "o"] // }, WordPhonemePair { // word: "お冷", // phonemes: ["o", "h", "i", "y", "a"] // }, ... ] Ok(()) } ``` -------------------------------- ### Initialize and Convert Text Source: https://github.com/o24s/haqumei/blob/main/haqumei-kanalizer/README.md Demonstrates how to initialize the Kanalizer and convert English text to Katakana. Ensure the ONNX model is correctly bundled or accessible. ```rust let mut kanalizer = haqumei_kanalizer::Kanalizer::new().unwrap(); let kana = kanalizer.convert("kanalizer").unwrap(); assert_eq!(kana, "カナライザー"); ``` -------------------------------- ### Rust: Basic haqumei Usage Source: https://github.com/o24s/haqumei/blob/main/README.md Demonstrates converting Japanese text to phonemes, prosody-annotated phonemes, and katakana reading using the Haqumei Rust library. ```rust use haqumei::Haqumei; fn main() -> Result<(), Box> { let mut haqumei = Haqumei::new()?; let text = "こんにちは、世界!"; // Convert to phoneme list let phonemes = haqumei.g2p(text)?; assert_eq!(phonemes, ["k", "o", "N", "n", "i", "ch", "i", "w", "a", "pau", "s", "e", "k", "a", "i"]); // Get phoneme list with prosodic symbols let phones = haqumei.g2p_prosody(text)?.join(" "); assert_eq!(phones, "^ k o [ N n i ch i w a _ s e ] k a i ! $"); // Convert to katakana reading let kana = haqumei.g2k(text)?; assert_eq!(kana, "コンニチワ、セカイ!"); Ok(()) } ``` -------------------------------- ### Python: Basic haqumei Usage Source: https://github.com/o24s/haqumei/blob/main/README.md Demonstrates converting Japanese text to phonemes, prosody-annotated phonemes, and katakana reading using the Haqumei Python library. ```python from haqumei import Haqumei # Initialize Haqumei (the dictionary will be automatically set up) haqumei = Haqumei() text = "こんにちは、世界!" # Convert to a phoneme list phonemes = haqumei.g2p(text) print(f"Phonemes: {phonemes}") # -> Phonemes: ["k", "o", "N", "n", "i", "ch", "i", "w", "a", "pau", "s", "e", "k", "a", "i"] # Get phoneme list with prosodic symbols phones = " ".join(haqumei.g2p_prosody(text)) print(f"Prosody-annotated phonemes: {phones}") # -> Prosody-annotated phonemes: ^ k o [ N n i ch i w a _ s e ] k a i ! $ # Convert to katakana reading kana = haqumei.g2k(text) print(f"Katakana reading: {kana}") # -> Katakana reading: コンニチワ、セカイ! ``` -------------------------------- ### REPL Mode Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Run haqumei-cli without arguments to enter interactive mode. Press Ctrl+C or Ctrl+D to exit. ```bash $ haqumei-cli Enter text to process (Ctrl+C or Ctrl+D to exit): > 今日はいい天気ですね。 ky o o w a i i t e N k i d e s U n e ``` -------------------------------- ### Configure Header File Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Generates the mecab/config.h file from a template (config.h.in) using CMake's configure_file command. This file will contain definitions based on the preceding checks. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mecab/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/mecab/src/config.h) ``` -------------------------------- ### Creating the OpenJTalk Library Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Adds the main library target 'openjtalk' and compiles it using the collected source files. It also sets the version and shared object version for the library. ```cmake add_library(openjtalk ${libjpcommon_source} ${libmecab_source} ${libmecab2njd_source} ${libnjd_source} ${libnjd2jpcommon_source} ${libnjd_set_accent_phrase_source} ${libnjd_set_accent_type_source} ${libnjd_set_digit_source} ${libnjd_set_long_vowel_source} ${libnjd_set_pronunciation_source} ${libnjd_set_unvoiced_vowel_source} ${libtext2mecab_source}) set_target_properties(openjtalk PROPERTIES VERSION ${OPEN_JTALK_VERSION}) set_target_properties(openjtalk PROPERTIES SO_VERSION ${OPEN_JTALK_VERSION}) ``` -------------------------------- ### Build Configuration and Source Directory Inclusion Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Configures the project name and uses aux_source_directory to collect source files from various subdirectories. It also includes the necessary directories for the compiler. ```cmake # build configuration project(openjtalk) aux_source_directory(jpcommon libjpcommon_source) aux_source_directory(mecab/src libmecab_source) aux_source_directory(mecab2njd libmecab2njd_source) aux_source_directory(njd libnjd_source) aux_source_directory(njd2jpcommon libnjd2jpcommon_source) aux_source_directory(njd_set_accent_phrase libnjd_set_accent_phrase_source) aux_source_directory(njd_set_accent_type libnjd_set_accent_type_source) aux_source_directory(njd_set_digit libnjd_set_digit_source) aux_source_directory(njd_set_long_vowel libnjd_set_long_vowel_source) aux_source_directory(njd_set_pronunciation libnjd_set_pronunciation_source) aux_source_directory(njd_set_unvoiced_vowel libnjd_set_unvoiced_vowel_source) aux_source_directory(text2mecab libtext2mecab_source) include_directories(jpcommon mecab/src mecab2njd njd njd2jpcommon njd_set_accent_phrase njd_set_accent_type njd_set_digit njd_set_long_vowel njd_set_pronunciation njd_set_unvoiced_vowel text2mecab) ``` -------------------------------- ### Set HAQUMEI_DICT_SRC Environment Variable (Unix-like) Source: https://github.com/o24s/haqumei/blob/main/README.md On Unix-like systems, set the HAQUMEI_DICT_SRC environment variable to the path of your custom dictionary source directory before building. This ensures the build script uses your provided dictionary. ```bash HAQUMEI_DICT_SRC="/path/to/your/dictionary" cargo build --release ``` -------------------------------- ### Prosody Output with Prefix Format Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Generate prosody output using the prefix format for phonemes. ```bash # Prefix format (--prosody-format prefix) $ haqumei-cli "青い空" --mode prosody --prosody-format prefix ^ L_a H_o L_i # H_s H_o L_r L_a $ ``` -------------------------------- ### Detailed G2P Output with Special Tokens Source: https://github.com/o24s/haqumei/blob/main/README.md Utilize `g2p_detailed` and related functions to identify unknown words as `unk` and spaces/symbols as `sp`. This differs from standard G2P which treats unknowns as `pau`. ```rust use haqumei::Haqumei; fn main() -> Result<(), Box> { let mut haqumei = Haqumei::new()?; println!("{:?}", haqumei.g2p_detailed("こんにちは 𰻞𰻞麺")?); // ["k", "o", "N", "n", "i", "ch", "i", "w", "a", "sp", "unk", "m", "e", "N"] println!("{:?}", haqumei.g2p_mapping("𰻞𰻞麺 お冷を頼んだ")?); // [WordPhonemeMap { // word: "𰻞𰻞", // phonemes: ["unk"], // is_unknown: true, // is_ignored: false, // }, // WordPhonemeMap { // word: "麺", // phonemes: ["m", "e", "N"], // is_unknown: false, // is_ignored: false, // }, // WordPhonemeMap { // word: "\u{3000}", // phonemes: ["sp"], // is_unknown: false, // is_ignored: true, // }, // WordPhonemeMap { // word: "お冷", // phonemes: ["o", "h", "i", "y", "a"], // is_unknown: false, // is_ignored: false, // }, ... ] println!("{:?}", haqumei.g2p_mapping_detailed("薄明")?); // [WordPhonemeDetail { // word: "薄明", // phonemes: ["h","a","k","u","m","e","e"], // features: [ // "薄明", // "名詞", // "一般", // "*", // "*", // "*", // "*", // "薄明", // "ハクメイ", // "ハクメー", // "0/4", // "C2", // ], // pos: "名詞", // pos_group1: "一般", // pos_group2: "*", // pos_group3: "*", // ctype: "*", // cform: "*", // orig: "薄明", // read: "ハクメイ", // pron: "ハクメー", // accent_nucleus: 0, // mora_count: 4, // chain_rule: "C2", // chain_flag: -1, // is_unknown: false, // is_ignored: false, // }] Ok(()) } ``` -------------------------------- ### Build Programs Option Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Configures whether to build the associated programs for Open JTalk. Defaults to OFF. ```cmake option(BUILD_PROGRAMS "Build Programs" OFF) if(BUILD_PROGRAMS) add_subdirectory(bin) endif() ``` -------------------------------- ### Check Libraries Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Uses CMake's CheckLibraryExists module to verify the availability of external libraries. It checks for 'iconv' and 'm' (math library) and stores results in variables like ICONV_CONST and HAVE_LIBM. ```cmake include(CheckLibraryExists) check_library_exists(iconv iconv_open "" ICONV_CONST) check_library_exists(m sqrt "" HAVE_LIBM) ``` -------------------------------- ### Add Preprocessor Definitions Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Defines preprocessor macros for the build. These include configuration flags (HAVE_CONFIG_H), version information (DDIC_VERSION, VERSION), package name (DPACKAGE), and build-specific options (DMECAB_WITHOUT_SHARE_DIC). ```cmake add_definitions(-DHAVE_CONFIG_H -DDIC_VERSION=102 -DMECAB_DEFAULT_RC="dummy" -DMECAB_WITHOUT_SHARE_DIC -DPACKAGE="open_jtalk" -DVERSION="${OPEN_JTALK_VERSION}") ``` -------------------------------- ### Haqumei Options for ROHAN Accuracy Source: https://github.com/o24s/haqumei/blob/main/README.md Configuration for Haqumei when evaluating accuracy on the ROHAN dataset. Enables reverting long vowels and yotsugana. ```rust HaqumeiOptions { revert_long_vowels: true, revert_yotsugana: true, ..Default::default() } ``` -------------------------------- ### Convert Text to Phonemes with Default Prosody Source: https://github.com/o24s/haqumei/blob/main/README.md Converts Japanese text to a phoneme list with default prosodic symbols, including utterance boundaries, pauses, and accent phrase boundaries. This method is equivalent to `g2p_prosody_with_options` with `ProsodyFormat::Default`. ```rust use haqumei::Haqumei; fn main() -> Result<(), Box> { let mut haqumei = Haqumei::new()?; let phones = haqumei.g2p_prosody("こんにちは、世界!")?; assert_eq!(phones.join(" "), "^ k o [ N n i ch i w a _ s e ] k a i ! $"); let phones = haqumei.g2p_prosody("青い空、広がる。")?; assert_eq!(phones.join(" "), "^ a [ o ] i # s o ] r a _ h i [ r o g a r u _ $"); Ok(()) } ``` -------------------------------- ### Check for HTSEngine and Error Handling Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/bin/CMakeLists.txt Verifies if HTSEngine was found. If not, it terminates the build with a fatal error message. ```cmake if(NOT HTS_ENGINE_INCLUDE_DIR OR NOT HTS_ENGINE_LIB) message(FATAL_ERROR "Required HTSEngine not found") endif() ``` -------------------------------- ### File Processing Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Read from an input file and write to an output file using the 'g2p' mode. ```bash haqumei-cli --input input.txt --output output.txt --mode g2p ``` -------------------------------- ### Prosody Output Source: https://github.com/o24s/haqumei/blob/main/haqumei-cli/README.md Output phoneme sequences with accent phrase boundaries and pitch markers using '--mode prosody'. ```bash $ haqumei-cli "青い空が、好きだ!" --mode prosody ^ a [ o ] i # s o ] r a g a _ s U [ k i ] d a ! $ ``` -------------------------------- ### Configure Cargo Features for Custom Dictionary Source: https://github.com/o24s/haqumei/blob/main/README.md Modify your Cargo.toml to disable the default dictionary download and enable custom dictionary building. Ensure you specify the correct version. ```toml [dependencies] haqumei = { version = "x.y.z", features = ["embed-dictionary", "build-dictionary"], default-features = false } ``` -------------------------------- ### Find HTSEngine Dependency Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/bin/CMakeLists.txt Locates the HTSEngine header file and library. Includes a fallback mechanism for the library name. ```cmake find_path(HTS_ENGINE_INCLUDE_DIR HTS_engine.h) find_library(HTS_ENGINE_LIB hts_engine_API) if(NOT HTS_ENGINE_LIB) # fallback find_library(HTS_ENGINE_LIB HTSEngine) endif() ``` -------------------------------- ### Set Library Type Option Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Configures whether to build Open JTalk as a shared or static library. Defaults to static. ```cmake option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF) if(BUILD_SHARED_LIBS) set(LIB_TYPE SHARED) else() set(LIB_TYPE STATIC) endif() ``` -------------------------------- ### Haqumei Options for jsut-label Accuracy Source: https://github.com/o24s/haqumei/blob/main/README.md Configuration for Haqumei when evaluating accuracy on the jsut-label dataset. Enables Unidic yomi and specific IU pronunciation normalization. ```rust HaqumeiOptions { use_unidic_yomi: true, normalize_iu: Some(IuPronunciation::Yuu), ..Default::default() } ``` -------------------------------- ### Set Character Set Configuration Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Sets the character encoding for the Open JTalk build. Defaults to UTF-8. ```cmake set(CHARSET "utf8") ``` -------------------------------- ### Configure EUC-JP Character Set Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Adds definitions and compile options for EUC-JP character encoding. This is used when the CHARSET variable is set to 'eucjp'. ```cmake elseif(${CHARSET} STREQUAL "eucjp") add_definitions(-DCHARSET_EUC_JP -DMECAB_CHARSET=euc-jp) target_compile_options(openjtalk PRIVATE $<$:/source-charset:euc-jp;/execution-charset:euc-jp> ) ``` -------------------------------- ### Configure UTF-8 Character Set Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Adds definitions and compile options for UTF-8 character encoding. This is used when the CHARSET variable is set to 'utf8'. ```cmake elseif(${CHARSET} STREQUAL "utf8") add_definitions(-DCHARSET_UTF_8 -DMECAB_CHARSET=utf-8 -DMECAB_UTF8_USE_ONLY) foreach(flag CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) set(${flag} "${${flag}} -finput-charset=UTF-8 -fexec-charset=UTF-8") endforeach() target_compile_options(openjtalk PRIVATE $<$:/source-charset:UTF-8;/execution-charset:UTF-8> ) ``` -------------------------------- ### Check C Standard Library Functions Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Uses CMake's CheckFunctionExists module to verify the availability of standard C functions. The results are stored in cache variables like HAVE_GETENV. ```cmake include(CheckFunctionExists) check_function_exists(getenv HAVE_GETENV) check_function_exists(getpagesize HAVE_GETPAGESIZE) check_function_exists(mmap HAVE_MMAP) check_function_exists(opendir HAVE_OPENDIR) check_function_exists(setjmp HAVE_SETJMP) check_function_exists(sqrt HAVE_SQRT) check_function_exists(strstr HAVE_STRSTR) ``` -------------------------------- ### Handle Unrecognized Character Set Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Generates a fatal error if an unrecognized character set is specified. This ensures that only supported encodings are used. ```cmake else() message(FATAL_ERROR "Encoding ${CHARSET} not recognized. You can set sjis/eucjp/utf8") endif() ``` -------------------------------- ### Check C Standard Library Headers Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Uses CMake's CheckIncludeFiles module to verify the availability of standard C headers. The results are stored in cache variables like HAVE_CTYPE_H. ```cmake include(CheckIncludeFiles) check_include_files(ctype.h HAVE_CTYPE_H) check_include_files(dirent.h HAVE_DIRENT_H) check_include_files(fcntl.h HAVE_FCNTL_H) check_include_files(inttypes.h HAVE_INTTYPES_H) check_include_files(io.h HAVE_IO_H) check_include_files(memory.h HAVE_MEMORY_H) check_include_files(setjmp.h HAVE_SETJMP_H) check_include_files(stdint.h HAVE_STDINT_H) check_include_files(stdlib.h HAVE_STDLIB_H) check_include_files(strings.h HAVE_STRINGS_H) check_include_files(string.h HAVE_STRING_H) check_include_files(sys/mman.h HAVE_SYS_MMAN_H) check_include_files(sys/stat.h HAVE_SYS_STAT_H) check_include_files(sys/times.h HAVE_SYS_TIMES_H) check_include_files(sys/types.h HAVE_SYS_TYPES_H) check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(windows.h HAVE_WINDOWS_H) ``` -------------------------------- ### Set HAQUMEI_DICT_SRC Environment Variable (Windows PowerShell) Source: https://github.com/o24s/haqumei/blob/main/README.md On Windows using PowerShell, set the HAQUMEI_DICT_SRC environment variable to your custom dictionary source directory path. This is necessary for the build script to locate and compile your dictionary. ```powershell & { $env:HAQUMEI_DICT_SRC="C:\path\to\your\dictionary"; cargo build --release } ``` -------------------------------- ### Configure SJIS Character Set Source: https://github.com/o24s/haqumei/blob/main/haqumei/vendor/open_jtalk/src/CMakeLists.txt Adds definitions and compile options for SJIS (Shift_JIS) character encoding. This is used when the CHARSET variable is set to 'sjis'. ```cmake if(${CHARSET} STREQUAL "sjis") add_definitions(-DCHARSET_SHIFT_JIS -DMECAB_CHARSET=sjis) foreach(flag CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) set(${flag} "${${flag}} -finput-charset=cp932 -fexec-charset=cp932") endforeach() target_compile_options(openjtalk PRIVATE $<$:/source-charset:.932;/execution-charset:.932> ) else() ```