# 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.
## 1. Installing
### 1.1. Install the package from pip
To install the package from [pypi](https://pypi.org/project/text-to-speech-program), follow the instructions below:
```bash
pip install text_to_speech_program
```
Execute `which tts-program-server` to see where it was installed, probably in `/home/USERNAME/.local/bin/tts-program-server`.
### 1.2. Install the package from pip and add to the Linux service
```bash
curl -fsSL https://raw.githubusercontent.com/trucomanx/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**.
```bash
sudo systemctl start tts-program-server
```
#### 1.2.2. Stop server service in linux
```bash
sudo systemctl stop tts-program-server
```
#### 1.2.3. Disable service at linux startup
```bash
sudo systemctl disable tts-program-server
```
#### 1.2.4. Show journal of service
```bash
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:
```bash
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.
```bash
tts-program-client send /caminho/para/arquivo.json
```
JSON file example:
```json
{
"text": "Some text to convert.\n\n OK",
"language": "en",
"split_pattern": [".", "\n\n"],
"speed":1.25
}
```
#### 2.2.2. Sending a DICT from string:
Adding a text-to-speech task.
```bash
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.
```bash
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:
```bash
tts-program-client remove <ID>
```
Replace `<ID>` with the unique ID returned when adding a task.
### 2.3. Make a client in Python
```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.
Raw data
{
"_id": null,
"home_page": "https://github.com/trucomanx/text_to_speech_program",
"name": "text-to-speech-program",
"maintainer": "Fernando Pujaico Rivera",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "fernando.pujaico.rivera@gmail.com",
"keywords": "tts, gtts, server",
"author": "Fernando Pujaico Rivera",
"author_email": "fernando.pujaico.rivera@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ad/27/c169a1a10ea2110e233bee3515162e4e5706dd4fe98ae368928ce9ada665/text_to_speech_program-0.1.5.tar.gz",
"platform": null,
"description": "# Text to Speech Program\n\nThis package provides a text-to-speech server, using `gtts` and `pydub`, and a client program to interact with the server.\n\n## 1. Installing\n\n### 1.1. Install the package from pip\n\nTo install the package from [pypi](https://pypi.org/project/text-to-speech-program), follow the instructions below:\n\n\n```bash\npip install text_to_speech_program\n```\n\nExecute `which tts-program-server` to see where it was installed, probably in `/home/USERNAME/.local/bin/tts-program-server`.\n\n\n### 1.2. Install the package from pip and add to the Linux service\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/trucomanx/text_to_speech_program/main/install_linux_service.sh | sh\n```\n\nAfter the last code, the program server starts at with the operating system.\nNow the next commands are accepted (Use them if necessary).\n\n#### 1.2.1. Start server service in linux\n**You only need to start the server if it has been stopped or is disabled from starting with Linux boot**.\n\n```bash\nsudo systemctl start tts-program-server\n```\n\n#### 1.2.2. Stop server service in linux\n\n```bash\nsudo systemctl stop tts-program-server\n```\n\n#### 1.2.3. Disable service at linux startup\n\n```bash\nsudo systemctl disable tts-program-server\n```\n#### 1.2.4. Show journal of service\n\n```bash\njournalctl -u tts-program-server -f\n```\n\n## 2. Using\n\n### 2.1. Start the server\n**You only need to start the server if it has been stopped**.\nIf the program server was not added to the Linux service, then to start the text-to-speech server, use the command below:\n\n```bash\ntts-program-server\n```\n\nThis starts a server that will listen, by default, on `http://127.0.0.1:5000` and will be ready to receive text conversion requests.\nTo modify these values see `tts-program-server config`.\n\n\n### 2.2. Start the client\n\nThe client can submit conversion text-to-speech tasks or remove pending jobs from the server.\n\n#### 2.2.1. Sending a JSON file:\nAdding a text-to-speech task.\n\n```bash\ntts-program-client send /caminho/para/arquivo.json\n```\n\nJSON file example:\n\n```json\n{\n \"text\": \"Some text to convert.\\n\\n OK\",\n \"language\": \"en\",\n \"split_pattern\": [\".\", \"\\n\\n\"],\n \"speed\":1.25\n}\n```\n\n#### 2.2.2. Sending a DICT from string:\nAdding a text-to-speech task.\n\n```bash\ntts-program-client senddict '{ \n \"text\": \"Some text to convert. OK\", \n \"language\": \"en\", \n \"split_pattern\": [\".\"], \n \"speed\":1.25 \n}'\n```\n\nor if host is `localhost` and port is `5000`. See `tts-program-client config` to conf the localhost and port.\n\n```bash\ncurl -X POST http://localhost:5000/add_task \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"text\": \"Some text to convert. OK\", \n \"language\": \"en\", \n \"split_pattern\": [\".\"], \"speed\":1.25 \n}'\n```\n\n#### 2.2.3. Remove a task from the stack using the ID:\n\n```bash\ntts-program-client remove <ID>\n```\n\nReplace `<ID>` with the unique ID returned when adding a task.\n\n### 2.3. Make a client in Python\n\n```python\nimport requests\n\ndef remove_task(server_url,task_id):\n # Send DELETE request to server\n response = requests.delete(f'{server_url}/remove_task/{task_id}')\n\n if response.status_code == 200:\n print(response.json()[\"message\"])\n return response.json()[\"message\"]\n else:\n print(\"Error removing task:\",task_id)\n return None\n\ndef send_json_from_dict(server_url,data):\n \"\"\"\n Sends a POST request to the server with a JSON payload.\n\n Args:\n server_url (str): The base URL of the server.\n data (dict): A dictionary containing the data to be sent as JSON.\n\n Returns:\n str: The ID of the task if successfully sent, or None if there was an error.\n \"\"\"\n\t\n # Send POST request to the server\n response = requests.post(f'{server_url}/add_task', json=data)\n\n if response.status_code == 200:\n print(f\"Task sent successfully! ID: {response.json()['id']}\")\n return response.json()['id'];\n else:\n print(\"Error submitting task.\")\n return None;\n\n# Example usage:\n\nSERVER_URL = 'http://localhost:5000'; # If host is localhost and port is 5000\n\nDATA={\n \"text\": \"Some text to convert. OK\", \n \"language\": \"en\", \n \"split_pattern\": [\".\"], \n \"speed\":1.25 \n}\n\n\nID=send_json_from_dict(SERVER_URL,DATA);\n\n#msg=remove_task(SERVER_URL,ID);\n\n```\n\n\n## 3. License\n\nThis project is licensed under the GPL license. See the `LICENSE` file for more details.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A text-to-speech server and client using gtts and pydub",
"version": "0.1.5",
"project_urls": {
"Bug Reports": "https://github.com/trucomanx/text_to_speech_program/issues",
"Funding": "https://trucomanx.github.io/en/funding.html",
"Homepage": "https://github.com/trucomanx/text_to_speech_program",
"Source": "https://github.com/trucomanx/text_to_speech_program/"
},
"split_keywords": [
"tts",
" gtts",
" server"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f938b9d964289925d1fecbacc4519416e14cf91c08a7b554b1e2e2f99fea7d0f",
"md5": "b1278d777b15595e80e9763fc35bbe12",
"sha256": "c0c9a69d5e103cfab0d79d009519d7ef35c7ef0d9ce341c7be15555c1a88995a"
},
"downloads": -1,
"filename": "text_to_speech_program-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b1278d777b15595e80e9763fc35bbe12",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 51203,
"upload_time": "2024-09-18T04:51:35",
"upload_time_iso_8601": "2024-09-18T04:51:35.429616Z",
"url": "https://files.pythonhosted.org/packages/f9/38/b9d964289925d1fecbacc4519416e14cf91c08a7b554b1e2e2f99fea7d0f/text_to_speech_program-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ad27c169a1a10ea2110e233bee3515162e4e5706dd4fe98ae368928ce9ada665",
"md5": "3378d38fe26639f8c7e68f3880f80e70",
"sha256": "4532bd47ad21da230312423f72ba3ae6578d75ade602633bb7fb9213738c00f4"
},
"downloads": -1,
"filename": "text_to_speech_program-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "3378d38fe26639f8c7e68f3880f80e70",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 53620,
"upload_time": "2024-09-18T04:51:37",
"upload_time_iso_8601": "2024-09-18T04:51:37.782023Z",
"url": "https://files.pythonhosted.org/packages/ad/27/c169a1a10ea2110e233bee3515162e4e5706dd4fe98ae368928ce9ada665/text_to_speech_program-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-18 04:51:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "trucomanx",
"github_project": "text_to_speech_program",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "Flask",
"specs": []
},
{
"name": "gtts",
"specs": []
},
{
"name": "pydub",
"specs": []
},
{
"name": "requests",
"specs": []
}
],
"lcname": "text-to-speech-program"
}