-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPygLatin
49 lines (47 loc) · 1.36 KB
/
PygLatin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
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()