Skip to main content

TTS-Wrapper

PyPI version build codecov Maintainability

Contributions are welcome! Check our contribution guide.

TTS-Wrapper makes it easier to use text-to-speech APIs by providing a unified and easy-to-use interface.

Currently the following services are supported:

  • AWS Polly
  • Google TTS
  • Microsoft TTS
  • IBM Watson
  • PicoTTS
  • SAPI (Microsoft Speech API)

Installation

Install using pip.

pip install TTS-Wrapper

Note: for each service you want to use, you have to install the required packages.

Example: to use google and watson:

pip install TTS-Wrapper[google, watson]

For PicoTTS you need to install the package on your machine. For Debian (Ubuntu and others) install the package libttspico-utils and for Arch (Manjaro and others) there is a package called aur/pico-tts.

Usage

Simply instantiate an object from the desired service and call synth().

from tts_wrapper import PollyTTS, PollyClient

tts = PollyTTS(client=PollyClient())
tts.synth('<speak>Hello, world!</speak>', 'hello.wav')

Notice that you must create a client object to work with your service. Each service uses different authorization techniques. Check out the documentation to learn more.

Selecting a Voice

You can change the default voice and lang like this:

PollyTTS(voice='Camila', lang='pt-BR')

Check out the list of available voices for Polly, Google, Microsoft, and Watson.

SSML

You can also use SSML markup to control the output of compatible engines.

tts.synth('<speak>Hello, <break time="3s"/> world!</speak>', 'hello.wav')

It is recommended to use the ssml attribute that will create the correct boilerplate tags for each engine:

tts.synth(tts.ssml.add('Hello, <break time="3s"/> world!'), 'hello.wav')

Learn which tags are available for each service: Polly, Google, Microsoft, and Watson.

Authorization

To setup credentials to access each engine, create the respective client.

Polly

If you don't explicitly define credentials, boto3 will try to find them in your system's credentials file or your environment variables. However, you can specify them with a tuple:

from tts_wrapper import PollyClient
client = PollyClient(credentials=(region, aws_key_id, aws_access_key))

Google

Point to your Oauth 2.0 credentials file path:

from tts_wrapper import GoogleClient
client = GoogleClient(credentials='path/to/creds.json')

Microsoft

Just provide your subscription key, like so:

from tts_wrapper import MicrosoftClient
client = MicrosoftClient(credentials='TOKEN')

If your region is not the default "useast", you can change it like so:

client = MicrosoftClient(credentials='TOKEN', region='brazilsouth')

Watson

Pass your API key and URL to the initializer:

from tts_wrapper import WatsonClient
client = WatsonClient(credentials=('API_KEY', 'API_URL'))

PicoTTS & SAPI

These clients dont't require authorization since they run offline.

from tts_wrapper import PicoClient, SAPIClient
client = PicoClient()
# or
client = SAPIClient()

File Format

By default, all audio will be a wave file but you can change it to a mp3 using the format option:

tts.synth('<speak>Hello, world!</speak>', 'hello.mp3', format='mp3)

License

Licensed under the MIT License.

Release files for tts-wrapper 0.8.0

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

Source distribution (sdist)

Source distribution for tts-wrapper 0.8.0
File Size Uploaded
tts-wrapper-0.8.0.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tts-wrapper 0.8.0
File Interpreter ABI Platform
tts_wrapper-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / tts-wrapper-0.8.0.tar.gz

Download URL tts-wrapper-0.8.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8af81140612bc9ed051208e387b4ece4c48f50bc973c51f2e0b56c48c1036c54
BLAKE2b-256 checksum
How to use checksums
957f340654592a8f40e33ec4833adcb6f335d5054743bc30de9dd12ca580db65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.5 Linux/5.15.55-1-MANJARO

Release files / tts_wrapper-0.8.0-py3-none-any.whl

Download URL tts_wrapper-0.8.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68f8c23b49d5afeef31adaa071e7009cc877e8095d8a2d6965d66cf05b6ad088
BLAKE2b-256 checksum
How to use checksums
6d42ad23d2c1b2a38271d3d053e835b99bb2f7d1e5c358c9c2099906984a9fb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.5 Linux/5.15.55-1-MANJARO

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

1 release file

0.5.0

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

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