Skip to main content

A hassle-free Python library that allows one to use text-to-speech APIs with the same interface

Project description

TTS-Wrapper

TTS-Wrapper is a hassle-free Python library that allows one to use text-to-speech APIs with the same interface.

Currently the following services are supported:

  • AWS Polly
  • Google TTS
  • Microsoft TTS

Installation

Install using pip.

pip install TTS-Wrapper

Usage

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

from tts_wrapper import PollyTTS

tts = PollyTTS()
tts.synth('Hello, world!', 'hello.wav')

Selecting a Voice

You can change the default voice by specifying the voice name and the language code:

tts = PollyTTS(voice_name='Camila', lang='pt-BR')

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

SSML

You can also use SSML markup to control the output, like so:

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

You don't need to wrap it with the <speak></speak> tag as it is automatically used with the required parameters for each TTS service.

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

Credentials

You need to setup credentials to access each service.

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:

from tts_wrapper import PollyTTS, AwsCredentials

tts = PollyTTS(creds=AwsCredentials('AWS_KEY_ID', 'AWS_ACCESS_KEY'))

Google

Point to your Oauth 2.0 credentials file path:

from tts_wrapper import GoogleTTS

tts = GoogleTTS(creds='path/to/creds.json')

Microsoft

Just provide your subscription key, like so:

from tts_wrapper import MicrosoftTTS

tts = MicrosoftTTS(creds='TOKEN')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for TTS-Wrapper, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size TTS_Wrapper-0.2-py3-none-any.whl (6.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page