added pyttsx option
This commit is contained in:
1 parent
b81ee722b8
commit
c5fda9d3fe
6 files changed
+72
-2
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import pyttsx3
|
||||
from utils import settings
|
||||
import random
|
||||
|
||||
max_chars = 0
|
||||
|
||||
#Uses the system voices, significantly faster than other tts
|
||||
|
||||
class pyttsx:
|
||||
|
||||
def __init__(self):
|
||||
self.max_chars = 0
|
||||
self.voices = []
|
||||
|
||||
def run(
|
||||
self,
|
||||
text: str = "Python Text to Speech",
|
||||
filepath: str = "assets/temp/mp3",
|
||||
random_voice=False,
|
||||
censor=False,
|
||||
):
|
||||
voice_id = int(settings.config["settings"]["tts"]["python_voice"])
|
||||
voice_num = int(settings.config["settings"]["tts"]["python_voice_number"])
|
||||
for i in range(voice_num):
|
||||
self.voices.append(i)
|
||||
i=+1
|
||||
if random_voice:
|
||||
voice_id = self.randomvoice()
|
||||
else:
|
||||
voice = voice_id
|
||||
engine = pyttsx3.init()
|
||||
voices = engine.getProperty('voices')
|
||||
engine.setProperty('voice', voices[voice].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,9 @@
|
||||
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()
|
||||
@@ -31,7 +31,9 @@ background_choice = { optional = true, default = "minecraft", example = "rocket-
|
||||
|
||||
|
||||
[settings.tts]
|
||||
voice_choice = { optional = false, default = "", options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", ], example = "tiktok", explanation = "The voice platform used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
|
||||
voice_choice = { optional = false, default = "", options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx"], example = "tiktok", explanation = "The voice platform used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
|
||||
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" }
|
||||
streamlabs_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for Streamlabs Polly" }
|
||||
tiktok_voice = { optional = false, default = "en_us_006", example = "en_us_006", explanation = "The voice used for TikTok TTS" }
|
||||
python_voice = {optional = false, default = "1", example = "1", explanation = "The index of the system tts voices (can be downloaded externally, run ptt.py to find value)"}
|
||||
python_voice_number = {optional = false, default = "2", example = "2", explanation= "the number of system voices(2 are pre-installed in windows)"}
|
||||
@@ -1 +1,18 @@
|
||||
[]
|
||||
[
|
||||
{
|
||||
"subreddit": "tifu",
|
||||
"id": "w97htn",
|
||||
"time": "1658942748",
|
||||
"background_credit": "Achy Gaming",
|
||||
"reddit_title": "TIFU by refusing to give tea to a Chinese senator",
|
||||
"filename": "TIFU by refusing to give tea to a Chinese senator.mp4"
|
||||
},
|
||||
{
|
||||
"subreddit": "tifu",
|
||||
"id": "w9iqby",
|
||||
"time": "1658945240",
|
||||
"background_credit": "Achy Gaming",
|
||||
"reddit_title": "TIFU by giving my boss a RedBull",
|
||||
"filename": "TIFU by giving my boss a RedBull.mp4"
|
||||
}
|
||||
]
|
||||
@@ -1,3 +1,4 @@
|
||||
from distutils.command.config import config
|
||||
import json
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
from typing import Dict, Tuple
|
||||
|
||||
from rich.console import Console
|
||||
from TTS import pyttsx
|
||||
|
||||
from TTS.engine_wrapper import TTSEngine
|
||||
from TTS.GTTS import GTTS
|
||||
from TTS.streamlabs_polly import StreamlabsPolly
|
||||
from TTS.aws_polly import AWSPolly
|
||||
from TTS.TikTok import TikTok
|
||||
from TTS.pyttsx import pyttsx
|
||||
from utils import settings
|
||||
from utils.console import print_table, print_step
|
||||
|
||||
@@ -20,6 +22,7 @@ TTSProviders = {
|
||||
"AWSPolly": AWSPolly,
|
||||
"StreamlabsPolly": StreamlabsPolly,
|
||||
"TikTok": TikTok,
|
||||
"pyttsx" : pyttsx,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user