gsay: Fetch pronunciation of English vocabulary from Google

37 points 12 comments a day ago
myfonj

I've made something (probably) very similar for quick GB vs US pronunciation check that also leeches on Google's snapshot of what I believe is a licensed copy of the Oxford collection the same way the shell script does, but mine "runs in browser's URL bar" instead. It's a super tiny dataURI HTML document, intended to be bookmarked with a keyword (say, "say"):

    data:text/html;charset=utf-8,<title>US-GB pronunciation 2.0.2</title><body onload=x='https://ssl.gstatic.com/dictionary/static/sounds/20160317/' text=snow bgcolor=black><button onfocus=click() onclick=a.src=x+i.value+'--_us_1.mp3';a.play()>US</button><input id=i placeholder=(shift+)tab value="%s"><button onfocus=click() onclick=a.src=x+i.value+'--_gb_1.mp3';a.play()>GB</button><audio id=a onplay=i.focus()></audio>
so when I do

    Alt+D, "say something", Enter
then hitting Tab plays it in British and Shift+Tab plays it in US English. It uses older 2016 batch, because I totally adore the US voice in it: just listen to "music" [1] and tell it isn't pure ASMR.

(I'm afraid it just a matter of time they will prevent our mischief, though.)

[0] oxfordlearnersdictionaries.com uses the same collection. [1] https://ssl.gstatic.com/dictionary/static/sounds/20160317/mu...

IAmBroom

Dubiously, I clicked. Yeah, I could listen to her read the dictionary as I waft off to sleep...

myfonj

Ha ha, really glad to hear that. (The fact is, I am kinda freak/junkie about human voices, and that particular one stands really high on my list of irresistible tingles-inducing specimens. So happy to hear I am not alone.)

chastings

Have you found any you like in the AI world for text to speech? I know ElevenLabs and OpenAI have voices, but I'm hoping to build something that can be run locally.

therealpygon

Would be nice if there were enough words in a sentence with that voice to create an ai voice clone.

giancarlostoro

English is not my first language, and I didn't realize it was "google say" at first, so I was sitting here scratching my head wondering how you could possibly pronounce this word. Interesting that it's a shell script and not so much a browser extension or something. I guess this is for when you're knee deep in terminals?

pooyamo

> I guess this is for when you're knee deep in terminals?

One can use it directly in terminal or it can be used as a dependency tool in other scripts similar to the way other UNIX tools are used. For example I use it as a pronunciation player in my dictionary dict-master [1]. It's a shell script too.

Another example (run two times so it uses the cache the second time):

  echo this unix pipeline is poor man text to speech | xargs -n 1 gsay
[1]: https://github.com/pvonmoradi/dict-master
edwcross

I tried running the suggested code (curl -sL ...) but inadvertently did not check it was missing quotes around '\r'. So after a while I started seeing some errors:

[error] No valid link found according to patterns for 'aboad'

[error] No valid link found according to patterns for 'absob'

[error] No valid link found according to patterns for 'acoss'

I thought "well, there's quite a lot of words I need to learn in English", but after seeing 'addess' and 'adventue' I thought "wait, this is not ight".

Fixing it helps, but there are still missing expressions, such as "add up", "a couple", etc.

pooyamo

Thanks! Fixed that example. (In fish shell that I use, it didn't need those quotes that's why I didn't catch it)

>there are still missing expressions, such as "add up", "a couple", etc.

Googling "pronounce add up" does not show the google short answer box for me. Aside from that, the heuristic method I used may miss some words since it's not quite clear to me how the naming scheme works in that static stash. The 2024 stash is more straightforward but as I mentioned in readme, it sounds synthetic to me.

dilap

There is a website forvo.com which has a bunch of community-generated pronunciations of words in a ton of languages. I used to use it a lot when I was playing around w/ learning languages.

There's also a paid API. I made a very basic command-line client which might still work: https://github.com/erinok/forvosay

5-

what is the source of google's pronunciations?

i've always held the cambridge learner dictionary's ones in high esteem.

e.g. https://dictionary.cambridge.org/dictionary/english/pronunci...

Tagbert

so many of the pronunciations I find on the web are just raw text-to-speech outputs that assume a generic pronunciation and fail for many words, in particular for names. I hope that the Google ones are actually human generated and verified, but am not confident of that.

Made by @calebRussel