Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####Settings###
- startfrom = 0
- endat = 2000
- show_words = False #Output the spanish words or leave them blank?
- ###imports###
- from num2words import num2words #https://github.com/savoirfairelinux/num2words
- import os
- from gtts import gTTS #https://pythonprogramminglanguage.com/text-to-speech/
- def makeaudio(theword,thenumber):
- tts = gTTS(text=theword, lang='es')
- filename = "{}.mp3".format(thenumber)
- tts.save(filename)
- os.system("mpg321 {}.mp3".format(thenumber))
- return filename
- def createnumbers(range_low,range_high):
- output = []
- tick = 0
- while tick <endat:
- tick += 1
- spanishword = num2words(tick,lang='es') #Setting this to a var so we can use it for make audio func
- audiofile = makeaudio(spanishword,tick)
- outputdict = {"english" : num2words(tick,lang='en'),
- "spanish" : spanishword,
- "audiofile" : audiofile
- }
- output.append(outputdict)
- return output
- numberlist = createnumbers(startfrom,endat)
- for number in numberlist:
- if show_words == True:
- print("{},{},{}".format(number["english"],number["spanish"],number["audiofile"]))
- else:
- print("{},{},{}".format(number["english"],"",number["audiofile"]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement