commit
95e980932c
@ -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()
|
@ -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)
|
@ -0,0 +1,10 @@
|
||||
import pyttsx3
|
||||
|
||||
engine = pyttsx3.init()
|
||||
voices = engine.getProperty("voices")
|
||||
for voice in voices:
|
||||
print(voice, voice.id)
|
||||
engine.setProperty("voice", voice.id)
|
||||
engine.say("Hello World!")
|
||||
engine.runAndWait()
|
||||
engine.stop()
|
@ -0,0 +1,11 @@
|
||||
import requests
|
||||
from utils.console import print_step
|
||||
|
||||
def checkversion(__VERSION__):
|
||||
response = requests.get("https://api.github.com/repos/elebumm/RedditVideoMakerBot/releases/latest")
|
||||
latestversion = (response.json()["tag_name"])
|
||||
if __VERSION__ == latestversion:
|
||||
print_step(f"You are using the newest version ({__VERSION__}) of the bot")
|
||||
return True
|
||||
else:
|
||||
print_step(f"You are using an older version ({__VERSION__}) of the bot. Download the newest version ({latestversion}) from https://github.com/elebumm/RedditVideoMakerBot/releases/latest")
|
@ -1 +1 @@
|
||||
[]
|
||||
[]
|
Loading…
Reference in new issue