-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwindows.py
184 lines (155 loc) · 7.23 KB
/
windows.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import pyttsx3
from colorama import Fore, Style, init, Back
import os
from datetime import datetime
# Initialize colorama
init()
clear_line = "\033[F\033[K" # Escape codes for clearing one line
def save_to_history(text):
# Get current date
current_date = datetime.now().strftime("%Y-%m-%d")
# Create history folder if it doesn't exist
history_folder = "history"
os.makedirs(history_folder, exist_ok=True)
# Create subfolder for current date if it doesn't exist
date_folder = os.path.join(history_folder, current_date)
os.makedirs(date_folder, exist_ok=True)
# Create markdown file for current date if it doesn't exist
markdown_file = os.path.join(date_folder, "history.md")
# Write text to markdown file with a timestamp
with open(markdown_file, "a") as file:
file.write(f"\n\n---\n\n{datetime.now().strftime('%H:%M:%S')}\n{text}\n")
# Now, you can use clear_line in a print statement and multiply it as needed
# print(clear_line * 2) # This will clear two lines
# print(clear_line * 3) # This will clear three lines
def select_voice():
print(f"\n{Fore.GREEN}\n\n\nSelect a voice:")
print(f"{Fore.MAGENTA}[1]{Style.RESET_ALL} - Male")
print(f"{Fore.MAGENTA}[2]{Style.RESET_ALL} - Female")
choice = input(f"{Fore.GREEN}\nEnter your choice (1 or 2):{Style.RESET_ALL} ")
if choice == '1':
print(clear_line * 1000)
header()
print("\n"*2) # line breaks for alighnment
elif choice == '2':
print(clear_line * 1000)
header()
print("\n"*2) # line breaks for alighnment
elif choice not in ['1', '2']:
print(clear_line * 1000)
header()
print(f"{Fore.YELLOW}\n\n\tWell, well, well... Are you trying to hack into my system, huh? 🤔\n\tUsing the default voice instead.\n{Style.RESET_ALL}")
return '1' # Use default male voice if invalid choice is entered
return choice
def select_speed():
print(f"{Fore.GREEN}Select speech speed:")
print(f"{Fore.MAGENTA}[1]{Style.RESET_ALL} - Slow")
print(f"{Fore.MAGENTA}[2]{Style.RESET_ALL} - Medium (Default)")
print(f"{Fore.MAGENTA}[3]{Style.RESET_ALL} - Fast")
speed_choice = input(f"{Fore.GREEN}\nEnter your choice (1, 2, or 3):{Style.RESET_ALL} ")
if speed_choice == "1":
print(clear_line * 1000) #terminal clear
header()
print("\n"*2) # line breaks for alignment
return 130 # Slow
elif speed_choice == "2":
print(clear_line * 1000) #terminal clear
header()
print("\n"*2) # line breaks for alignment
return 170 # Medium
elif speed_choice == "3":
print(clear_line * 1000) #terminal clear
header()
print("\n"*2) # line breaks for alignment
return 207 # Fast
else:
print(clear_line * 1000) #terminal clear
header()
print(f"{Fore.YELLOW}\n\n\tUh-oh! Default speed (Medium) will be selected.{Style.RESET_ALL}")
return 170 # Medium (Default)
def save_audio(output_file, text, voice):
# Create the output folder if it doesn't exist
audio_folder = "Audios"
if not os.path.exists(audio_folder):
os.makedirs(audio_folder)
# Initialize pyttsx3 engine
engine = pyttsx3.init()
# Set the voice for the engine
engine.setProperty('voice', voice)
# Define the full path to the output file within the audio folder
full_output_path = os.path.join(audio_folder, output_file)
# Save the speech as an audio file
engine.save_to_file(text, full_output_path)
# Wait for the speech to be saved
engine.runAndWait()
def header():
# Print the logo
logo = r"""
__________ ___.
\______ \ ____\_ |__ ____
| _// _ \| __ \ / _ \
| | ( <_> ) \_\ ( <_> )
|____|_ /\____/|___ /\____/
\/ \/ __
____________ ____ _____ | | __ ___________
/ ___/\____ \_/ __ \\__ \ | |/ // __ \_ __ \
\___ \ | |_> > ___/ / __ \| <\ ___/| | \/
/____ >| __/ \___ >____ /__|_ \\___ >__| 101
\/ |__| \/ \/ \/ \/ windows v3.0
"""
print(f"{Fore.MAGENTA}{logo}{Style.RESET_ALL}")
print(f"{Fore.RED}\n\t\t█▒▓░⡷⠂ DEVELOPED BY FADED ⠐⢾░▒▓█{Style.RESET_ALL}")
print(f"{Fore.LIGHTWHITE_EX}\n\t\t🏴 彡 https://t.me/cyberhood 彡 🏴 {Style.RESET_ALL}")
print(f"{Back.RED}\n\t ★ 彡 https://github.com/anonfaded/robospeaker101 彡 ★ {Style.RESET_ALL}")
def robospeaker():
while True:
header() # Printing header part
choice = select_voice()
speed = select_speed()
# Initialize pyttsx3 engine
engine = pyttsx3.init()
# Get all available voices
voices = engine.getProperty('voices')
# Set the voice based on user's choice
if choice == "1":
engine.setProperty('voice', voices[0].id) # Select male voice
elif choice == "2":
engine.setProperty('voice', voices[1].id) # Select female voice
while True:
user_input = input(f"{Fore.GREEN}\nEnter What you want me to speak: {Fore.LIGHTBLACK_EX}(Enter q to quit or 0 for the main menu.){Fore.MAGENTA}\n>>> {Style.RESET_ALL}")
if user_input.strip() == "q":
print(f"\n\t{Fore.MAGENTA}<<< {Fore.YELLOW}Bye {Fore.MAGENTA}>>>\n{Style.RESET_ALL}")
engine.say("Goodbye")
engine.runAndWait()
return
elif user_input.strip() == "0":
print(clear_line * 1000)
break # Restat the tool
elif not user_input.strip(): # Check if user input is empty
print(clear_line * 1000)
header()
print(f"{Fore.RED}\n\n\t\tPlease enter something to speak.{Style.RESET_ALL}")
continue
else:
# If user input is not empty, save to history and continue loop
save_to_history(user_input)
engine.setProperty('rate', speed) # Adjust the rate of speech
engine.say(user_input.strip())
engine.runAndWait()
# Prompt user to save the speech
save_choice = input(f"{Fore.CYAN}\nDo you want to save this speech? {Fore.YELLOW}(y/n){Style.RESET_ALL}: ")
# print(clear_line * 7)
if save_choice.lower() == "y":
print(clear_line * 1000)
header()
output_file = input(f"{Fore.CYAN}\n\n\n\nEnter the name of the output file {Fore.YELLOW}(e.g., speech.wav){Style.RESET_ALL}: ")
save_audio(output_file, user_input.strip(), choice)
print(clear_line * 1000)
header()
print(f"{Fore.MAGENTA}\n\n\t<<< {Fore.GREEN}Speech saved in folder: {Fore.YELLOW}Audios{Fore.MAGENTA}{Fore.GREEN}, as {Fore.YELLOW}{output_file} 🎉 {Fore.MAGENTA}>>> {Style.RESET_ALL}")
elif save_choice.lower() != "y":
print(clear_line * 1000)
header()
print("\n"*2)
if __name__ == '__main__':
robospeaker()