1

The following is the link to Goole dictionary pronunciation files:

http://ssl.gstatic.com/dictionary/static/sounds/20160317/pronunciation--_us_1.mp3

If you substitute "pronunciation" with your own word, you get that word's pronunciation.

I wonder if it is possible to develop a script in mac which allows the user to type his word and the script fetches its pronunciation through the above link. I can already use the automator to fetch the definition for a new word (by using the code presented here) through the link below by adding words after the equal sign.

https://www.google.com/search?sa=X&biw=1440&bih=737&q=Dictionary#dobs=

But I don't know how I can insert words in the mentioned place in the pronunciation link.

0

In bash, it's very easy:

cd ~/Desktop; curl --remote-name-all --silent --url \
http://ssl.gstatic.com/dictionary/static/sounds/20160317/\
{wrought,drought,rough,thorough}--_us_1.mp3

That will download the files for wrought, drought, rough, and thorough, and save them on the desktop.

If you want to put it in an AppleScript:

    set word_list to {"wrought", "drought", "rough", "thorough"}

    set my text item delimiters to ","
    set my text item delimiters to {word_list as text, "{word-list}"}

    set curl to "cd ~/Desktop; curl --remote-name-all --silent --url " & ¬
        "http://ssl.gstatic.com/dictionary/static/sounds/20160317/" & ¬
        "{{word-list}}--_us_1.mp3"

    text items of curl as text

    do shell script the result

To obtain user input to allow a user to supply a word to feed into the URL, replace the first line with these two:

    display dialog "Enter a word:" default answer "pronunciation"
    set word_list to {text returned} of the result
  • Thanks a lot for replying. But I don't want to give it a word list in advance. Isn't it possible to insert the new words one by one in an interactive way. I mean, I wanted to be able to add a new word in a dialogue box and the script checks the pronunciation and opens it in a browser. – developer Aug 9 '18 at 16:34
  • Those are example scripts to show you how it's done. Of course, there are a myriad ways to incorporate user interaction that will allow you to supply a word to the script. I'll make an edit to demonstrate. – CJK Aug 9 '18 at 16:41
0

Here is a basic AppleScript that does as you've asked:

set theWord to text returned of (display dialog ¬
    "Enter a word to pronounce:" buttons {"Cancel", "OK"} ¬
    default button "OK" default answer ¬
    "" with title "What word would you like to pronounce?")

set theURL to "http://ssl.gstatic.com/dictionary/static/sounds/20160317/" & theWord & "--_us_1.mp3"

open location theURL

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .