{"id":45325494,"url":"https://github.com/markokosticdev/cloud_text_to_speech_nodejs","last_synced_at":"2026-02-21T08:33:45.049Z","repository":{"id":238113583,"uuid":"795903205","full_name":"markokosticdev/cloud_text_to_speech_nodejs","owner":"markokosticdev","description":"Single interface to Google, Microsoft, and Amazon Text-To-Speech.","archived":false,"fork":false,"pushed_at":"2025-06-23T13:32:30.000Z","size":750,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-17T07:46:38.320Z","etag":null,"topics":["amazon-tts","aws","azure","google-cloud","google-tts","microsoft-tts","text-to-speech","tts","universal-tts"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/cloud-text-to-speech","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markokosticdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"markokosticdev"}},"created_at":"2024-05-04T11:25:36.000Z","updated_at":"2025-02-10T10:26:44.000Z","dependencies_parsed_at":"2024-05-04T12:31:42.876Z","dependency_job_id":"90e407c1-b3a9-4601-8bfa-01ca4bdebd9a","html_url":"https://github.com/markokosticdev/cloud_text_to_speech_nodejs","commit_stats":null,"previous_names":["markokosticdev/cloud_text_to_speech_nodejs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markokosticdev/cloud_text_to_speech_nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markokosticdev%2Fcloud_text_to_speech_nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markokosticdev%2Fcloud_text_to_speech_nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markokosticdev%2Fcloud_text_to_speech_nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markokosticdev%2Fcloud_text_to_speech_nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markokosticdev","download_url":"https://codeload.github.com/markokosticdev/cloud_text_to_speech_nodejs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markokosticdev%2Fcloud_text_to_speech_nodejs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29677535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T06:23:40.028Z","status":"ssl_error","status_checked_at":"2026-02-21T06:23:39.222Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["amazon-tts","aws","azure","google-cloud","google-tts","microsoft-tts","text-to-speech","tts","universal-tts"],"created_at":"2026-02-21T08:33:44.264Z","updated_at":"2026-02-21T08:33:45.043Z","avatar_url":"https://github.com/markokosticdev.png","language":"TypeScript","funding_links":["https://github.com/sponsors/markokosticdev","https://www.buymeacoffee.com/markokostich"],"categories":[],"sub_categories":[],"readme":"# Cloud Text-To-Speech\n\n[![Npm Version](https://img.shields.io/npm/v/cloud-text-to-speech.svg?logo=npm)](https://www.npmjs.com/package/cloud-text-to-speech)\n[![Npm Downloads Total](https://img.shields.io/npm/dt/cloud-text-to-speech.svg?logo=npm)](https://www.npmjs.com/package/cloud-text-to-speech)\n[![Npm Downloads Week](https://img.shields.io/npm/dw/cloud-text-to-speech.svg?logo=npm)](https://www.npmjs.com/package/cloud-text-to-speech)\n[![GitHub License](https://img.shields.io/github/license/markokosticdev/cloud_text_to_speech_nodejs.svg?logo=github)](https://github.com/markokosticdev/cloud_text_to_speech_nodejs?tab=BSD-2-Clause-1-ov-file)\n[![GitHub Sponsor](https://img.shields.io/badge/GitHub%20Sponsor-donate-yellow.svg?logo=github)](https://github.com/sponsors/markokosticdev)\n[![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-donate-yellow.svg?logo=buy-me-a-coffee)](https://www.buymeacoffee.com/markokostich)\n\nSingle interface to Google, Microsoft, and Amazon Text-To-Speech.\nNodeJS implementation of:\n\n- [Google Cloud Text-To-Speech API](https://cloud.google.com/text-to-speech)\n- [Microsoft Azure Cognitive Text-To-Speech API](https://azure.microsoft.com/en-us/services/cognitive-services/text-to-speech)\n- [Amazon Polly API](https://aws.amazon.com/polly)\n\n## Features\n\n- Universal implementation for accessing all providers with one interface.\n- Separate implementation for every provider so we could access every functionality.\n- Sanitize SSML input per provider so we send only supported SSML elements.\n- Locale names in English and native language so we could display language selector.\n- Fake name generation for Google voices that are generated randomly based on voice locale.\n- Accessible configurable output format (per provider), rate, and pitch.\n\n## Feature Requests\n\nWe welcome and value your ideas and suggestions to improve this project! To submit and vote for feature requests, please visit our [Feature Requests Board](https://cloud-text-to-speech.featureupvote.com).\n\nOn the board, you can:\n- **Submit new feature requests**: Share your ideas on how we can enhance the project.\n- **Vote on existing requests**: Help prioritize the most popular features by voting for the ones you find most valuable.\n\nThank you for contributing to the development and improvement of Cloud Text-To-Speech!\n\n## Getting Started\n\nThere are essentially two ways to use Cloud Text-To-Speech:\n\n- **Universal**: Using TtsUniversal to be able to configure the TTS provider dynamically and us it.\n    - **Single**: Using `TtsProviders.google`, `TtsProviders.microsoft`, `TtsProviders.amazon` to use the single provider at a time.\n    - **Combine**: Using `TtsProviders.combine` to combine all providers and get all voices at once.\n- **Provider**: Using TtsGoogle, TtsMicrosoft, TtsAmazon to get the most from provider's API.\n\n### Universal(Single)\n\nTo init configuration use:\n\n```ts\n//Do init once and run it before any other method\nTtsUniversal.init({\n  provider: TtsProviders.amazon,\n  googleParams: { apiKey: \"API-KEY\" },\n  microsoftParams: { subscriptionKey: \"SUBSCRIPTION-KEY\", region: \"eastus\" },\n  amazonParams: { keyId: \"KEY-ID\", accessKey: \"ACCESS-KEY\", region: \"us-east-1\" },\n  withLogs: true\n});\n```\n\nTo change provider use:\n\n```ts\nTtsUniversal.setProvider(TtsProviders.microsoft);\n```\n\nTo get the list of all voices use:\n\n```ts\n//Get voices\nconst voicesResponse = await TtsUniversal.getVoices();\nconst voices = voicesResponse.voices;\n\n//Print all available voices\nconsole.log(voices);\n\n//Pick an English Voice\nconst voice = voices.find((voice) =\u003e voice.locale.code.startsWith('en-'));\n```\n\nTo convert TTS and get audio use:\n\n```ts\n//Generate Audio for a text\nconst text = \"Amazon, Microsoft and Google Text-to-Speech API are awesome\";\n\nconst ttsParams = new TtsParamsUniversal({\n  voice: voice,\n  audioFormat: AudioOutputFormatUniversal.mp3_64k,\n  text: text,\n  rate: 'slow', //optional\n  pitch: 'default', //optional\n});\n\nconst ttsResponse = await TtsUniversal.convertTts(ttsParams);\n\n//Get the audio bytes.\nconst audioBytes = ttsResponse.audio;\n```\n\n### Universal(Combine)\n\nTo init configuration use:\n\n```ts\n//Do init once and run it before any other method\nTtsUniversal.init({\n  provider: TtsProviders.combine,\n  googleParams: { apiKey: \"API-KEY\" },\n  microsoftParams: { subscriptionKey: \"SUBSCRIPTION-KEY\", region: \"eastus\" },\n  amazonParams: { keyId: \"KEY-ID\", accessKey: \"ACCESS-KEY\", region: \"us-east-1\" },\n  withLogs: true\n});\n```\n\nTo change provider use:\n\n```ts\nTtsUniversal.setProvider(TtsProviders.combine);\n```\n\nTo get the list of all voices use:\n\n```ts\n//Get voices\nconst voicesResponse = await TtsUniversal.getVoices();\nconst voices = voicesResponse.voices;\n\n//Print all available voices\nconsole.log(voices);\n\n//Pick an English Voice\nconst voice = voices.find((voice) =\u003e voice.locale.code.startsWith('en-'));\n```\n\nTo convert TTS and get audio use:\n\n```ts\n//Generate Audio for a text\nconst text = \"Amazon, Microsoft and Google Text-to-Speech API are awesome\";\n\nconst ttsParams = new TtsParamsUniversal({\n  voice: voice,\n  audioFormat: AudioOutputFormatUniversal.mp3_64k,\n  text: text,\n  rate: 'slow', //optional\n  pitch: 'default', //optional\n});\n\nconst ttsResponse = await TtsUniversal.convertTts(ttsParams);\n\n//Get the audio bytes.\nconst audioBytes = ttsResponse.audio;\n```\n\n### Google\n\nTo init configuration use:\n\n```ts\n//Do init once and run it before any other method\nTtsGoogle.init({\n  params: { apiKey: 'API-KEY' },\n  withLogs: true,\n});\n```\n\nTo get the list of all voices use:\n\n```ts\n//Get voices\nconst voicesResponse = await TtsGoogle.getVoices();\nconst voices = voicesResponse.voices;\n\n//Print all voices\nconsole.log(voices);\n\n//Pick an English Voice\nconst voice = voices.find((voice) =\u003e voice.locale.code.startsWith('en-'));\n```\n\nTo convert TTS and get audio use:\n\n```ts\n//Generate Audio for a text\nconst text = '\u003cspeak\u003eGoogle\u003cbreak time=\"2s\"\u003e Speech Service Text-to-Speech API is awesome!\u003c/speak\u003e';\n\nconst ttsParams = new TtsParamsGoogle({\n  voice: voice,\n  audioFormat: AudioOutputFormatGoogle.mp3,\n  text: text,\n  rate: 'slow', //optional\n  pitch: 'default', //optional\n});\n\nconst ttsResponse = await TtsGoogle.convertTts(ttsParams);\n\n//Get the audio bytes.\nconst audioBytes = ttsResponse.audio;\n```\n\n### Microsoft\n\nTo init configuration use:\n\n```ts\n//Do init once and run it before any other method\nTtsMicrosoft.init({\n  params: { subscriptionKey: 'SUBSCRIPTION-KEY', region: 'eastus' },\n  withLogs: true,\n});\n```\n\nTo get the list of all voices use:\n\n```ts\n//Get voices\nconst voicesResponse = await TtsMicrosoft.getVoices();\nconst voices = voicesResponse.voices;\n\n//Print all voices\nconsole.log(voices);\n\n//Pick an English Voice\nconst voice = voices.find((voice) =\u003e voice.locale.code.startsWith('en-'));\n```\n\nTo convert TTS and get audio use:\n\n```ts\n//Generate Audio for a text\nconst text = '\u003cspeak\u003eMicrosoft\u003cbreak time=\"2s\"\u003e Speech Service Text-to-Speech API is awesome!\u003c/speak\u003e';\n\nconst ttsParams = new TtsParamsMicrosoft({\n  voice: voice,\n  audioFormat: AudioOutputFormatMicrosoft.audio48Khz192kBitrateMonoMp3,\n  text: text,\n  rate: 'slow', //optional\n  pitch: 'default', //optional\n});\n\nconst ttsResponse = await TtsMicrosoft.convertTts(ttsParams);\n\n//Get the audio bytes.\nconst audioBytes = ttsResponse.audio;\n```\n\n### Amazon\n\nTo init configuration use:\n\n```ts\n//Do init once and run it before any other method\nTtsAmazon.init({\n  params: { keyId: 'KEY-ID', accessKey: 'ACCESS-KEY', region: 'us-east-1' },\n  withLogs: true,\n});\n```\n\nTo get the list of all voices use:\n\n```ts\n//Get voices\nconst voicesResponse = await TtsAmazon.getVoices();\nconst voices = voicesResponse.voices;\n\n//Print all voices\nconsole.log(voices);\n\n//Pick an English Voice\nconst voice = voices.find((voice) =\u003e voice.locale.code.startsWith('en-'));\n```\n\nTo convert TTS and get audio use:\n\n```ts\n//Generate Audio for a text\nconst text = '\u003cspeak\u003eAmazon\u003cbreak time=\"2s\"\u003e Speech Service Text-to-Speech API is awesome!\u003c/speak\u003e';\n\nconst ttsParams = new TtsParamsAmazon({\n  voice: voice,\n  audioFormat: AudioOutputFormatAmazon.mp3,\n  text: text,\n  rate: 'slow', // optional\n  pitch: 'default', // optional\n});\n\nconst ttsResponse = await TtsAmazon.convertTts(ttsParams);\n\n//Get the audio bytes.\nconst audioBytes = ttsResponse.audio;\n```\n\n## Notes\n\nThere are things you should take care of:\n\n- Securing of your API keys and credentials, they could be extracted from your web or mobile app.\n- For fixing SSML/XML before passing it to TTS Params, you could use the [xmldom](https://www.npmjs.com/package/xmldom)\n  package's,\n  methods `(new XMLSerializer()).serializeToString(new DOMParser().parseFromString(ssml, 'text/xml'))`.\n- Audio has uniform format for all providers, it is Uint8Array that you could use to play it or save it to file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkokosticdev%2Fcloud_text_to_speech_nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkokosticdev%2Fcloud_text_to_speech_nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkokosticdev%2Fcloud_text_to_speech_nodejs/lists"}