-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1093 from elebumm/develop
2.4
- Loading branch information
Showing
24 changed files
with
353 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Import the server module | ||
import http.server | ||
import webbrowser | ||
# Set the hostname | ||
HOST = "localhost" | ||
# Set the port number | ||
PORT = 4000 | ||
|
||
# Define class to display the index page of the web server | ||
class PythonServer(http.server.SimpleHTTPRequestHandler): | ||
def do_GET(self): | ||
if self.path == '/GUI': | ||
self.path = 'index.html' | ||
return http.server.SimpleHTTPRequestHandler.do_GET(self) | ||
|
||
# Declare object of the class | ||
webServer = http.server.HTTPServer((HOST, PORT), PythonServer) | ||
# Print the URL of the webserver, new =2 opens in a new tab | ||
print(f"Server started at http://{HOST}:{PORT}/GUI/") | ||
webbrowser.open(f'http://{HOST}:{PORT}/GUI/', new = 2) | ||
print("Website opened in new tab") | ||
print("Press Ctrl+C to quit") | ||
try: | ||
# Run the web server | ||
webServer.serve_forever() | ||
except KeyboardInterrupt: | ||
# Stop the web server | ||
webServer.server_close() | ||
print("The server is stopped.") | ||
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import random | ||
import pyttsx3 | ||
from utils import settings | ||
|
||
|
||
class pyttsx: | ||
def __init__(self): | ||
self.max_chars = 5000 | ||
self.voices = [] | ||
|
||
def run( | ||
self, | ||
text: str, | ||
filepath: str, | ||
random_voice=False, | ||
): | ||
voice_id = settings.config["settings"]["tts"]["python_voice"] | ||
voice_num = settings.config["settings"]["tts"]["py_voice_num"] | ||
if voice_id == "" or voice_num == "": | ||
voice_id = 2 | ||
voice_num = 3 | ||
raise ValueError( | ||
"set pyttsx values to a valid value, switching to defaults" | ||
) | ||
else: | ||
voice_id = int(voice_id) | ||
voice_num = int(voice_num) | ||
for i in range(voice_num): | ||
self.voices.append(i) | ||
i = +1 | ||
if random_voice: | ||
voice_id = self.randomvoice() | ||
engine = pyttsx3.init() | ||
voices = engine.getProperty("voices") | ||
engine.setProperty( | ||
"voice", voices[voice_id].id | ||
) # changing index changes voices but ony 0 and 1 are working here | ||
engine.save_to_file(text, f"{filepath}") | ||
engine.runAndWait() | ||
|
||
def randomvoice(self): | ||
return random.choice(self.voices) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.