translate-shell icon indicating copy to clipboard operation
translate-shell copied to clipboard

Add support for choosing en-US for Google voice

Open ibrshv opened this issue 7 years ago • 3 comments

Will be great to have ability to choose US voice for Google. Like this: https://github.com/AwesomeTTS/awesometts-anki-addon/blob/a6bb2fc61bdd6bc2285f3874f41594cda0172bcd/awesometts/service/google.py

ibrshv avatar Mar 18 '18 13:03 ibrshv

You can edit the binary (as a superuser if necessary) to support American English TTS via the Google API. Use which trans to find the file to edit. Then change:

    function googleTTSUrl(text, tl) {
    return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=gtx"\
    "&tl=" tl "&q=" preprocessByDump(text)
    }

... to:

    function googleTTSUrl(text, tl) {
    if (tl == "en") tl = tl "-US"
    return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=gtx"\
    "&tl=" tl "&q=" preprocessByDump(text)
    }

PennRobotics avatar Apr 19 '20 19:04 PennRobotics

In short, you want to specify en-US as the target language (variable tl in that script) without messing up other input languages. I think my proposed change accomplishes this without ill side-effects but cannot be overridden if you want an English pronunciation with a non-American accent.

(On a side note, if you use Google Translate's website in a region which defaults to non-American pronunciation, you can force American pronunciation by using translate.google.as, which is the American Samoa suffix.)

PennRobotics avatar Apr 19 '20 20:04 PennRobotics

Maybe better solution will be add the separate us language type? Especially for audio, pronunciation of US English and British English is very different for some words, eg schedule.

MurzNN avatar Jul 20 '21 07:07 MurzNN