{"id":24347690,"url":"https://github.com/ziligy/watson-text-talker","last_synced_at":"2025-04-09T19:16:31.559Z","repository":{"id":62588268,"uuid":"143080754","full_name":"ziligy/watson-text-talker","owner":"ziligy","description":"Simple python Text-to-Speech Interface using IBM's Watson TTS","archived":false,"fork":false,"pushed_at":"2019-10-22T22:34:01.000Z","size":14,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T19:16:23.978Z","etag":null,"topics":["bot","home-automation","pip","python","raspberry-pi","text-to-speech","voice","watson"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziligy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-31T23:38:29.000Z","updated_at":"2022-01-18T02:52:26.000Z","dependencies_parsed_at":"2022-11-04T07:46:30.409Z","dependency_job_id":null,"html_url":"https://github.com/ziligy/watson-text-talker","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziligy%2Fwatson-text-talker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziligy%2Fwatson-text-talker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziligy%2Fwatson-text-talker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziligy%2Fwatson-text-talker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziligy","download_url":"https://codeload.github.com/ziligy/watson-text-talker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094988,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","home-automation","pip","python","raspberry-pi","text-to-speech","voice","watson"],"created_at":"2025-01-18T11:19:32.629Z","updated_at":"2025-04-09T19:16:31.539Z","avatar_url":"https://github.com/ziligy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# watson-text-talker\n\n### About\nI 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 \u0026 sound-output-capable devices.\n\n### Installation\n\n    pip3 install watson-text-talker --user\n\n### Get [IBM credentials](https://console.bluemix.net/catalog/services/text-to-speech) for Watson Text-To-Speech, Lite Plan is *FREE*\n\n### Simple Use\n\n```python\nfrom watson_text_talker import *\n\ntext_talker = TextTalker(api_key='your-watson-tts-api-key')\n\ntext_talker.say(\"Hello world!\")\n```\n\n### Features\n\n* #### Voice file cacheing\n    - lowers cloud round-trips\n    - keeps cost down\n* #### Phrase grouping\n    - segments phrases/sentences\n    - each segment can have it's own importance factor\n* #### Importance factors\n    - optional percentage chance that a phrase will be voiced\n* #### Quiet level\n    - optional quiet level factor can be applied to all optional phrases\n    - increases or decreases the likelihood that an optional phrase will be voiced\n* #### Uses high-quality Waston voices\n    - very realistic sounding, with appropriate cadence and intonation\n    - voice selection: [see here for selection available](https://www.ibm.com/watson/developercloud/text-to-speech/api/v1/curl.html?curl#get-voice)\n    - free tier plan: no credit card required, 10,000 characters per month at no cost\n\n### Voice file cacheing\nThe 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.\n\n### Phrase grouping\nPhrase grouping is based on array of tuples.\n\n```python\n    from watson_text_talker import *\n\n    text_talker = TextTalker(api_key='your-api-key')\n\n    importance = TT_Importance()\n\n    grouping_example = [(importance.SAY_30_PERCENT, \"I'm your assistant.\"), (importance.SAY_50_PERCENT, \"How are you?\"), (importance.SAY_ALWAYS, \"Nice to meet you\") ]\n\n    text_talker.say_group(grouping_example)\n```\n\nTuples are made up of the importance \u0026 the text phrase.\n\n### Importance factors\n```python\n# TT_Importance is a class of numeric constants\n    SAY_ALWAYS = 1\n    SAY_90_PERCENT = 2\n    SAY_80_PERCENT = 3\n    SAY_70_PERCENT = 4\n    SAY_60_PERCENT = 5\n    SAY_50_PERCENT = 6\n    SAY_40_PERCENT = 7\n    SAY_30_PERCENT = 8\n    SAY_20_PERCENT = 9\n    SAY_10_PERCENT = 10\n    SAY_NEVER = 11\n```\n\nFor the same as above we could have just as easily said:\n```python\n    from watson_text_talker import *\n\n    text_talker = TextTalker(api_key='your_api_key')\n\n    grouping_example = [(8, \"I'm your assistant.\"), (6, \"How are you?\"), (1, \"Nice to meet you\") ]\n\n    text_talker.say_group(grouping_example)\n```\n\n### Quiet level\nThe package includes a globally applied `quite level` that increases or decreases the likelihood that an optional phrase will be voiced.\n\n```python\n    from watson_text_talker import *\n\n    text_talker = TextTalker(api_key='your_api_key')\n\n    importance = TT_Importance()\n\n    grouping_example = [(importance.SAY_30_PERCENT, \"I'm your assistant.\"), (importance.SAY_ALWAYS, \"Nice to meet you\") ]\n\n    text_talker.quiet_level = +2\n\n    text_talker.say_group(grouping_example)\n```\n\nIn 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.\n\n### Config\nuse the TT_Config class to override configuration defaults\n\n```python\n# TT_Config's standard defaults\n\n    API_KEY='--watson tts credentials api-key goes here--'\n    \n    # TTS API URL  \n    API_URL='https://gateway-lon.watsonplatform.net/text-to-speech/api'\n\n    TTS_VOICE = 'en-US_AllisonVoice'\n    TTS_ACCEPT = 'audio/mp3'\n\n    CACHE_DIRECTORY = 'voice_mp3s'\n\n    # when True cache direcory will be relative to the current working directory\n    # if False then cache directory should be fully pathed\n    CACHE_DIRECTORY_IS_RELATIVE = True\n\n    VOICE_FILE_EXTENSION = 'mp3'\n\n    # some environments may require a delay if first speech is cut off\n    # generally 1, 2 or 3 seconds will work\n    INITIALIZATION_DELAY = 0\n```\n\nUse it like so:\n```python\n    from watson_text_talker import *\n\n    config = TT_Config()\n    config.API_KEY='your watson tts api-key'\n    config.API_URL='if you need to update API URL, update this'\n    config.TTS_Voice = 'en-US_MichaelVoice'\n    congig.CACHE_DIRECTORY = 'custom_cache'\n    congig.INITIALIZATION_DELAY = 1\n\n    text_talker = TextTalker(config=config)\n\n    text_talker.say(\"Hello world!\")\n```\n\n### Attributions\n\n* [pygame](https://github.com/pygame/pygame) is used to process the mp3 voice files\n* [python-slugify](https://github.com/un33k/python-slugify) is used to create cache file names\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziligy%2Fwatson-text-talker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziligy%2Fwatson-text-talker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziligy%2Fwatson-text-talker/lists"}