सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक एकीकृत Flutter पैकेज जो Google, Microsoft और Amazon क्लाउड सेवाओं से टेक्स्ट-टू-स्पीच कार्यक्षमता को एकल इंटरफ़ेस के माध्यम से एकीकृत करता है। यह प्रदाता-विशिष्ट API को अब्स्ट्रैक्ट करके विभिन्न प्लेटफॉर्मों पर आवाज़ आउटपुट के कार्यान्वयन को सरल बनाता है। डेवलपर्स को कम से कम कोड बदलाव के साथ प्रदाताओं के बीच स्विच करने की अनुमति मिलती है, जिससे नैचुरल-साउंडिंग बोलने वाले सिंथेसिस की आवश्यकता वाले ऐप्स में स्केलेबल और लचीले TTS समाधान बनाए जा सकते हैं। इस पैकेज का समर्थन Android, iOS, Web, macOS, Windows और Linux के लिए है, जिससे यह क्रॉस-प्लेटफॉर्म आवाज़-आधारित ऐप्स के लिए आदर्श है।
उपयोग
क्रॉस-प्लेटफॉर्म वॉइस असिस्टेंट
ऑडियो नैरेशन वाले ई-लर्निंग एप्लिकेशन
एप्स में एक्सेसिबिलिटी फीचर्स
बहुभाषी ध्वनि आउटपुट
चैटबॉट्स में स्वचालित आवाज़ प्रतिक्रियाएँ
मुख्य विशेषताएँ
Google, Microsoft, और AWS TTS के लिए एकीकृत API
बहुभाषी और आवाज़ों का समर्थन करता है
प्लेटफॉर्म-अनुकूल अमल
आसान प्रदाता बदलें
एम्बेडेड त्रुटि संभाल और पुनर्प्रयास
रियल-टाइम ऑडियो स्ट्रीमिंग सपोर्ट
इनके लिए उपयुक्त
बहु-प्रदाता टीटीएस एप्लिकेशन बनाने वाले डेवलपर्स
प्लेटफॉर्म के आसपास सुस्त ध्वनि आउटपुट की आवश्यकता वाले ऐप
वाणी विशेषताओं के त्वरित प्रोटोटाइपिंग की आवश्यकता वाले प्रोजेक्ट
बहुत से बादल TTS सेवाओं का उपयोग करने वाली टीमें
विचार योग्य बातें
प्रत्येक क्लाउड प्रदाता के लिए API की की आवश्यक है
उपयोग के आधार पर बिलिंग लागू होती है
बाद में कॉल के लिए नेटवर्क कनेक्टिविटी की आवश्यकता होती है
सीमित ऑफलाइन क्षमता
वॉइस क्वालिटी चयनित प्रदाता और क्षेत्र पर निर्भर करती है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Cloud Text-To-Speech
Single interface to Google, Microsoft, and Amazon Text-To-Speech.
Flutter implementation of:
Universal implementation for accessing all providers with one interface.
Separate implementation for every provider so we could access every functionality.
Sanitize SSML input per provider so we send only supported SSML elements.
Locale names in English and native language so we could display language selector.
Fake name generation for Google voices that are generated randomly based on voice locale.
Accessible configurable output format (per provider), rate, and pitch.
Feature Requests
We welcome and value your ideas and suggestions to improve this project! To submit and vote for feature requests, please visit our Feature Requests Board.
On the board, you can:
Submit new feature requests: Share your ideas on how we can enhance the project.
Vote on existing requests: Help prioritize the most popular features by voting for the ones you find most valuable.
Thank you for contributing to the development and improvement of Cloud Text-To-Speech!
Getting Started
There are essentially two ways to use Cloud Text-To-Speech:
Universal: Using TtsUniversal to be able to configure the TTS provider dynamically and us it.
Single: Using TtsProviders.google, TtsProviders.microsoft, TtsProviders.amazon to use the single provider at a time.
Combine: Using TtsProviders.combine to combine all providers and get all voices at once.
Provider: Using TtsGoogle, TtsMicrosoft, TtsAmazon to get the most from provider's API.
Universal(Single)
To init configuration use:
//Do init once and run it before any other methodTtsUniversal.init(
provider: TtsProviders.amazon,
googleParams: InitParamsGoogle(apiKey: 'API-KEY'),
microsoftParams: InitParamsMicrosoft(
subscriptionKey: 'SUBSCRIPTION-KEY', region: 'eastus'),
amazonParams: InitParamsAmazon(
keyId: 'KEY-ID', accessKey: 'ACCESS-KEY', region: 'us-east-1'),
withLogs: true
);
To change provider use:
TtsUniversal.setProvider(TtsProviders.microsoft);
To get the list of all voices use:
//Get voicesfinal voicesResponse = awaitTtsUniversal.getVoices();
final voices = voicesResponse.voices;
//Print all available voicesprint(voices);
//Pick an English Voicefinal voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a textconst text = "Amazon, Microsoft and Google Text-to-Speech API are awesome";
final ttsParams = TtsParamsUniversal(
voice: voice,
audioFormat: AudioOutputFormatUniversal.mp3_64k,
text: text,
rate: 'slow', //optional
pitch: 'default'//optional
);
final ttsResponse = awaitTtsUniversal.convertTts(ttsParams);
//Get the audio bytes.final audioBytes = ttsResponse.audio.buffer.asByteData();
Universal(Combine)
To init configuration use:
//Do init once and run it before any other methodTtsUniversal.init(
provider: TtsProviders.combine,
googleParams: InitParamsGoogle(apiKey: 'API-KEY'),
microsoftParams: InitParamsMicrosoft(
subscriptionKey: 'SUBSCRIPTION-KEY', region: 'eastus'),
amazonParams: InitParamsAmazon(
keyId: 'KEY-ID', accessKey: 'ACCESS-KEY', region: 'us-east-1'),
withLogs: true
);
To change provider use:
TtsUniversal.setProvider(TtsProviders.combine);
To get the list of all voices use:
//Get voicesfinal voicesResponse = awaitTtsUniversal.getVoices();
final voices = voicesResponse.voices;
//Print all available voicesprint(voices);
//Pick an English Voicefinal voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a textconst text = "Amazon, Microsoft and Google Text-to-Speech API are awesome";
final ttsParams = TtsParamsUniversal(
voice: voice,
audioFormat: AudioOutputFormatUniversal.mp3_64k,
text: text,
rate: 'slow', //optional
pitch: 'default'//optional
);
final ttsResponse = awaitTtsUniversal.convertTts(ttsParams);
//Get the audio bytes.final audioBytes = ttsResponse.audio.buffer.asByteData();
Google
To init configuration use:
//Do init once and run it before any other methodTtsGoogle.init(
params: InitParamsGoogle(apiKey: "API-KEY"),
withLogs:true
);
To get the list of all voices use:
//Get voicesfinal voicesResponse = awaitTtsGoogle.getVoices();
final voices = voicesResponse.voices;
//Print all voicesprint(voices);
//Pick an English Voicefinal voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a textfinal text = '<speak>Google<break time="2s"> Speech Service Text-to-Speech API is awesome!</speak>';
TtsParamsGoogle ttsParams = TtsParamsGoogle(
voice: voice,
audioFormat: AudioOutputFormatGoogle.mp3,
text: text,
rate: 'slow', //optional
pitch: 'default'//optional
);
final ttsResponse = awaitTtsGoogle.convertTts(ttsParams);
//Get the audio bytes.final audioBytes = ttsResponse.audio.buffer.asByteData();
Microsoft
To init configuration use:
//Do init once and run it before any other methodTtsMicrosoft.init(
params: InitParamsMicrosoft(
subscriptionKey: "SUBSCRIPTION-KEY", region: "eastus"),
withLogs: true
);
To get the list of all voices use:
//Get voicesfinal voicesResponse = awaitTtsMicrosoft.getVoices();
final voices = voicesResponse.voices;
//Print all voicesprint(voices);
//Pick an English Voicefinal voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a textfinal text = '<speak>Microsoft<break time="2s"> Speech Service Text-to-Speech API is awesome!</speak>';
TtsParamsMicrosoft ttsParams = TtsParamsMicrosoft(
voice: voice,
audioFormat: AudioOutputFormatMicrosoft.audio48Khz192kBitrateMonoMp3,
text: text,
rate: 'slow', //optional
pitch: 'default'//optional
);
final ttsResponse = awaitTtsMicrosoft.convertTts(ttsParams);
//Get the audio bytes.final audioBytes = ttsResponse.audio.buffer.asByteData();
Amazon
To init configuration use:
//Do init once and run it before any other methodTtsAmazon.init(
params: InitParamsAmazon(
keyId: 'KEY-ID',
accessKey: 'ACCESS-KEY',
region: 'us-east-1'
),
withLogs: true
);
To get the list of all voices use:
//Get voicesfinal voicesResponse = awaitTtsAmazon.getVoices();
final voices = voicesResponse.voices;
//Print all voicesprint(voices);
//Pick an English Voicefinal voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a textfinal text = '<speak>Amazon<break time="2s"> Speech Service Text-to-Speech API is awesome!</speak>';
TtsParamsAmazon ttsParams = TtsParamsAmazon(
voice: voice,
audioFormat: AudioOutputFormatAmazon.audio48Khz192kBitrateMonoMp3,
text: text,
rate: 'slow', //optional
pitch: 'default'//optional
);
final ttsResponse = awaitTtsAmazon.convertTts(ttsParams);
//Get the audio bytes.final audioBytes = ttsResponse.audio.buffer.asByteData();
Notes
There are things you should take care of:
Securing of your API keys and credentials, they could be extracted from your mobile or web app.
Sometimes Amazon Polly is not working in emulator, so you could get 403 error.
For fixing SSML/XML before passing it to TTS Params, you could use
the xml package's,
methods XmlDocument.parse(ssml).toXmlString().
Audio has uniform format for all providers, it is Uint8List that you could use to play it or save
it to file.