[add] Text_to_Speech
This commit is contained in:
parent
b1dffd1f6b
commit
587caaa9b4
@ -4,6 +4,6 @@
|
|||||||
"isPlugin": true,
|
"isPlugin": true,
|
||||||
"loadPluginInWeb": true,
|
"loadPluginInWeb": true,
|
||||||
"loadPluginInNative": true,
|
"loadPluginInNative": true,
|
||||||
"loadPluginInEditor": true,
|
"loadPluginInEditor": false,
|
||||||
"subMetas": {}
|
"subMetas": {}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ export default class Manager extends cc.Component {
|
|||||||
|
|
||||||
//#region private
|
//#region private
|
||||||
|
|
||||||
private _text_to_Speech: Text_to_Speech = new Text_to_Speech();
|
private _text_to_Speech: Text_to_Speech;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -24,6 +24,7 @@ export default class Manager extends cc.Component {
|
|||||||
|
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
let self: this = this;
|
let self: this = this;
|
||||||
|
this._text_to_Speech = new Text_to_Speech();
|
||||||
window.addEventListener("message", function (e: MessageEvent<any>): void {
|
window.addEventListener("message", function (e: MessageEvent<any>): void {
|
||||||
let data: any = e.data;
|
let data: any = e.data;
|
||||||
let method: string = data.method;
|
let method: string = data.method;
|
||||||
@ -73,7 +74,7 @@ export default class Manager extends cc.Component {
|
|||||||
console.log(msg);
|
console.log(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _speak(msg: string): void {
|
public Speak(msg: string): void {
|
||||||
this._text_to_Speech.speak(msg);
|
this._text_to_Speech.speak(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,30 @@
|
|||||||
|
const responsiveVoice = window["responsiveVoice"];
|
||||||
|
|
||||||
export default class Text_to_Speech {
|
export default class Text_to_Speech {
|
||||||
//#region 外調參數
|
//#region 外調參數
|
||||||
|
|
||||||
private _responsiveVoice: any = window["responsiveVoice"];
|
private voice: string = null;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Custom
|
//#region Custom
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._responsiveVoice.speak("hello world");
|
let self: this = this;
|
||||||
|
responsiveVoice.init();
|
||||||
|
var voicelist = responsiveVoice.getVoices();
|
||||||
|
this.setDefaultVoice(voicelist[14].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setDefaultVoice(voice: string): void {
|
||||||
|
this.voice = voice;
|
||||||
|
responsiveVoice.setDefaultVoice(voice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public speak(msg: string): void {
|
public speak(msg: string): void {
|
||||||
let self: this = this;
|
let self: this = this;
|
||||||
this._responsiveVoice.speak(msg, "Chinese Female", {
|
if (responsiveVoice.voiceSupport()) {
|
||||||
|
responsiveVoice.speak(msg, this.voice, {
|
||||||
onstart: function (Callback: any): void {
|
onstart: function (Callback: any): void {
|
||||||
console.log(`onstart msg: ${msg}`);
|
console.log(`onstart msg: ${msg}`);
|
||||||
},
|
},
|
||||||
@ -21,6 +32,9 @@ export default class Text_to_Speech {
|
|||||||
console.log(`onstart msg: ${msg}`);
|
console.log(`onstart msg: ${msg}`);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.error(`!responsiveVoice.voiceSupport`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user