Commit adf14af8 authored by skeyboy's avatar skeyboy

tts语音适配iOS

parent 1610ec8c
...@@ -4,21 +4,15 @@ enum TtsState { playing, stopped, paused, continued } ...@@ -4,21 +4,15 @@ enum TtsState { playing, stopped, paused, continued }
class ChartTTS { class ChartTTS {
String voiceName; String voiceName;
String locale;
double volume; double volume;
double speechRate; double speechRate;
String language = "en-US"; String language = "zh-CN";
static ChartTTS tts = ChartTTS(); static ChartTTS tts = ChartTTS();
ChartTTS( ChartTTS({this.voiceName = "zh", this.volume = 1.0, this.speechRate = 1.0}) {
{this.voiceName = "Karen",
this.locale = 'en-AU',
this.volume = 1.0,
this.speechRate = 1.0}) {
flutterTts.setLanguage(language); flutterTts.setLanguage(language);
flutterTts.setVolume(volume); flutterTts.setVolume(volume);
flutterTts.setSpeechRate(speechRate); flutterTts.setSpeechRate(speechRate);
flutterTts.setVoice({"name": voiceName, "locale": locale});
} }
final FlutterTts _flutterTts = FlutterTts(); final FlutterTts _flutterTts = FlutterTts();
...@@ -160,17 +154,17 @@ class _MessageListState extends State<MessageList> { ...@@ -160,17 +154,17 @@ class _MessageListState extends State<MessageList> {
margin: const EdgeInsets.only(top: 20), margin: const EdgeInsets.only(top: 20),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
message.text, message.text,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
style: const TextStyle( style: const TextStyle(
color: Color.fromARGB( color: Color.fromARGB(
255, 170, 170, 194)), 255, 170, 170, 194)),
)), )),
const Icon( const Icon(
Icons.arrow_forward, Icons.arrow_forward,
color: Color(0xFF9c67f6), color: Color(0xFF9c67f6),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment