android_tts 0.0.1 copy "android_tts: ^0.0.1" to clipboard
android_tts: ^0.0.1 copied to clipboard

PlatformAndroid
outdated

A TTS plug-in that supports switching engines

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _androidTtsPlugin = AndroidTts();
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                  onPressed: () {
                    _androidTtsPlugin.openTTSSetting();
                  },
                  child: const Text("switch system engine")),
              ElevatedButton(
                  onPressed: () {
                    _androidTtsPlugin.init();
                  },
                  child: const Text("init")),
              ElevatedButton(
                  onPressed: () async {
                    print(await _androidTtsPlugin.getConfig());
                  },
                  child: const Text("print config")),
              ElevatedButton(
                  onPressed: () async {
                    print(await _androidTtsPlugin.setPitch(pitch: 0.5));
                  },
                  child: const Text("setPitch")),
              ElevatedButton(
                  onPressed: () async {
                    print(await _androidTtsPlugin.setLanguage(
                        language: 'yue__#Hant'));
                  },
                  child: const Text("setLanguage")),
              ElevatedButton(
                  onPressed: () {
                    _androidTtsPlugin.speak(text: "你好啊中国");
                  },
                  child: const Text("speak")),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

A TTS plug-in that supports switching engines

Homepage

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on android_tts

Packages that implement android_tts