watson-text-talker
About
I created this interface for a voice-based-bot that I'm running on a Raspberry Pi 3B. I'm using the AIY Voice HAT, but I was very displeased with the robotic-voice that's supplied by Google. After studying a few other voice options I decided on IBM's Watson because of it's high quality cadence and intonation. I added some features for my purposes and decided others may find some benefit in my effort. The package should work in other internet-connected & sound-output-capable devices.
Installation
pip3 install watson-text-talker --user
Get IBM credentials for Watson Text-To-Speech, Lite Plan is FREE
Simple Use
from watson_text_talker import *
text_talker = TextTalker(username='your-watson-tts-credentials-username', password='your-watson-tts-credentials-password')
text_talker.say("Hello world!")
Features
-
Voice file cacheing
- lowers cloud round-trips
- keeps cost down
-
Phrase grouping
- segments phrases/sentences
- each segment can have it's own importance factor
-
Importance factors
- optional percentage chance that a phrase will be voiced
-
Quiet level
- optional quiet level factor can be applied to all optional phrases
- increases or decreases the likelihood that an optional phrase will be voiced
-
Uses high-quality Waston voices
- very realistic sounding, with appropriate cadence and intonation
- voice selection: see here for selection available
- free tier plan: no credit card required, 10,000 characters per month at no cost
Voice file cacheing
The package always caches new phrases to a file. The cache directory defaults to ./voice_mp3s, but can also be defined in TT_Config. To regulate the filename I slugify the phrase. This has the advantage of making it human readable. The only caveat is the phrase MUST be limited to 255 characters.
Phrase grouping
Phrase grouping is based on array of tuples.
from watson_text_talker import *
text_talker = TextTalker(username='credentials-username', password='credentials-password')
importance = TT_Importance()
grouping_example = [(importance.SAY_30_PERCENT, "I'm your assistant."), (importance.SAY_50_PERCENT, "How are you?"), (importance.SAY_ALWAYS, "Nice to meet you") ]
text_talker.say_group(grouping_example)
Tuples are made up of the importance & the text phrase.
Importance factors
# TT_Importance is a class of numeric constants
SAY_ALWAYS = 1
SAY_90_PERCENT = 2
SAY_80_PERCENT = 3
SAY_70_PERCENT = 4
SAY_60_PERCENT = 5
SAY_50_PERCENT = 6
SAY_40_PERCENT = 7
SAY_30_PERCENT = 8
SAY_20_PERCENT = 9
SAY_10_PERCENT = 10
SAY_NEVER = 11
For the same as above we could have just as easily said:
from watson_text_talker import *
text_talker = TextTalker(username='credentials-username', password='credentials-password')
grouping_example = [(8, "I'm your assistant."), (6, "How are you?"), (1, "Nice to meet you") ]
text_talker.say_group(grouping_example)
Quiet level
The package includes a globally applied quite level that increases or decreases the likelihood that an optional phrase will be voiced.
from watson_text_talker import *
text_talker = TextTalker(username='credentials-username', password='credentials-password')
importance = TT_Importance()
grouping_example = [(importance.SAY_30_PERCENT, "I'm your assistant."), (importance.SAY_ALWAYS, "Nice to meet you") ]
text_talker.quiet_level = +2
text_talker.say_group(grouping_example)
In the above example the I'm your assistant phrase will only be said 10% of the time because of the +2 assigned to quiet level. The Nice to meet you is not effected.
Config
use the TT_Config class to override configuration defaults
# TT_Config's standard defaults
USERNAME='--watson tts credentials username goes here--'
PASSWORD='--watson tts credentials password goes here--'
TTS_VOICE = 'en-US_AllisonVoice'
TTS_ACCEPT = 'audio/mp3'
CACHE_DIRECTORY = 'voice_mp3s'
CACHE_DIRECTORY_IS_RELATIVE = True
VOICE_FILE_EXTENSION = 'mp3'
Use it like so:
from watson_text_talker import *
config = TT_Config()
config.CREDENTIALS_USERNAME='your watson credentials'
config.CREDENTIALS_PASSWORD='your watson password'
config.TTS_Voice = 'en-US_MichaelVoice'
congig.CACHE_DIRECTORY = 'custom_cache'
text_talker = TextTalker(config=config)
text_talker.say("Hello world!")
Attributions
- pygame is used to process the mp3 voice files
- python-slugify is used to create cache file names
Metadata
Release files for watson-text-talker 0.8.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| watson_text_talker-0.8.10.tar.gz | 4.9 kB | Without provenance | Details for watson_text_talker-0.8.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| watson_text_talker-0.8.10-py3-none-any.whl | Python 3 | none | any | Details for watson_text_talker-0.8.10-py3-none-any.whl |
Total release size: 10.3 kB
Release files / watson_text_talker-0.8.10.tar.gz
| Download URL | watson_text_talker-0.8.10.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cdcd1c531b3e3d6b0380e430120094352e9a5dd0f47b0a6bc9804df86d8a2757
|
|
BLAKE2b-256 checksum How to use checksums |
593b3c0ad1c9cdc41a905456aa87e6feeed14021183198aa92a8ba8e625fdedb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|
Release files / watson_text_talker-0.8.10-py3-none-any.whl
| Download URL | watson_text_talker-0.8.10-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb0eb23c61609f3a249b5697721ef1928f62ba042d9c9dc45cd4576dae85245c
|
|
BLAKE2b-256 checksum How to use checksums |
bfe7d8e960daa4cc08f80b33084b5e18f59656db63e25b21fe217dd31c02b95b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|
Security for watson-text-talker 0.8.10
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.