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

gl_talk: language code detection #86

Open
retowyss opened this issue Apr 13, 2024 · 2 comments
Open

gl_talk: language code detection #86

retowyss opened this issue Apr 13, 2024 · 2 comments

Comments

@retowyss
Copy link
Contributor

For text to speech, the Neural2 voices require passing of the full language code (en-GB, en-US, ...) not just the first two letters (en, ...).

Error in `abort_http()`:
! http_400 Requested language code 'en' doesn't match the voice 'en-GB-Neural2-F''s language code 'en-gb'. Either pick a different voice, or change the requested language code to en-gb.

The gl_talk implementation forces the languageCode to be derived from the first two letters of the name parameter, so there's no way to overcome this.

if (!is.null(name)) {
        assert_that(is.string(name))
        languageCode <- substr(name, 1, 2)
        gender <- NULL
    }

I can submit a fix but there are multiple ways this could be resolved.

a) Check whether name contains "Neural", if so grab first 5 characters for languageCode
b) add parameter to force supplied languageCode parameter force_languageCode = FALSE (?)

Drawback of a) is it requires code updates to the code for every model that requires the full languageCode.

b) doesn't look elegant, but it will never break existing code. Particularly, it can be passed through text2speech::tts_google's ... parameter.

I'd prefer the function never overwrites the languageCode, but that surely is a breaking change.

@retowyss
Copy link
Contributor Author

#87

Tested this through

text2speech::tts_google(
  text = "This works now, yay!", 
  voice = "en-GB-Neural2-F", 
  languageCode = "en-gb",
  forceLanguageCode = TRUE
)

@MarkEdmondson1234
Copy link
Collaborator

Thanks, b looks good to prevent breaking changes

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

No branches or pull requests

2 participants