Coder Social home page Coder Social logo

flutter_azure_tts's Introduction

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

flutter_azure_tts's People

Contributors

ghuyfel avatar indjec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_azure_tts's Issues

Web app Play Uint8List audio on Safari iPhone device

Hi and thanks for creating the package, i am developing a Web Flutter application and i can successfully play Audio File using Chrome web browser on my Android device and Computer, but failed to play audio using Chrome on my iPhone or Safari browser on my Mac,
I am using the following code to convert Uint8List to a Url

`
import 'dart:html' as html;

final blob = html.Blob([bytes], 'audio/mp3', 'native');
final url = html.Url.createObjectUrlFromBlob(blob);`
Please advice what to do in order to play the url on iPhone Chrome browser too
Tnaks

Add style friendly

Could you adding more optional parameters. Such as style.

The following is an example of ssml,

<speak
	xmlns="http://www.w3.org/2001/10/synthesis"
	xmlns:mstts="http://www.w3.org/2001/mstts"
	xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="en-US">
	<voice name="en-US-JaneNeural">
		<s />
		<mstts:express-as style="cheerful">Good morning, Contoso restaurant. I am your AI assistant, Jane. How can I help you?</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-TonyNeural">
		<s />
		<mstts:express-as style="friendly">Hi
			<break strength="weak" />, I would like to make a dinner reservation.
		</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-JaneNeural">
		<s />
		<mstts:express-as style="cheerful">Of course, what evening will you be joining us on?</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-TonyNeural">We will need the reservation for Thursday night.</voice>
	<voice name="en-US-JaneNeural">
		<s />
		<mstts:express-as style="cheerful">
			<prosody rate="+20.00%">And what time would you like the reservation for?</prosody>
		</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-TonyNeural">We would prefer 7:00 or 7:30.</voice>
	<voice name="en-US-JaneNeural">
		<s />
		<mstts:express-as style="cheerful">
			<prosody rate="+10.00%">Sounds good!</prosody>
			<prosody rate="-5.00%"> And for how many people?</prosody>
		</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-TonyNeural">
		<s />There will be 5 of us.
		<s />
	</voice>
	<voice name="en-US-JaneNeural">
		<s />
		<mstts:express-as style="cheerful">Fine, I can seat you at 7:00 on Thursday, if you would kindly give me your name.</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-TonyNeural">
		<mstts:express-as style="friendly">The last name is Wood. W-O-O-D, Wood.</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-JaneNeural">
		<s />
		<mstts:express-as style="excited">See you at 7:00 this Thursday, Mr. Wood.</mstts:express-as>
		<s />
	</voice>
	<voice name="en-US-TonyNeural">
		<s />
		<mstts:express-as style="Default">Thank you.</mstts:express-as>
		<s />
	</voice>
</speak>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.