
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
python-text-to-speech
Advanced tools
This project leverages pyttsx3
for microsoft's built-in text-to-speech feature. It's designed for simplicity and ease of use, allowing you to configure continuous text-to-speech functionality and optional English translation.
pyttsx3
Install dependencies:
pip install pyttsx3
Create Configuration Files:
input_sentence_file.txt
: This file will contain the sentences that need to be spoken.stop_or_not_file.txt
: This file will control whether the text-to-speech function continues to check the input text file for new sentences. It should contain either "A" or "B".
To use the text-to-speech functionality, import the Speaker
class from python-text-to-speech
and initialize it with the appropriate parameters.
from python-text-to-speech import Speaker
ai = Speaker(
input_file_path="input_sentence_file.txt",
stop_file_path="stop_or_not_file.txt",
log_file="TTS.log"
translate=True | False,
speak_continous=True | False
)
ai.add_more_voice("/temporary_directory_for_working", "voice_install_log_file.log") # Initialize all the voices avaliable in system
voices_list = ai.populate_voices() # to get list of available voices in your system
ai.set_voice(voice_name) # voice name should be the exact name of voice provided in vlices_list
ai.speak() # to speak sentences
input_file_path
(str): Path to the file containing sentences to be spoken.stop_file_path
(str): Path to the file that controls whether to stop or continue.log_file
(str): Path to a log file where all the logs will be stored.translate
(bool): Set to True to translate the text to English before speaking, False otherwise.speak_continous
(bool): Set to True for continuous text-to-speech, False for single execution.If you want the text-to-speech functionality to run continuously, it is recommended to use threading. This will prevent the function from blocking the execution of further code until it is stopped.
Example with Threading
import threading
from python-text-to-speech import Speaker
def tts_thread():
ai = Speaker(
input_file_path="input_sentence_file.txt",
stop_file_path="stop_or_not_file.txt",
translate=True,
speak_continous=True
)
ai.speak()
# Start TTS in a separate thread
thread = threading.Thread(target=tts_thread)
thread.start()
thread.join()
To make the program speak, update the sentence in input_sentence_file.txt. To stop the function, change the value in stop_or_not_file.txt from "A" to "B".
Time & language => Speech => Add voices
and download the language whose voice you need to use.System_Voices_Manager
from python-text-to-speech.Register
and follow the codefrom python-text-to-speech.Register import System_Voices_Manager
import os
if __name__ == "__main__":
sys = System_Voices_Manager("voice_install_log_file.log")
sys.install_all_voices(os.path.join(os.getcwd(), "export"))
This project is managed by Artex AI. Soon an improved and stable version will roll out
FAQs
A python text to speech library
We found that python-text-to-speech demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.