패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.3.2

cloud_text_to_speech

Google, Microsoft 및 Amazon 텍스트 음성 변환을 위한 단일 인터페이스입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
294
좋아요
31
Pub 점수
120

패키지 설치

flutter pub add cloud_text_to_speech

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Google, Microsoft, Amazon 클라우드 서비스의 텍스트 음성 합성 기능을 통합하여 단일 인터페이스를 제공하는 통합된 Flutter 패키지입니다. 제공업체별 API를 추상화함으로써 여러 플랫폼에서 음성 출력 구현을 간소화합니다. 개발자는 코드 변경을 최소한으로 하여 제공업체를 쉽게 전환할 수 있으며, 자연스러운 음성 합성을 필요로 하는 앱에서 확장 가능하고 유연한 TTS 솔루션을 구현할 수 있습니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux를 지원하여 크로스플랫폼 음성 기반 애플리케이션에 이상적입니다.

사용 사례

  • 크로스 플랫폼 음성 보조자
  • 오디오 내레이션을 갖춘 전자 학습 애플리케이션
  • 앱의 접근성 기능
  • 다국어 음성 출력
  • 채팅봇에서의 자동 음성 응답

주요 기능

  • Google, Microsoft, AWS TTS를 위한 통합 API
  • 여러 언어와 음성 지원
  • 플랫폼에 관계없는 구현
  • 간편한 공급업체 전환
  • 내장된 오류 처리 및 재시도
  • 실시간 오디오 스트리밍 지원

적합한 대상

  • 다중 공급자 TTS 앱을 개발하는 개발자
  • 다양한 플랫폼에서 일관된 음성 출력이 필요한 앱
  • 음성 특징의 빠른 프로토타이핑을 필요로 하는 프로젝트
  • 여러 클라우드 TTS 서비스를 사용하는 팀

고려 사항

  • 각 클라우드 공급자에 대해 API 키가 필요합니다
  • 사용량에 따라 청구가 적용됩니다
  • 클라우드 호출을 위해 네트워크 연결이 필요합니다
  • 제한된 오프라인 기능
  • 음성 품질은 선택한 공급업체 및 지역에 따라 달라집니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Cloud Text-To-Speech

Pub Version Pub Likes Pub Popularity Pub Points GitHub License GitHub Sponsor Buy Me a Coffee

Single interface to Google, Microsoft, and Amazon Text-To-Speech. Flutter implementation of:

Features

  • 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 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();
Universal(Combine)

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();
Google

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();
Microsoft

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();
Amazon

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();

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.
  • Some player packages that are good fit are: audioplayers and assets_audio_player.

카테고리

의존성

의존성 목록 6 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.