Skip to main content

Text to Speech Program

This package provides a text-to-speech server, using gtts and pydub, and a client program to interact with the server.

[!WARNING] Tested only on Python 3.10–3.12. Newer versions may break due to audio dependencies (pydub / audioop stack).

1. Installing

1.1. Install the package from PyPi

To install the package from pypi, follow the instructions below:

With pip

pip install --upgrade text-to-speech-program

Execute which tts-program-server to see where it was installed, probably in /home/USERNAME/.local/bin/tts-program-server.

With pipx (recommended for desktop applications)

pipx install text-to-speech-program

[!IMPORTANT] To install with python 3.12 use: pipx install --python /path/to/venvs/python3.12/bin/python3.12 text-to-speech-program

If you need to upgrade later: pipx upgrade text-to-speech-program

1.2. Install the package from pip and add to the Linux service

pip install --upgrade text-to-speech-program
curl -fsSL https://raw.githubusercontent.com/trucomanx-voice/text_to_speech_program/main/install_linux_service.sh | sh

After the last code, the program server starts at with the operating system. Now the next commands are accepted (Use them if necessary).

1.2.1. Start server service in linux

You only need to start the server if it has been stopped or is disabled from starting with Linux boot.

sudo systemctl start tts-program-server

1.2.2. Stop server service in linux

sudo systemctl stop tts-program-server

1.2.3. Disable service at linux startup

sudo systemctl disable tts-program-server

1.2.4. Show journal of service

journalctl -u tts-program-server -f

2. Using

2.1. Start the server

You only need to start the server if it has been stopped. If the program server was not added to the Linux service, then to start the text-to-speech server, use the command below:

tts-program-server

This starts a server that will listen, by default, on http://127.0.0.1:5000 and will be ready to receive text conversion requests. To modify these values see tts-program-server config.

2.2. Start the client

The client can submit conversion text-to-speech tasks or remove pending jobs from the server.

2.2.1. Sending a JSON file:

Adding a text-to-speech task.

tts-program-client send /caminho/para/arquivo.json

JSON file example:

{
    "text": "Some text to convert.\n\n OK",
    "language": "en",
    "split_pattern": [".", "\n\n", "\n\r\n"],
    "speed":1.25
}

2.2.2. Sending a DICT from string:

Adding a text-to-speech task.

tts-program-client senddict '{ 
    "text": "Some text to convert. OK", 
    "language": "en", 
    "split_pattern": ["."], 
    "speed":1.25 
}'

or if host is localhost and port is 5000. See tts-program-client config to conf the localhost and port.

curl -X POST http://localhost:5000/add_task \
    -H "Content-Type: application/json" \
    -d '{
    "text": "Some text to convert. OK", 
    "language": "en", 
    "split_pattern": ["."], "speed":1.25 
}'

2.2.3. Remove a task from the stack using the ID:

tts-program-client remove <ID>

Replace <ID> with the unique ID returned when adding a task.

2.3. Make a client in Python

import requests

def remove_task(server_url,task_id):
    # Send DELETE request to server
    response = requests.delete(f'{server_url}/remove_task/{task_id}')

    if response.status_code == 200:
        print(response.json()["message"])
        return response.json()["message"]
    else:
        print("Error removing task:",task_id)
        return None

def send_json_from_dict(server_url,data):
    """
    Sends a POST request to the server with a JSON payload.

    Args:
        server_url (str): The base URL of the server.
        data (dict): A dictionary containing the data to be sent as JSON.

    Returns:
        str: The ID of the task if successfully sent, or None if there was an error.
    """
	
    # Send POST request to the server
    response = requests.post(f'{server_url}/add_task', json=data)

    if response.status_code == 200:
        print(f"Task sent successfully! ID: {response.json()['id']}")
        return response.json()['id'];
    else:
        print("Error submitting task.")
        return None;

# Example usage:

SERVER_URL = 'http://localhost:5000'; # If host is localhost and port is 5000

DATA={
    "text": "Some text to convert. OK", 
    "language": "en", 
    "split_pattern": ["."], 
    "speed":1.25 
}


ID=send_json_from_dict(SERVER_URL,DATA);

#msg=remove_task(SERVER_URL,ID);

3. License

This project is licensed under the GPL license. See the LICENSE file for more details.

Metadata

Release files for text-to-speech-program 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for text-to-speech-program 0.1.11
File Size Uploaded Provenance
text_to_speech_program-0.1.11.tar.gz 54.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for text-to-speech-program 0.1.11
File Interpreter ABI Platform
text_to_speech_program-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 106.9 kB

Release files / text_to_speech_program-0.1.11.tar.gz

Download URL text_to_speech_program-0.1.11.tar.gz
Size 54.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2dd97a9be0c539aafcc8defc419c9afef68069a521740ce07665af3becf35735
BLAKE2b-256 checksum
How to use checksums
27fdd7d507b2ac50d4aaadaab5251288f7f8ccb40ae15db4f326ad1a64622b99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / text_to_speech_program-0.1.11-py3-none-any.whl

Download URL text_to_speech_program-0.1.11-py3-none-any.whl
Size 52.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42d4182437770a87e5e1daedb35bbfbe824832bb0432e5aab69b1b76db84171e
BLAKE2b-256 checksum
How to use checksums
ce79a0a8f1c1e17a7514fdeb9d90ec695dfcdd8f36557951f99d297d19010b25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for text-to-speech-program 0.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page