Skip to content

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

License

Notifications You must be signed in to change notification settings

enhanceai/flutter_azure_tts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_azure_tts

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

Getting Started

Initialise the framework with your Region and Subscription key

  AzureTts.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 AzureTts.getTts(params);

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%