cloud_text_to_speech
Google, Microsoft 및 Amazon 텍스트 음성 변환을 위한 단일 인터페이스입니다.
Google, Microsoft, Amazon 텍스트 음성 변환을 위한 단일 인터페이스입니다.
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Single interface to Google, Microsoft, and Amazon Text-To-Speech. Flutter implementation of:
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:
Thank you for contributing to the development and improvement of Cloud Text-To-Speech!
There are essentially two ways to use Cloud Text-To-Speech:
TtsProviders.google, TtsProviders.microsoft, TtsProviders.amazon to use the single provider at a time.TtsProviders.combine to combine all providers and get all voices at once.To init configuration use:
//Do init once and run it before any other method
TtsUniversal.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 voices
final voicesResponse = await TtsUniversal.getVoices();
final voices = voicesResponse.voices;
//Print all available voices
print(voices);
//Pick an English Voice
final voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a text
const 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 = await TtsUniversal.convertTts(ttsParams);
//Get the audio bytes.
final audioBytes = ttsResponse.audio.buffer.asByteData();
To init configuration use:
//Do init once and run it before any other method
TtsUniversal.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 voices
final voicesResponse = await TtsUniversal.getVoices();
final voices = voicesResponse.voices;
//Print all available voices
print(voices);
//Pick an English Voice
final voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a text
const 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 = await TtsUniversal.convertTts(ttsParams);
//Get the audio bytes.
final audioBytes = ttsResponse.audio.buffer.asByteData();
To init configuration use:
//Do init once and run it before any other method
TtsGoogle.init(
params: InitParamsGoogle(apiKey: "API-KEY"),
withLogs:true
);
To get the list of all voices use:
//Get voices
final voicesResponse = await TtsGoogle.getVoices();
final voices = voicesResponse.voices;
//Print all voices
print(voices);
//Pick an English Voice
final voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a text
final 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 = await TtsGoogle.convertTts(ttsParams);
//Get the audio bytes.
final audioBytes = ttsResponse.audio.buffer.asByteData();
To init configuration use:
//Do init once and run it before any other method
TtsMicrosoft.init(
params: InitParamsMicrosoft(
subscriptionKey: "SUBSCRIPTION-KEY", region: "eastus"),
withLogs: true
);
To get the list of all voices use:
//Get voices
final voicesResponse = await TtsMicrosoft.getVoices();
final voices = voicesResponse.voices;
//Print all voices
print(voices);
//Pick an English Voice
final voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a text
final 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 = await TtsMicrosoft.convertTts(ttsParams);
//Get the audio bytes.
final audioBytes = ttsResponse.audio.buffer.asByteData();
To init configuration use:
//Do init once and run it before any other method
TtsAmazon.init(
params: InitParamsAmazon(
keyId: 'KEY-ID',
accessKey: 'ACCESS-KEY',
region: 'us-east-1'
),
withLogs: true
);
To get the list of all voices use:
//Get voices
final voicesResponse = await TtsAmazon.getVoices();
final voices = voicesResponse.voices;
//Print all voices
print(voices);
//Pick an English Voice
final voice = voices
.where((element) => element.locale.code.startsWith("en-"))
.toList(growable: false)
.first;
To convert TTS and get audio use:
//Generate Audio for a text
final 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 = await TtsAmazon.convertTts(ttsParams);
//Get the audio bytes.
final audioBytes = ttsResponse.audio.buffer.asByteData();
There are things you should take care of:
XmlDocument.parse(ssml).toXmlString().의존성 목록 10 개
{"sdk":"flutter"}—^4.8.1^2.4.6^1.1.1^6.3.0^5.0.0{"sdk":"flutter"}^2.0.0^6.7.1사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗