[add] Text_to_Speech

This commit is contained in:
2022-01-20 19:20:17 +08:00
parent ef23390d9a
commit 506d8b69e9
4 changed files with 730 additions and 11 deletions

View File

@@ -39,19 +39,15 @@ export default class Manager extends cc.Component {
cc.view.setResizeCallback(this._resize.bind(this));
this._resize();
setTimeout(() => {
if (this.webview.node.opacity === 0) {
self._closeBG();
}
}, 2000);
}
private _closeBG(): void {
this.BG.destroy();
this.webview.node.opacity = 255;
this.webview.node.active = false;
this.webview.node.active = true;
if (this.webview.node.opacity === 0) {
this.BG.destroy();
this.webview.node.opacity = 255;
this.webview.node.active = false;
this.webview.node.active = true;
}
}
private _log(msg: string): void {

View File

@@ -0,0 +1,36 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class Text_to_Speech extends cc.Component {
// LIFE-CYCLE CALLBACKS:
start(): void {
let self: this = this;
let url: string = window.location.search;
let request: object = [];
if (url.indexOf("?") !== -1) {
let str: string = url.substr(1);
let strs: string[] = str.split("&");
for (let i: number = 0; i < strs.length; i++) {
request[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
}
}
let ResponsiveVoice: any = responsiveVoice;
// var voicelist: any = ResponsiveVoice.getVoices();
// let voice: string = this.EditBox.string;
// let voice: string = "傻B豆豆";
let voice: string = request["voice"];
ResponsiveVoice.speak(voice, "Chinese Female", {
onstart: function (Callback: any): void {
// IsEnd = true;
self.node.getChildByName("Label").getComponent(cc.Label).string = voice;
},
// onend: function (Callback: any): void {
// // IsEnd = true;
// },
});
}
}