flutter_baidutts 0.0.5 copy "flutter_baidutts: ^0.0.5" to clipboard
flutter_baidutts: ^0.0.5 copied to clipboard

flutter plugin for baidu tts

example/lib/main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  var res = await FlutterBaidutts.instance.init(
    appId: '22722660',
    appKey: 'X1Lh6ALA408BUI5bquxcLgVE',
    appSecret: 'z9ayX40Ca3kxHzrORczSHfgChrN9lkTy',
  );

  print('init code: $res');

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double volume = 1.0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              FlatButton(
                child: Text('speek'),
                onPressed: () async {
                  final res = await FlutterBaidutts.instance.speak('你好,我是刘艳琦,英文名字是river');
                  print("speek:$res");
                },
              ),
              Row(
                children: [
                  Text('volume'),
                  Expanded(
                    child: Slider(
                      value: volume,
                      onChanged: (value) {
                        setState(() {
                          volume = value;
                        });

                        FlutterBaidutts.instance.setVolume(volume);
                      },
                    ),
                  ),
                ],
              ),
              FlatButton(
                child: Text('pause'),
                onPressed: () async {
                  FlutterBaidutts.instance.pause();
                },
              ),
              FlatButton(
                child: Text('resume'),
                onPressed: () async {
                  FlutterBaidutts.instance.resume();
                },
              ),
              FlatButton(
                child: Text('stop'),
                onPressed: () async {
                  FlutterBaidutts.instance.stop();
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
30
pub points
0%
popularity

Publisher

unverified uploader

flutter plugin for baidu tts

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_baidutts