{"id":26220515,"url":"https://github.com/lyrcaxis/kokorosharpbinaries","last_synced_at":"2025-12-27T05:28:30.627Z","repository":{"id":276841642,"uuid":"927567278","full_name":"Lyrcaxis/KokoroSharpBinaries","owner":"Lyrcaxis","description":"Repo that builds and hosts stuff KokoroSharp's .nupkg needs to become Plug \u0026 Play.","archived":false,"fork":false,"pushed_at":"2025-02-05T20:10:56.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T15:51:34.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lyrcaxis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-05T07:04:18.000Z","updated_at":"2025-02-08T12:57:04.000Z","dependencies_parsed_at":"2025-02-10T19:06:50.911Z","dependency_job_id":"bb81c35c-76c9-4f67-b822-5a79b72118f8","html_url":"https://github.com/Lyrcaxis/KokoroSharpBinaries","commit_stats":null,"previous_names":["lyrcaxis/kokorosharpbinaries"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lyrcaxis%2FKokoroSharpBinaries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lyrcaxis%2FKokoroSharpBinaries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lyrcaxis%2FKokoroSharpBinaries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lyrcaxis%2FKokoroSharpBinaries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lyrcaxis","download_url":"https://codeload.github.com/Lyrcaxis/KokoroSharpBinaries/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243238972,"owners_count":20259132,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-12T15:17:48.476Z","updated_at":"2025-12-27T05:28:30.620Z","avatar_url":"https://github.com/Lyrcaxis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KokoroSharpBinaries\nThis repo builds and hosts stuff **KokoroSharp**'s `.nupkg` needs to become Plug \u0026amp; Play.\n\nYou can find **KokoroSharp**'s code on [its official github repo](https://github.com/Lyrcaxis/KokoroSharp) and download it via [NuGet](https://www.nuget.org/packages/KokoroSharp/).\n\n## Shoutout to:\n- https://huggingface.co/hexgrad/Kokoro-82M for the fantastic Kokoro-82M model and its voices\n- https://github.com/thewh1teagle/espeak-ng-static for 100% working binary-building workflow\n- https://github.com/taylorchu/kokoro-onnx for the plug-and-play onnx-converted kokoro models\n\n# Building espeak-ng for Android (`.so` libraries)\n\nThis repository includes a script (`build_android.sh`) to automate the compilation of the [espeak-ng text-to-speech engine](https://github.com/espeak-ng/espeak-ng) into shared libraries (`.so`) for various Android architectures (ABIs). This is useful for embedding `espeak-ng`'s phonetization or synthesis capabilities directly into an Android application (e.g., built with Unity, React Native, or native Android).\n\nThe script uses CMake and the Android NDK (Native Development Kit) for cross-compilation.\n\n## Prerequisites\n\nBefore running the build script, ensure you have the following installed on your system:\n\n1.  **Git:** To clone repositories.\n2.  **Android NDK:**\n    *   The easiest way is via Android Studio: `Tools -\u003e SDK Manager -\u003e SDK Tools -\u003e NDK (Side by side)`. Note the installation path.\n    *   Alternatively, download directly from the [Android NDK website](https://developer.android.com/ndk/downloads).\n3.  **CMake:** A cross-platform build system generator.\n    *   Download from [cmake.org](https://cmake.org/download/) or install via package manager.\n4.  **Ninja:** A small build system focused on speed (used by the script).\n    *   **Linux (Debian/Ubuntu):** `sudo apt update \u0026\u0026 sudo apt install ninja-build`\n    *   **macOS (Homebrew):** `brew install ninja`\n    *   **Windows:** Download `ninja-win.zip` from the [Ninja GitHub Releases](https://github.com/ninja-build/ninja/releases), extract `ninja.exe`, and ensure it's in your system's PATH. (Easier if using WSL - see below).\n5.  **Basic Build Tools (Host):** A C/C++ compiler for your host system (like GCC/Clang, Make) might be needed by CMake or espeak-ng's build process for host tools.\n    *   **Linux (Debian/Ubuntu):** `sudo apt install build-essential`\n    *   **macOS:** Install Xcode Command Line Tools: `xcode-select --install`\n    *   **Windows:** Often covered by installing Visual Studio Build Tools or using WSL/Git Bash.\n\n## Setup\n\n1.  **Clone this Repository:**\n    ```bash\n    git clone \u003cyour-repo-url\u003e\n    cd \u003cyour-repo-name\u003e\n    ```\n2.  **Clone espeak-ng:** The build script expects the `espeak-ng` source code to be in a directory named `espeak-ng` *inside* the directory where you run the script.\n    ```bash\n    git clone https://github.com/espeak-ng/espeak-ng.git\n    ```\n    Your directory structure should look like this:\n    ```\n    \u003cyour-repo-name\u003e/\n    ├── build_android.sh  \u003c-- The build script\n    ├── espeak-ng/        \u003c-- The cloned espeak-ng source code\n    └── README.md         \u003c-- This file (potentially)\n    └── ... (other files from your repo)\n    ```\n\n## Configuration (Important!)\n\nBefore running the script, you **must** configure the path to your Android NDK installation:\n\n1.  **Edit the `build_android.sh` script:** Open the file in a text editor.\n2.  **Locate the `NDK_ROOT` variable:** Find the lines near the top:\n    ```bash\n    # !!! IMPORTANT: Set the path to your Android NDK installation !!!\n    # Example: export NDK_ROOT=\"/Users/your_user/Library/Android/sdk/ndk/25.1.8937393\"\n    # Example: export NDK_ROOT=\"/home/user/Android/Sdk/ndk/25.1.8937393\"\n    # Example: export NDK_ROOT=\"C:/Users/user/AppData/Local/Android/Sdk/ndk/25.1.8937393\" # (Use Git Bash/WSL on Windows)\n    # NDK_ROOT=\n    ```\n3.  **Set the Path:** Uncomment the `NDK_ROOT=` line and set the correct path to your NDK installation directory. **Use the correct path format for your operating system and shell environment!**\n    *   **Linux/macOS:** `/path/to/your/ndk/version`\n    *   **Windows (using Git Bash):** `/c/path/to/your/ndk/version` (Note the leading `/c/` for C drive)\n    *   **Windows (using WSL):** `/mnt/c/path/to/your/ndk/version` (Note the leading `/mnt/c/` for C drive)\n\n4.  **(Optional) Adjust Other Settings:** You can also modify:\n    *   `MIN_API_LEVEL`: Target minimum Android SDK level (default is usually fine).\n    *   `ABIS_TO_BUILD`: An array of Android architectures to build for (e.g., `\"arm64-v8a\"`, `\"armeabi-v7a\"`).\n\n## Execution\n\n1.  **Open a Terminal or Shell:**\n    *   **Linux/macOS:** Use your standard terminal.\n    *   **Windows:** **Use WSL (Windows Subsystem for Linux - Recommended) or Git Bash.** Do *not* use standard Command Prompt or PowerShell directly, as they don't run bash scripts properly.\n        *   **WSL:** Open your Linux distribution (e.g., Ubuntu). Install prerequisites within WSL (`sudo apt install ...`).\n        *   **Git Bash:** Launch Git Bash. Ensure CMake and Ninja (downloaded `ninja.exe`) are in your Windows PATH.\n2.  **Navigate:** `cd` into the directory containing the `build_android.sh` script and the `espeak-ng` source folder.\n3.  **Make Executable (Linux/macOS/WSL/Git Bash):**\n    ```bash\n    chmod +x build_android.sh\n    ```\n4.  **Run the Script:**\n    ```bash\n    ./build_android.sh\n    ```\n5.  **Windows Specific - Permissions:**\n    *   The build process might try to create symbolic links. If you encounter a `\"privilege not held\"` error near the end:\n        *   **Option A (Recommended):** Enable **Developer Mode** in Windows Settings (`Settings -\u003e Privacy \u0026 security -\u003e For developers -\u003e Developer Mode`). Restart your shell (WSL/Git Bash) and rerun the script.\n        *   **Option B:** Run your WSL or Git Bash terminal **as Administrator** before executing the script.\n\nThe script will configure, build, and install `espeak-ng` for each ABI specified in `ABIS_TO_BUILD`. This may take some time.\n\n## Output\n\nUpon successful completion, the script will create an output directory (default: `android_libs`) in the same location where you ran the script. Inside, you will find the compiled shared libraries organized by ABI:\n```text\n\u003cyour-repo-name\u003e/\n├── android_libs/\n│   ├── arm64-v8a/\n│   │   └── libespeak-ng.so\n│   ├── armeabi-v7a/\n│   │   └── libespeak-ng.so\n│   ├── x86/\n│   │   └── libespeak-ng.so\n│   └── x86_64/\n│       └── libespeak-ng.so\n├── build_android.sh\n├── espeak-ng/\n└── ... (other files from your repo)\n```\n\n## Using the Libraries (Example: Unity)\n\n1.  Copy the contents of the relevant ABI directories from `android_libs/` into your Unity project's `Assets/Plugins/Android/libs/` folder. For example: \n    *   Copy `android_libs/arm64-v8a/libespeak-ng.so` to `YourUnityProject/Assets/Plugins/Android/libs/arm64-v8a/libespeak-ng.so`\n    *   Copy `android_libs/armeabi-v7a/libespeak-ng.so` to `YourUnityProject/Assets/Plugins/Android/libs/armeabi-v7a/libespeak-ng.so`\n    *   *(Repeat for other ABIs like x86, x86_64 if needed)*\n2.  **Bundle espeak-ng Data:** Copy the `espeak-ng-data` directory (found inside the `espeak-ng` source directory after a successful build, or potentially from the temporary `_install-android-*` folders) into your Unity project's `Assets/StreamingAssets/` folder. You will need code in your app to copy this data from `StreamingAssets` to a writable location (`Application.persistentDataPath`) on the device at runtime and tell the espeak-ng library where to find it via an initialization function.\n3.  **P/Invoke:** Use C#'s `[DllImport(\"__Internal\")]` mechanism to declare and call the native C functions exposed by `libespeak-ng.so` (e.g., functions for initialization and phonetization). Refer to the C# bindings example provided earlier or `espeak-ng`'s public API documentation (`espeak-ng/docs/api.md` or `espeak-ng/src/include/espeak-ng/espeak_ng.h`).\n\n## Troubleshooting\n\n*   **`NDK_ROOT environment variable is not set` or `NDK_ROOT directory not found`:** Double-check the `NDK_ROOT` path in `build_android.sh`. Ensure it's uncommented, points to the correct NDK location, and uses the proper path format for your shell (WSL/Git Bash paths on Windows!).\n*   **`CMake Error: ... MSBuild command:`:** You are likely running in an environment where CMake defaults to the Visual Studio generator. Ensure you are using WSL or Git Bash, and that the `-G \"Ninja\"` flag is present in the `cmake` command within the script. Make sure Ninja is installed and accessible.\n*   **`ninja: command not found` or similar:** Ninja is not installed or not in the system PATH. Install it using your package manager (Linux/macOS/WSL) or download `ninja.exe` and add it to your PATH (Windows/Git Bash).\n*   **`CMake Error: failed to create symbolic link ... privilege not held` (Windows):** Enable Developer Mode in Windows Settings or run the script terminal as Administrator.\n*   **Build Errors:** Check the script output for specific compilation errors. Ensure all prerequisites are installed. Try cleaning the build directories (`build-android-*` and `_install-android-*` inside the `espeak-ng` folder) and running the script again.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyrcaxis%2Fkokorosharpbinaries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyrcaxis%2Fkokorosharpbinaries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyrcaxis%2Fkokorosharpbinaries/lists"}