内容简介:A new Flutter plugin.English Document (中文文档在下面)
A new Flutter plugin.
Getting Started
English Document (中文文档在下面)
Use this package as a library
1. Depend on it 导入
Add this to your package’s pubspec.yaml file:
dependencies:
flutter_plugin_tts: ^1.0.2
-
Install it 安装
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.
-
Import it 导入头文件
Now in your Dart code, you can use:
Import 'package:flutter_plugin_tts/flutter_plugin_tts.dart';
Example of use:
@override Widget build(BuildContext context) { Return MaterialApp( Home: Scaffold( appBar: AppBar( Title: const Text('Plugin example app'), ), Body: ListView( Children: <Widget>[ RaisedButton(child: const Text('set to Chinese'), onPressed: () { FlutterPluginTts.setLanguage('zh-CN').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('set to English'), onPressed: () { FlutterPluginTts.setLanguage('en-AU').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('set to Japanese'), onPressed: () { FlutterPluginTts.setLanguage('ja-JP').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('play Chinese'), onPressed: () { FlutterPluginTts.speak ('Hello, World'); }), RaisedButton(child: const Text('playing English'), onPressed: () { FlutterPluginTts.speak('hello,world'); }), RaisedButton(child: const Text('playing Japanese'), onPressed: () { FlutterPluginTts.speak('こんにちは, world'); }), RaisedButton(child: const Text), onPressed: () { FlutterPluginTts.speak('Hello, World. I am testing a long sentence. You can stop my play by clicking the play pause button below. If I don't stop it means there is still a problem with this stop function. Please Continue to repair. La la la la!'); }), RaisedButton(child: const Text), onPressed: () { FlutterPluginTts.stop(); }), RaisedButton(child: const Text('play pause, start new sentence immediately'), onPressed: () { FlutterPluginTts.stop(); FlutterPluginTts.speak('hello,world'); }), RaisedButton(child: const Text('Chinese usability'), onPressed: () { FlutterPluginTts.isLanguageAvailable('zh-CN').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('English usability'), onPressed: () { FlutterPluginTts.isLanguageAvailable('en-US').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('Japanese usability'), onPressed: () { FlutterPluginTts.isLanguageAvailable('ja-JP').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('setSpeechRate = 1'), onPressed: () { FlutterPluginTts.setSpeechRate(0.5); }), RaisedButton(child: const Text('setSpeechRate = 0.5'), onPressed: () { FlutterPluginTts.setSpeechRate(0.25); }), RaisedButton(child: const Text('setSpeechRate = 2'), onPressed: () { FlutterPluginTts.setSpeechRate(1); }), ], ), ), ); }
Welcome everyone to support my website [website] ( https://tryenough.com ),
中文文档
一个支持tts的flutter库
使用步骤:
导入库
import 'package:flutter_plugin_tts/flutter_plugin_tts.dart';
使用例子:
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Plugin example app'), ), body: ListView( children: <Widget>[ RaisedButton(child: const Text('设置成汉语'), onPressed: () { FlutterPluginTts.setLanguage('zh-CN').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('设置成英语'), onPressed: () { FlutterPluginTts.setLanguage('en-AU').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('设置成日语'), onPressed: () { FlutterPluginTts.setLanguage('ja-JP').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('播放汉语'), onPressed: () { FlutterPluginTts.speak('你好,世界'); }), RaisedButton(child: const Text('播放英语'), onPressed: () { FlutterPluginTts.speak('hello,world'); }), RaisedButton(child: const Text('播放日语'), onPressed: () { FlutterPluginTts.speak('こんにちは、世界'); }), RaisedButton(child: const Text('播放长句子'), onPressed: () { FlutterPluginTts.speak('你好,世界。我正在测试播放很长的句子,你可以点击下方的播放暂停按钮来终止我的播放,如果我没有停止那就意味着这个停止功能还有问题。请你继续修复。啦啦啦啦!'); }), RaisedButton(child: const Text('播放暂停'), onPressed: () { FlutterPluginTts.stop(); }), RaisedButton(child: const Text('播放暂停,立刻开始新句子'), onPressed: () { FlutterPluginTts.stop(); FlutterPluginTts.speak('hello,world'); }), RaisedButton(child: const Text('中文可用性'), onPressed: () { FlutterPluginTts.isLanguageAvailable('zh-CN').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('英文可用性'), onPressed: () { FlutterPluginTts.isLanguageAvailable('en-US').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('日文可用性'), onPressed: () { FlutterPluginTts.isLanguageAvailable('ja-JP').then((v){ debugPrint('r = $v'); }); }), RaisedButton(child: const Text('设置语速为1正常'), onPressed: () { FlutterPluginTts.setSpeechRate(0.5); }), RaisedButton(child: const Text('设置语速为0.5'), onPressed: () { FlutterPluginTts.setSpeechRate(0.25); }), RaisedButton(child: const Text('设置语速为2'), onPressed: () { FlutterPluginTts.setSpeechRate(1); }), ], ), ), ); }
欢迎大家支持我的网站网站,
热度: 3
以上所述就是小编给大家介绍的《Flutter tts全新库,亲测有效》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
谁说商业直觉是天生的
[美] 戴夫·帕特奈克 (Dev Patnaik)、[美] 彼得·莫特森 (Peter Mortensen) / 马慧 / 万卷出版公司 / 2010-07 / 36.00
《Wired to Care》是帕特奈克集近年来在创新顾问公司 Jump Associates 实务经验,与史丹佛大学教学经验之大成,虽然《Wired to Care》定位为一本用设计创新方法谈企业管理的书,但本书,活像是一本近代的设计史,从以销售为设计目标的Raymond Loewy谈起,到以人为设计中心的OXO GOOD GRIPSSwivelPeeler削皮刀。由此作者向我们揭示了企业如何运......一起来看看 《谁说商业直觉是天生的》 这本书的介绍吧!