中化加油站项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.4 KiB

/**
*
*/
export class SpeakingTool {
private static instance: SpeakingTool;
static get Instance() {
if (SpeakingTool.instance == null) {
SpeakingTool.instance = new SpeakingTool();
}
return SpeakingTool.instance;
}
/**
*
*
* @param msg
*/
speak(msg: string) {
console.log("阅读" + msg);
if (this.isIE()) {
}
else {
this.clear();
let speakMsg = new SpeechSynthesisUtterance(msg);
speakMsg.lang = "zh-CN";
speakMsg.rate = 1;
speakMsg.pitch = 1.5;
window.speechSynthesis.speak(speakMsg);
return speakMsg;
}
}
/**
*
* @param speakMsg
*/
pause() {
window.speechSynthesis.pause();
}
/**
*
*/
resume() {
window.speechSynthesis.resume();
}
/**
*
*/
clear() {
window.speechSynthesis.cancel();
}
/**
* IE浏览器
*/
private isIE() {
// if ("ActiveXObject" in window) {
// console.log("IE 浏览器")
// return true;
// }
// else {
// return false;
// }
return false;
}
}