Skip to content

Ability to change fallback for missing lang_code #153

Closed

Description

@Krurst

Hi' I'd like to be able to change the fallback behaviour for the language selection when the API request doesn't specify a lang_code.
At the moment, it automatically selects the language based on the voice file. I'd like to be able to override that in the config file. This will give access to a lot more variety of voices in other apps.

I've gone and kludged the code directly to change the fallback, and it works quite nicely, but I don't have the coding skill to make it just an easy to change config file option.

Line under the comment "# Use provided lang_code or get from voice name" in kokoro_v1.py is where the logic happens.

Thanks! And great work so far - this is by far the best option for TTS I've tried on my mac!

Activity

  1. remsky commented on Feb 11, 2025

    @remsky
    Owner

    Thanks! Glad it's working for you! And I was making a change on the dockerfile, and was able to sneak this in on the main branch at
    24b31cc. Let me know if it's what you had in mind. Haven't tested it completely, but will take a further look tomorrow

    You should be able to set the voice/lang_code as an environment variable on run via the below command, or manually editing the config file for uv run/docker compose

    docker run -p 8880:8880 -e DEFAULT_VOICE_CODE=e ghcr.io/remsky/kokoro-fastapi-cpu:v0.2.1

    It's just building to v0.2.1post1 here https://github.com/remsky/Kokoro-FastAPI/actions/runs/13262317639 as the prebuilt image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions