importPackage(android.speech.tts);
importClass(java.util.Locale);
tts = new TextToSpeech(context, function(status) {
if (status != tts.SUCCESS) {
tLogtoast("初始化TTS识别: " + status);
exit();
}
var r = tts.setLanguage(Locale.CHINA);
if (r < 0) {
tLogtoast("不支持该语言: " + r);
exit();
}
toastLog("TTS初始化成功");
});
function 说(text, cb) {
threads.start(() => {
sleep(33)
tts.speak(text, TextToSpeech.QUEUE_ADD, null);
while (tts.isSpeaking()) {}
toastLog('说完了');
sleep(66)
click(device.width / 2, device.height / 2)
sleep(666)
back()
cb && cb();
})
}
events.on("exit", function() {
if (tts) {
tts.shutdown();
tts = null;
}
});
while (1) {
a = text('请按键,说出语音内容领红包').findOnce()?.parent();
if (a) {
txt = a.child(1).text()
说(txt)
sleep(111)
p = a.findOne(desc('录制按钮,长按开始录制')).bounds()
x = p.centerX()
y = p.centerY()
press(x, y, 60000)
}
}
setInterval(() => {}, 666666);