Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions Assets/UAP/Plugins/WebGL/WebSpeechBridge.jslib
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
mergeInto(LibraryManager.library, {
SpeakWeb: function (strPointer, languageCodeStrPtr)
{
var str = UTF8ToString(strPointer);
var lang = UTF8ToString(languageCodeStrPtr);

//SpeakWeb: function (strPointer, languageCodeStrPtr, speakRate)
SpeakWeb: function (strPointer, languageCodeStrPtr)
{
// Create JavaSCript string from Unity's string pointer
var str = Pointer_stringify(strPointer);
var lang = Pointer_stringify(languageCodeStrPtr);
var msg = new SpeechSynthesisUtterance(str);
msg.lang = lang || 'en-US';
msg.volume = 1;
msg.rate = 1;
msg.pitch = 1.5;

var msg = new SpeechSynthesisUtterance(str);
msg.lang = lang; // 'en-US';
msg.volume = 1; // 0 to 1
msg.rate = 1;//speakRate; //1; // 0.1 to 10
msg.pitch = 1.5; //0 to 2
window.speechSynthesis.cancel();
window.speechSynthesis.speak(msg);
},

// Stop any TTS that may still be active
window.speechSynthesis.cancel();

window.speechSynthesis.speak(msg);
},

CancelSpeakWeb: function()
{
window.speechSynthesis.cancel();
},

IsSpeakingWeb: function()
{
return (window.speechSynthesis.speaking || window.speechSynthesis.pending);
}
CancelSpeakWeb: function() {
window.speechSynthesis.cancel();
},

IsSpeakingWeb: function() {
return (window.speechSynthesis.speaking || window.speechSynthesis.pending);
}
});