Skip to content

feat: Add Norwegian and improve Apple Silicon support#1

Closed
haqatak wants to merge 4 commits intobrianferri:mainfrom
haqatak:feat-norwegian-apple-silicon
Closed

feat: Add Norwegian and improve Apple Silicon support#1
haqatak wants to merge 4 commits intobrianferri:mainfrom
haqatak:feat-norwegian-apple-silicon

Conversation

@haqatak
Copy link

@haqatak haqatak commented Oct 10, 2025

This commit introduces two key enhancements:

  1. Norwegian Language Support:

    • Adds support for Norwegian Bokmål (nb) and Norwegian Nynorsk (nn) through the espeak-ng integration.
    • Includes aliases (no, no-nb, nn, no-nn) for easier use.
  2. Apple Silicon (MPS) Support:

    • Updates the device selection logic in kokoro/pipeline.py to automatically detect and use the MPS backend on Apple Silicon devices.
    • Removes the requirement for the PYTORCH_ENABLE_MPS_FALLBACK environment variable, streamlining the user experience.

This commit introduces two key enhancements:

1.  **Norwegian Language Support:**
    -   Adds support for Norwegian Bokmål (`nb`) and Norwegian Nynorsk (`nn`) through the `espeak-ng` integration.
    -   Includes aliases (`no`, `no-nb`, `nn`, `no-nn`) for easier use.

2.  **Apple Silicon (MPS) Support:**
    -   Updates the device selection logic in `kokoro/pipeline.py` to automatically detect and use the MPS backend on Apple Silicon devices.
    -   Removes the requirement for the `PYTORCH_ENABLE_MPS_FALLBACK` environment variable, streamlining the user experience.
This commit fixes a `mutex lock failed` runtime error on macOS by pre-loading the `espeak-ng` library. This is achieved by importing `misaki.espeak` at the top of `kokoro/__init__.py`, which ensures that `espeak-ng` is initialized before any other conflicting libraries are loaded.
This commit introduces several key changes:

1.  **Fix for macOS Runtime Error:**
    -   Resolves a `mutex lock failed` runtime error on macOS by pre-loading the `espeak-ng` library. This is achieved by importing `misaki.espeak` at the top of `kokoro/__init__.py`, which ensures that `espeak-ng` is initialized before any other conflicting libraries are loaded.

2.  **Norwegian Language Support:**
    -   Adds support for Norwegian Bokmål (`nb`) and Norwegian Nynorsk (`nn`) through the `espeak-ng` integration.
    -   Includes aliases (`no`, `no-nb`, `nn`, `no-nn`) for easier use.
    -   Updates the `README.md` to include instructions for using the new Norwegian language models.

3.  **Apple Silicon (MPS) Support:**
    -   Updates the device selection logic in `kokoro/pipeline.py` to automatically detect and use the MPS backend on Apple Silicon devices.
    -   Removes the requirement for the `PYTORCH_ENABLE_MPS_FALLBACK` environment variable, streamlining the user experience.
…nd expand language support.

1.  **Fix macOS IPython Crash:** Resolves a `libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument` error that occurred when importing the library within an IPython session on macOS. This is fixed by pre-loading the `espeak-ng` native library by importing `misaki.espeak` at the top of the package's `__init__.py`. This ensures it is initialized before other conflicting libraries loaded by IPython.

2.  **Add Norwegian Language Support:**
    -   Adds language codes for Norwegian Bokmål (`nb`) and Norwegian Nynorsk (`nn`) to the pipeline, utilizing the existing `espeak-ng` backend.
    -   Updates the `README.md` to include usage instructions for the new languages.

3.  **Improve Apple Silicon (MPS) Support:**
    -   Removes the check for the `PYTORCH_ENABLE_MPS_FALLBACK` environment variable. The library will now automatically select the `mps` backend if it is available on the system, simplifying the setup for users on Apple Silicon devices.
@brianferri
Copy link
Owner

brianferri commented Oct 14, 2025

Hi @haqatak! Thanks for the PR. however this is just a fork of the Kokoro project with it's own PR currently awaiting attention.
Please redirect your PR to the official repo for the project https://github.com/hexgrad/kokoro

@brianferri brianferri closed this Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants