@@ -0,0 +1,2138 @@
+import requests%0A%0A%0Adef Main(myfile, lang, apikey):%0A      with open(myfile) as words:%0A            for i in words:%0A                  n=0%0A                  while n %3C 250:%0A                  #The free API let you make 500 request per-day, we're gonna use two request per-word%0A                  %0A                        #here we clean the string from formatting and white space%0A                        s = i.lower()%0A                        s = s.lstrip()%0A                        s = s.rstrip()%0A                        s = s.replace(' ','%2520')  #%2520 is vital to perform a correct call whit simple sentences that have white spaces%0A                        s = s.replace('%5Cn','')    #Replacing the escape character is important%0A                        %0A                        #let's make the first request%0A                        r = ForvoHttpRequest('word-pronunciations',s,lang,apikey)%0A                        %0A                        #now we download the mp3 files from forvo server if r is not-empty%0A                        if r:%0A                              #the second request%0A                              mp3 = requests.get(r)%0A                              with open(i.replace('%5Cn','')+'.mp3',%22wb%22) as out:%0A                                    out.write(mp3.content)%0A                                    out.close()%0A                        else:%0A                              with open('pronuonce_not_found.txt',%22a%22) as out:%0A                                    out.write(s)%0A                                    out.close()%0A                        %0A                        n = n+1%0A                  %0A                  %0A        %0Adef ForvoHttpRequest(act, word, lang, apikey):%0A      url = 'http://apifree.forvo.com/action/%7B0%7D/format/json/word/%7B1%7D/language/%7B2%7D/order/rate-desc/limit/1/key/%7B3%7D'.format(act, word, lang, apikey)%0A%0A      r = requests.get(url)%0A      data = r.json()%0A      print data%0A      if data:%0A            path = data%5B0%5D%0A      %0A            if path:%0A                  mp3path = path.get('pathmp3',)%0A            else:%0A                  mp3path = ''%0A      else:%0A            mp3path = ''%0A            %0A      return mp3path%0A            %0A

Create forvo.py