private void startAuto(String data) {
// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规
textToSpeech.setPitch(1.0f);
// 设置语速
textToSpeech.setSpeechRate(1.0f);
textToSpeech.speak(data,//输入中文,若不支持的设备则不会读出来
TextToSpeech.QUEUE_FLUSH, null);
}
private void initTTS() {
//实例化自带语音对象
textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == textToSpeech.SUCCESS) {
textToSpeech.setPitch(1.0f);//方法用来控制音调
textToSpeech.setSpeechRate(1.0f);//用来控制语速
//判断是否支持下面两种语言
int result1 = textToSpeech.setLanguage(Locale.US);
int result2 = textToSpeech.setLanguage(Locale.
SIMPLIFIED_CHINESE);
boolean a = (result1
Original: https://blog.csdn.net/qq_38998213/article/details/108627061
Author: ZhangJiQun&MXP
Title: android实现语音播报textToSpeech
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/526866/
转载文章受原作者版权保护。转载请注明原作者出处!