tts_azure 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 59

Speech to text from Azure. #

image alt image alt

A Flutter package to use Text to Speech from Azure.

Package that interacts with the Azure Cognitive Services REST API to convert text to speech.

Getting Started #

  1. Create an account and subscribe in Azure
  2. Add the Cognitive Services resource and get the endpoint (with region identifier) and subscription key (create resource group if necessary).
  3. Install tts_azure package.

Usage #

Complete Example #

There is a very simple example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

Install #

To use this package, add tts_azure as a dependency in your pubspec.yaml file

Setting up #

First, you must define a new TTS Azure object by initializing it and passing it the required parameters as such:

final ttsazure = TTSAzure("YOUR_SUBSCRIPTION_ID", "YOUR_REGION_IDENTIFIER");

Convert Text ➡️ Speech #

Finally, the only thing left to do is call the play() method to convert the text to speech, in this way:

String text = "Hello World";
String lang = "en-US";
String shortName = "BenjaminRUS"; // The voice.

ttsazure.play(text, lang, shortName);

NOTE: The Azure API allows you to use the authentication token (automatically obeyed by this package) only for 10 minutes, so this package updates the token in a minimum time of 9 minutes.

Author: @leonus96

*List of standart voices #

Locale Language Gender Full service name mapping Short name
1ar-EG Arabic (Egypt) Female "Microsoft Server Speech Text to Speech Voice (ar-EG, Hoda)" "ar-EG-Hoda"
ar-SA Arabic (Saudi Arabia) Male "Microsoft Server Speech Text to Speech Voice (ar-SA, Naayf)" "ar-SA-Naayf"
bg-BG Bulgarian Male "Microsoft Server Speech Text to Speech Voice (bg-BG, Ivan)" "bg-BG-Ivan"
ca-ES Catalan (Spain) Female "Microsoft Server Speech Text to Speech Voice (ca-ES, HerenaRUS)" "ca-ES-HerenaRUS"
cs-CZ Czech Male "Microsoft Server Speech Text to Speech Voice (cs-CZ, Jakub)" "cs-CZ-Jakub"
da-DK Danish Female "Microsoft Server Speech Text to Speech Voice (da-DK, HelleRUS)" "da-DK-HelleRUS"
de-AT German (Austria) Male "Microsoft Server Speech Text to Speech Voice (de-AT, Michael)" "de-AT-Michael"
de-CH German (Switzerland) Male "Microsoft Server Speech Text to Speech Voice (de-CH, Karsten)" "de-CH-Karsten"
de-DE German (Germany) Female "Microsoft Server Speech Text to Speech Voice (de-DE, Hedda)" "de-DE-Hedda"
Female "Microsoft Server Speech Text to Speech Voice (de-DE, HeddaRUS)" "de-DE-HeddaRUS"
Male "Microsoft Server Speech Text to Speech Voice (de-DE, Stefan, Apollo)" "de-DE-Stefan-Apollo"
el-GR Greek Male "Microsoft Server Speech Text to Speech Voice (el-GR, Stefanos)" "el-GR-Stefanos"
en-AU English (Australia) Female "Microsoft Server Speech Text to Speech Voice (en-AU, Catherine)" "en-AU-Catherine"
Female "Microsoft Server Speech Text to Speech Voice (en-AU, HayleyRUS)" "en-AU-HayleyRUS"
en-CA English (Canada) Female "Microsoft Server Speech Text to Speech Voice (en-CA, Linda)" "en-CA-Linda"
Female "Microsoft Server Speech Text to Speech Voice (en-CA, HeatherRUS)" "en-CA-HeatherRUS"
en-GB English (UK) Female "Microsoft Server Speech Text to Speech Voice (en-GB, Susan, Apollo)" "en-GB-Susan-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (en-GB, HazelRUS)" "en-GB-HazelRUS"
Male "Microsoft Server Speech Text to Speech Voice (en-GB, George, Apollo)" "en-GB-George-Apollo"
en-IE English (Ireland) Male "Microsoft Server Speech Text to Speech Voice (en-IE, Sean)" "en-IE-Sean"
en-IN English (India) Female "Microsoft Server Speech Text to Speech Voice (en-IN, Heera, Apollo)" "en-IN-Heera-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (en-IN, PriyaRUS)" "en-IN-PriyaRUS"
Male "Microsoft Server Speech Text to Speech Voice (en-IN, Ravi, Apollo)" "en-IN-Ravi-Apollo"
en-US English (US) Female "Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)" "en-US-ZiraRUS"
Female "Microsoft Server Speech Text to Speech Voice (en-US, AriaRUS)" "en-US-AriaRUS"
Male "Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS)" "en-US-BenjaminRUS"
Male "Microsoft Server Speech Text to Speech Voice (en-US, Guy24kRUS)" "en-US-Guy24kRUS"
es-ES Spanish (Spain) Female "Microsoft Server Speech Text to Speech Voice (es-ES, Laura, Apollo)" "es-ES-Laura-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (es-ES, HelenaRUS)" "es-ES-HelenaRUS"
Male "Microsoft Server Speech Text to Speech Voice (es-ES, Pablo, Apollo)" "es-ES-Pablo-Apollo"
es-MX Spanish (Mexico) Female "Microsoft Server Speech Text to Speech Voice (es-MX, HildaRUS)" "es-MX-HildaRUS"
Male "Microsoft Server Speech Text to Speech Voice (es-MX, Raul, Apollo)" "es-MX-Raul-Apollo"
fi-FI Finnish Female "Microsoft Server Speech Text to Speech Voice (fi-FI, HeidiRUS)" "fi-FI-HeidiRUS"
fr-CA French (Canada) Female "Microsoft Server Speech Text to Speech Voice (fr-CA, Caroline)" "fr-CA-Caroline"
Female "Microsoft Server Speech Text to Speech Voice (fr-CA, HarmonieRUS)" "fr-CA-HarmonieRUS"
fr-CH French (Switzerland) Male "Microsoft Server Speech Text to Speech Voice (fr-CH, Guillaume)" "fr-CH-Guillaume"
fr-FR French (France) Female "Microsoft Server Speech Text to Speech Voice (fr-FR, Julie, Apollo)" "fr-FR-Julie-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (fr-FR, HortenseRUS)" "fr-FR-HortenseRUS"
Male "Microsoft Server Speech Text to Speech Voice (fr-FR, Paul, Apollo)" "fr-FR-Paul-Apollo"
he-IL Hebrew (Israel) Male "Microsoft Server Speech Text to Speech Voice (he-IL, Asaf)" "he-IL-Asaf"
hi-IN Hindi (India) Female "Microsoft Server Speech Text to Speech Voice (hi-IN, Kalpana, Apollo)" "hi-IN-Kalpana-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (hi-IN, Kalpana)" "hi-IN-Kalpana"
Male "Microsoft Server Speech Text to Speech Voice (hi-IN, Hemant)" "hi-IN-Hemant"
hr-HR Croatian Male "Microsoft Server Speech Text to Speech Voice (hr-HR, Matej)" "hr-HR-Matej"
hu-HU Hungarian Male "Microsoft Server Speech Text to Speech Voice (hu-HU, Szabolcs)" "hu-HU-Szabolcs"
id-ID Indonesian Male "Microsoft Server Speech Text to Speech Voice (id-ID, Andika)" "id-ID-Andika"
it-IT Italian Male "Microsoft Server Speech Text to Speech Voice (it-IT, Cosimo, Apollo)" "it-IT-Cosimo-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (it-IT, LuciaRUS)" "it-IT-LuciaRUS"
ja-JP Japanese Female "Microsoft Server Speech Text to Speech Voice (ja-JP, Ayumi, Apollo)" "ja-JP-Ayumi-Apollo"
Male "Microsoft Server Speech Text to Speech Voice (ja-JP, Ichiro, Apollo)" "ja-JP-Ichiro-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (ja-JP, HarukaRUS)" "ja-JP-HarukaRUS"
ko-KR Korean Female "Microsoft Server Speech Text to Speech Voice (ko-KR, HeamiRUS)" "ko-KR-HeamiRUS"
ms-MY Malay Male "Microsoft Server Speech Text to Speech Voice (ms-MY, Rizwan)" "ms-MY-Rizwan"
nb-NO Norwegian Female "Microsoft Server Speech Text to Speech Voice (nb-NO, HuldaRUS)" "nb-NO-HuldaRUS"
nl-NL Dutch Female "Microsoft Server Speech Text to Speech Voice (nl-NL, HannaRUS)" "nl-NL-HannaRUS"
pl-PL Polish Female "Microsoft Server Speech Text to Speech Voice (pl-PL, PaulinaRUS)" "pl-PL-PaulinaRUS"
pt-BR Portuguese (Brazil) Female "Microsoft Server Speech Text to Speech Voice (pt-BR, HeloisaRUS)" "pt-BR-HeloisaRUS"
Male "Microsoft Server Speech Text to Speech Voice (pt-BR, Daniel, Apollo)" "pt-BR-Daniel-Apollo"
pt-PT Portuguese (Portugal) Female "Microsoft Server Speech Text to Speech Voice (pt-PT, HeliaRUS)" "pt-PT-HeliaRUS"
ro-RO Romanian Male "Microsoft Server Speech Text to Speech Voice (ro-RO, Andrei)" "ro-RO-Andrei"
ru-RU Russian Female "Microsoft Server Speech Text to Speech Voice (ru-RU, Irina, Apollo)" "ru-RU-Irina-Apollo"
Male "Microsoft Server Speech Text to Speech Voice (ru-RU, Pavel, Apollo)" "ru-RU-Pavel-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (ru-RU, EkaterinaRUS)" ru-RU-EkaterinaRUS
sk-SK Slovak Male "Microsoft Server Speech Text to Speech Voice (sk-SK, Filip)" "sk-SK-Filip"
sl-SI Slovenian Male "Microsoft Server Speech Text to Speech Voice (sl-SI, Lado)" "sl-SI-Lado"
sv-SE Swedish Female "Microsoft Server Speech Text to Speech Voice (sv-SE, HedvigRUS)" "sv-SE-HedvigRUS"
ta-IN Tamil (India) Male "Microsoft Server Speech Text to Speech Voice (ta-IN, Valluvar)" "ta-IN-Valluvar"
te-IN Telugu (India) Female "Microsoft Server Speech Text to Speech Voice (te-IN, Chitra)" "te-IN-Chitra"
th-TH Thai Male "Microsoft Server Speech Text to Speech Voice (th-TH, Pattara)" "th-TH-Pattara"
tr-TR Turkish (Turkey) Female "Microsoft Server Speech Text to Speech Voice (tr-TR, SedaRUS)" "tr-TR-SedaRUS"
vi-VN Vietnamese Male "Microsoft Server Speech Text to Speech Voice (vi-VN, An)" "vi-VN-An"
zh-CN Chinese (Mandarin, simplified) Female "Microsoft Server Speech Text to Speech Voice (zh-CN, HuihuiRUS)" "zh-CN-HuihuiRUS"
Female "Microsoft Server Speech Text to Speech Voice (zh-CN, Yaoyao, Apollo)" "zh-CN-Yaoyao-Apollo"
Male "Microsoft Server Speech Text to Speech Voice (zh-CN, Kangkang, Apollo)" "zh-CN-Kangkang-Apollo"
zh-HK Chinese (Cantonese, Traditional) Female "Microsoft Server Speech Text to Speech Voice (zh-HK, Tracy, Apollo)" "zh-HK-Tracy-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (zh-HK, TracyRUS)" "zh-HK-TracyRUS"
Male "Microsoft Server Speech Text to Speech Voice (zh-HK, Danny, Apollo)" "zh-HK-Danny-Apollo"
zh-TW Chinese (Taiwanese Mandarin) Female "Microsoft Server Speech Text to Speech Voice (zh-TW, Yating, Apollo)" "zh-TW-Yating-Apollo"
Female "Microsoft Server Speech Text to Speech Voice (zh-TW, HanHanRUS)" "zh-TW-HanHanRUS"
Male "Microsoft Server Speech Text to Speech Voice (zh-TW, Zhiwei, Apollo)" "zh-TW-Zhiwei-Apollo"

[1.0.0] - 27/03/2020 #

  • Replace function name play to speak.
  • Implement stop function.

[0.0.7] - 27/03/2020 #

  • Replace audioplayer package for audioplayers.

[0.0.6] - 27/03/2020 #

  • Add List of Azure standart voices.

[0.0.5] - 27/03/2020 #

  • Update dependencies.
  • Fix README.md

[0.0.4] - 27/03/2020 #

  • Fix README.MD.
  • Add description in pubspec.yaml

[0.0.3] - 26/03/2020 #

  • Fix README.MD.
  • Change language in example project.

[0.0.2] - 26/03/2020 #

  • Updated documentation in README.MD.
  • Change language in example project.

[0.0.1] - 26/03/2020 #

  • Token reload in 9 minutes.
  • Speech to text.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:tts_azure/tts_azure.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TTSAzure',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'TTSAzure'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TTSAzure _ttsazure;
  TextEditingController _controller;
  String _lang = 'es-ES';
  String _shortName = 'es-ES-Pablo-Apollo';
  
  @override
  void initState() {
    _ttsazure = TTSAzure("YOUR_SUBSCRIPTION_KEY", "YOUR_REGION_IDENTIFIER");
    _controller = TextEditingController();
    _controller.text = "¡Hola Mundo!";
    super.initState();
  }

  void _play() {
    _ttsazure.speak(_controller.text, _lang, _shortName);
  }

  void _stop() {
    _ttsazure.stop();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            ListTile(
              title: TextField(
                maxLines: 10,
                controller: _controller,
              ),
            )
          ],
        ),
      ),
      floatingActionButton: Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: <Widget>[
          FloatingActionButton(
            onPressed: _play,
            tooltip: 'Speech to Text',
            child: Icon(Icons.play_arrow),
          ),
          SizedBox(width: 15,),
          FloatingActionButton(
            onPressed: _stop,
            tooltip: 'Stop speech',
            child: Icon(Icons.stop),
          )
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  tts_azure: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tts_azure/tts_azure.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
26
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Android

Because:

  • package:tts_azure/tts_azure.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Linux

Because:

  • package:tts_azure/tts_azure.dart that imports:
  • package:audioplayers/audioplayers.dart that declares support for platforms: Android, iOS, macOS

Package does not support Flutter platform Web

Because:

  • package:tts_azure/tts_azure.dart that imports:
  • package:audioplayers/audioplayers.dart that declares support for platforms: Android, iOS, macOS

Package does not support Flutter platform Windows

Because:

  • package:tts_azure/tts_azure.dart that imports:
  • package:audioplayers/audioplayers.dart that declares support for platforms: Android, iOS, macOS

Package does not support Flutter platform iOS

Because:

  • package:tts_azure/tts_azure.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform macOS

Because:

  • package:tts_azure/tts_azure.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package not compatible with SDK dart

Because:

  • tts_azure that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

5 out of 5 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/tts_azure.dart.

Run flutter format to format lib/tts_azure.dart.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (audioplayers, xml).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
audioplayers ^0.14.2 0.14.2 0.15.1
flutter 0.0.0
http ^0.12.0+4 0.12.1
path_provider ^1.6.5 1.6.11
xml ^3.5.0 3.7.0 4.2.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
flutter_web_plugins 0.0.0
http_parser 3.1.4
intl 0.16.1
meta 1.1.8 1.2.2
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
pedantic 1.9.0 1.9.2
petitparser 3.0.4
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
uuid 2.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test