Skip to content

Instantly share code, notes, and snippets.

@xeon-zolt
Last active January 14, 2017 10:14
Show Gist options
  • Save xeon-zolt/17197577fe2f0f649312c5880558ef15 to your computer and use it in GitHub Desktop.
Save xeon-zolt/17197577fe2f0f649312c5880558ef15 to your computer and use it in GitHub Desktop.
a pyglatin translator made for unfpy
'''
ascii pig
(\____/)
/ @__@ \
( (oo) )
`-.~~.-'
/ \
@/ \_
(/ / \ \)
WW`----'WW
should i make a pig say
'''
from gtts import gTTS #to install gtts write -- > sudo pip install gtts
import os #required for mpg123 to install mpg123 write --> pacman -S mpg123
print ('Welcome to the Pig Latin Translator!')
pyg = 'py'
# speak tts
tts = gTTS(text="enter a word to translate to piglatin", lang='en-us')
tts.save("pcvoice.mp3")
os.system("mpg123 -q pcvoice.mp3")
# tts over
def original():
original= input(str("enter a Word: "))
if len(original) > 0 and original.isalpha():
print(original)
# speak the original word first
tts = gTTS(text="the original input is " + original, lang='en-us')
tts.save("pcvoice.mp3")
os.system("mpg123 -q pcvoice.mp3")
# tts over
word = original.lower()
first = word[0]
new_word = word+first+pyg
new_word = new_word[1:len(new_word)]
print (new_word)
# speak pyglatin
tts = gTTS(text=" piglatin translation is " + new_word, lang='en-us')
tts.save("pcvoice.mp3")
os.system("mpg123 -q pcvoice.mp3")
# tts over
elif len(original) > 0 and not original.isalpha():
print ("only alpha characters accepted")
orig()
else:
print("empty")
orig()
original()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment