-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
89 lines (60 loc) · 1.87 KB
/
main.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import Parser
import os, time
import playsound
import combine
native = "russian"#select your native language
os.system('cls')
playing = 1
folder_path = os.getcwd()
def commands(word):
global playing
if word == '/m':
playing = 1 - playing
if playing:
print("\033[92mSuccefuly \033[96mturned on")
else:
print("\033[92mSuccefuly \033[96mturned off")
elif word == '/r':
mp3_files = [f for f in os.listdir(folder_path) if f.endswith('.mp3')] # Get all MP3 files in the folder
for mp3_file in mp3_files:
print(f'\033[96m{mp3_file}\033[96m\033[92m was succefuly removed')
os.remove(folder_path + '\\' + mp3_file)
# os.remove(os.path.join(folder_path, mp3_file)) # Remove the MP3 file
print("\033[93mAll MP3 files in the folder have been removed.\033[93m\n")
else:
print("\033[91mOdd command\033[91m")
Start()
return 0
def Start():
global playing
word = input('\033[95mEnter the word you wish to load here: \033[91m').strip()
start = time.time()
for ele in '''!()[]{};:'",<>.?@#$%^&*_~''':
word = word.replace(ele, "")
if(len(word) == 0):
os.system('cls')
Start()
if word[0] == '/':
commands(word)
os.system('cls')
print(word)
save_path = f"{folder_path}/{word}.mp3" #Generating of file name
print("\033[92mDownloading..\033[92m")
Parser.define(word, save_path, 0, 1, 'english')
if os.path.exists(save_path):
if playing:
playsound.playsound(save_path, True)
else:
print("\033[91mSuch word wasn't found\033[91m")
if (combine.comb(word) and playing):
playsound.playsound(save_path, True)
try:
print('\033[94m\033[94m')
Parser.define(word, save_path, 1, 1, f"english-{native}")
except:
pass
print("\n\033[93m{:.2f}".format(time.time() - start) + " sec")
print('\n')
Start()
if __name__ == "__main__":
Start()