flutter_azure_tts 0.2.3 copy "flutter_azure_tts: ^0.2.3" to clipboard
flutter_azure_tts: ^0.2.3 copied to clipboard

Flutter implementation of Microsoft Azure Cognitive Text-To-Speech

flutter_azure_tts #

Flutter implementation of Microsoft Azure Cognitive Text-To-Speech API.

Getting Started #

Initialise the framework with your Region and Subscription key

  FlutterAzureTts.init(
      subscriptionKey: "YOUR SUBSCRIPTION KEY",
      region: "YOUR REGION",
      withLogs: true); // enable logs

Get the list of all available voices. And pick a voice to read the text.

  // Get available voices
  final voicesResponse = await AzureTts.getAvailableVoices();

  //List all available voices
  print("${voicesResponse.voices}");

  //Pick a Neural voice
  final voice = voicesResponse.voices
      .where((element) => element.locale.startsWith("en-"))
      .toList(growable: false).first;

Request audio file.

   //Generate Audio for a text
  final text = "Microsoft Speech Service Text-to-Speech API is awesome";

  TtsParams params = TtsParams(
      voice: voice,
      audioFormat: AudioOutputFormat.audio16khz32kBitrateMonoMp3,
      rate: 1.5, // optional prosody rate (default is 1.0)
      text: text);

  final ttsResponse = await FlutterAzureTts.getTts(params);

  //Get the audio bytes.
  final audioBytes = ttsResponse.audio.buffer.asByteData(); // you can save these bytes to a file for later playback

You can also optionally specify a speech style and/or a role for voices that support them:

TtsParams params = TtsParams(
    voice: voice,
    audioFormat: AudioOutputFormat.audio16khz32kBitrateMonoMp3,
    text: text,
    role: VoiceRole.SeniorMale,
    style: StyleSsml( style: VoiceStyle.cheerful,
                      styleDegree: 1.5), // optional intensity of the style (0.01 - 2.0)
);
34
likes
140
points
618
downloads

Publisher

verified publisherghuyfel.com

Weekly Downloads

Flutter implementation of Microsoft Azure Cognitive Text-To-Speech

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

equatable, http, json_annotation

More

Packages that depend on flutter_azure_tts