Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified language codes --> #9 #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

acerjay
Copy link

@acerjay acerjay commented Oct 10, 2024

Unified language code support for most of the TTS engines. #9
Can be modified to convert into alpha code (three character string)

@willwade
Copy link
Owner

Great. Don't do this yet - this is more a comment for me. I think we need to keep dialect / region info. This is actually tough because it needs reimagining what the final dict looks like but here's an idea

def getISOLangCode(dialect: str) -> Tuple[str, str]:
    try:
        language = str(Language.get(dialect))
    except Exception as dialectError:
        dialect = dialect.split('-')[0]
        language = str(Language.get(dialect))
    
    region = dialect.split('-')[1] if '-' in dialect else ""
    return (language, region)

# Example usage
langcode, region = getISOLangCode("en-US")
print(langcode)  # Output: 'en'
print(region)    # Output: 'US'

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