-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for Arabic and Hebrew on TTS widgets and addition of multi sp…
…eed player widget
- Loading branch information
1 parent
4022576
commit 28a5a7f
Showing
7 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"MultiSpeed Player Widget","key":"pw-multispeedplayer","version":"1.0.0","instructions":"Insert an audio player or audio link between the tags. The multi speed audio player will take over.","showatto":"1","showplayers":"0","requirecss":"","requirejs":"","shim":"","defaults":"","amd":"1","body":"<div id='@@AUTOID@@_container' style=\"display: none; max-width: 330px; width: 100%;\">\n<button onclick=\"SlowSpeed('@@AUTOID@@')\" type=\"button\"><img src=\"@@WWWROOT@@/filter/poodll/3rdparty/adamplayer/slowspeed.png\" alt=\"80% (Turtle)\">80%</button>\n<button onclick=\"RegularSpeed('@@AUTOID@@')\" type=\"button\"><img src=\"@@WWWROOT@@/filter/poodll/3rdparty/adamplayer/regularspeed.png\" alt=\"100% (Regular)\">100%</button> \n<button onclick=\"FastSpeed('@@AUTOID@@')\" type=\"button\"><img src=\"@@WWWROOT@@/filter/poodll/3rdparty/adamplayer/fastspeed.png\" alt=\"125% (Rabbit)\">125%</button><br />\n<audio id=\"@@AUTOID@@\" preload=\"meta\" controls=\"controls\" class=\"nomediaplugin\" >\n</audio>\n<div id=\"@@AUTOID@@_original\" style=\"display: none\">\n\n\n","bodyend":"</div>","script":"function parseMedia(containerid, mediatype) {\n var ret = {};\n ret.mediaurl = false;\n ret.lang = false;\n ret.subtitlesurl = false;\n ret.sources = false;\n ret.imgurl = false;\n\n //do we have an audio player?\n var originalplayer = $('#' + containerid + ' ' + mediatype).first();\n if (originalplayer.length === 1) {\n\n ret.lang = $('#' + containerid + ' ' + mediatype + ' track[kind=\"captions\"]').first().attr('srclang');\n ret.subtitlesurl = $('#' + containerid + ' ' + mediatype + ' track[kind=\"captions\"]').first().attr('src');\n\n if (originalplayer.attr('src') !== undefined) {\n ret.mediaurl = originalplayer.attr('src');\n } else {\n ret.mediaurl = $('#' + containerid + ' ' + mediatype + ' source').first().attr('src');\n }\n ret.sources = $('#' + containerid + ' ' + mediatype + ' source');\n\n\n //make sure moodle and poodll leave it alone from here on\n originalplayer.addClass('nomediaplugin');\n originalplayer.addClass('nopoodll');\n } else {\n\n //hopefully we have data attributes in the a link\n var originallink = $('#' + containerid + ' a').first();\n ret.mediaurl = originallink.attr('href');\n ret.lang = originallink.attr('data-lang');\n ret.subtitlesurl = originallink.attr('data-subtitles');\n ret.imgurl = originallink.attr('data-img');\n\n //but we might be in the old form where they were params on the url\n if (ret.subtitlesurl === undefined && ret.mediaurl.split('?').length > 0) {\n var urlParams = new URLSearchParams(ret.mediaurl.split('?')[1]);\n ret.subtitlesurl = urlParams.get('data-subtitles');\n ret.lang = urlParams.get('data-language');\n ret.mediaurl = mediaurl.split('?')[0]\n }\n\n //make sure moodle and poodll leave it alone from here on\n originallink.addClass('nomediaplugin');\n originallink.addClass('nopoodll');\n }\n\n //do we have an image\n if(!ret.imgurl) {\n var originalimg = $('#' + containerid + ' img').first();\n if (originalimg.length === 1) {\n ret.imgurl = originalimg.attr('src');\n ;\n }\n }\n\n return ret; \n }//end of parse function\n\n\nvar mediadetails= parseMedia(@@AUTOID@@ + '_original', 'audio');\n$('#' + @@AUTOID@@ + '_container').show();\n$('#' + @@AUTOID@@).attr('src', mediadetails.mediaurl);\n\n","style":"","dataset":"","datasetvars":"","alternate":"<audio id=\"@@AUTOID@@\" controls=\"controls\" class=\"nomediaplugin\">\n <source src=\"@@VIDEOURL@@\" type=\"audio/mpeg\">\n</audio>","alternateend":""} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"Text to Audio (Cloud)","key":"tta","version":"1.0.5","instructions":"Enter the text to be read between the 'tta' tags after they are inserted on the page. (Uses Cloud Poodll) ","showatto":"1","showplayers":"0","requirecss":"","requirejs":"","shim":"","defaults":"format=\"text|ssml\",language=\"English(US)|English(GB)|English(AU)|English(In)|English(Welsh)|Danish|Dutch|Dutch(BE)|French(FR)|French(CA)|German|Icelandic|Italian|Japanese|Korean|Norwegian|Polish|Portugese(BR)|Portugese(PT)|Romanian|Russian|Spanish(ES)|Spanish(US)|Swedish|Turkish|Welsh\",\nspeaker=\"Male|Female\"","amd":"1","body":"<audio id=\"@@AUTOID@@_audioplayer\" class=\"nomediaplugin\" controls/>\n<!-- @@CLOUDPOODLLTOKEN@@ -->\n<div id=\"@@AUTOID@@\" class='hide nolink'>","bodyend":"</div>","script":"//FUNCTION fetch polly url\n var fetch_polly_url = function(speaktext, voice, format, callback) {\n\n //The REST API we are calling\n var functionname = 'local_cpapi_fetch_polly_url';\n\n //fetch the Posturl. We need this.\n //set up our ajax request\n var xhr = new XMLHttpRequest();\n var that = this;\n\n //set up our handler for the response\n xhr.onreadystatechange = function (e) {\n if (this.readyState === 4) {\n if (xhr.status == 200) {\n\n //get a yes or forgetit or tryagain\n var payload = xhr.responseText;\n var payloadobject = JSON.parse(payload);\n if (payloadobject) {\n //returnCode > 0 indicates an error\n if (payloadobject.returnCode > 0) {\n console.log(payloadobject.returnMessage);\n return false;\n //if all good, then lets do the embed\n } else if (payloadobject.returnCode === 0){\n var pollyurl = payloadobject.returnMessage;\n callback(pollyurl);\n } else {\n console.log('Polly Signed URL Request failed:');\n console.log(payloadobject);\n }\n } else {\n console.log('Polly Signed URL Request something bad happened');\n }\n } else {\n console.log('Polly Signed URL Request Not 200 response:' + xhr.status);\n }\n }\n };\n\n //make our request\n var xhrparams = \"wstoken=\" + @@CLOUDPOODLLTOKEN@@\n + \"&wsfunction=\" + functionname\n + \"&moodlewsrestformat=\" + 'json'\n + \"&text=\" + encodeURIComponent(speaktext)\n + '&texttype=' + format\n + '&voice=' + voice\n + '&appid=' + 'filter_poodll'\n + '&owner=poodll'\n + '®ion=useast1';\n\n var serverurl = 'https://cloud.poodll.com' + \"/webservice/rest/server.php\";\n xhr.open(\"POST\", serverurl, true);\n xhr.setRequestHeader(\"Cache-Control\", \"no-cache\");\n xhr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\n xhr.send(xhrparams);\n };\n\n\nvar usetext = $('#' + @@AUTOID@@).text();\nvar theplayer = $('#' + @@AUTOID@@ + '_audioplayer');\nvar mf=@@speaker@@\n\nswitch(@@language@@){\ncase \"English(US)\": voice = mf=='Male'?'Joey':'Kendra';break;\ncase \"English(GB)\": voice = mf=='Male'?'Brian':'Amy';break;\ncase \"English(AU)\": voice = mf=='Male'?'Russell':'Nicole';break;\ncase \"English(IN)\": voice = mf=='Male'?'Aditi':'Raveena';break;\ncase \"English(WELSH)\": voice = mf=='Male'? 'Geraint':'Geraint';break;\ncase \"Danish\": voice = mf=='Male'?'Mads':'Naja';break;\ncase \"Dutch\": voice = mf=='Male'?'Ruben':'Lotte';break;\ncase \"Dutch(BE)\": voice = mf=='Male'?'nl-BE-Wavenet-B':'nl-BE-Wavenet-A';break;\ncase \"French(FR)\": voice = mf=='Male'?'Mathieu':'Celine';break;\ncase \"French(CA)\": voice = mf=='Male'?'Chantal':'Chantal';break;\ncase \"German\": voice = mf=='Male'?'Hans':'Marlene';break;\ncase \"Icelandic\": voice = mf=='Male'?'Karl':'Dora';break;\ncase \"Italian\": voice = mf=='Male'?'Carla':'Giorgio';break;\ncase \"Japanese\": voice = mf=='Male'?'Takumi':'Mizuki';break;\ncase \"Korean\": voice = mf=='Male'?'Seoyan':'Seoyan';break;\ncase \"Norwegian\": voice = mf=='Male'?'Liv':'Liv';break;\ncase \"Polish\": voice = mf=='Male'?'Jacek':'Ewa';break;\ncase \"Portugese(BR)\": voice = mf=='Male'?'Ricardo':'Vitoria';break;\ncase \"Portugese(PT)\": voice = mf=='Male'?'Cristiano':'Ines';break;\ncase \"Romanian\": voice = mf=='Male'?'Carmen':'Carmen';break;\ncase \"Russian\": voice = mf=='Male'?'Maxim':'Tatyana';break;\ncase \"Spanish(ES)\": voice = mf=='Male'?'Enrique':'Conchita';break;\ncase \"Spanish(US)\": voice = mf=='Male'?'Miguel':'Penelope';break;\ncase \"Swedish\": voice = mf=='Male'?'Astrid':'Astrid';break;\ncase \"Turkish\": voice = mf=='Male'?'Filiz':'Filiz';break;\ncase \"Welsh\": voice = mf=='Male'?'Gwyneth':'Gwyneth';break;\ndefault: voice = mf=='Male'?'Brian':'Amy';\n}\n\n\n//we replace tags with markers to survive going into a URL and out again\n//usetext = usetext.replace(/</gi, \"PPPP\");\n//usetext = usetext.replace(/>/gi, \"dddd\");\n\nvar datastring= @@format@@ + '|' + voice + '|' + usetext;\nvar format = @@format@@;\n\nfetch_polly_url(usetext,voice,format,function(audiourl){\n theplayer.attr('src',audiourl);\n }\n);\n\n","style":"","dataset":"","datasetvars":"","alternate":"","alternateend":""} | ||
{"name":"Text to Audio (Cloud)","key":"tta","version":"1.0.7","instructions":"Enter the text to be read between the 'tta' tags after they are inserted on the page. (Uses Cloud Poodll) ","showatto":"1","showplayers":"0","requirecss":"","requirejs":"","shim":"","defaults":"format=\"text|ssml\",language=\"English(US)|English(GB)|English(AU)|English(In)|English(Welsh)|Arabic|Danish|Dutch|Dutch(BE)|Farsi|French(FR)|French(CA)|German|Hebrew|Icelandic|Italian|Japanese|Korean|Norwegian|Polish|Portugese(BR)|Portugese(PT)|Romanian|Russian|Spanish(ES)|Spanish(US)|Swedish|Turkish|Welsh\",\nspeaker=\"Male|Female\"","amd":"1","body":"<audio id=\"@@AUTOID@@_audioplayer\" class=\"nomediaplugin\" controls/>\n<!-- @@CLOUDPOODLLTOKEN@@ -->\n<div id=\"@@AUTOID@@\" class='hide nolink'>","bodyend":"</div>","script":"//FUNCTION fetch polly url\n var fetch_polly_url = function(speaktext, voice, format, callback) {\n\n //The REST API we are calling\n var functionname = 'local_cpapi_fetch_polly_url';\n\n //fetch the Posturl. We need this.\n //set up our ajax request\n var xhr = new XMLHttpRequest();\n var that = this;\n\n //set up our handler for the response\n xhr.onreadystatechange = function (e) {\n if (this.readyState === 4) {\n if (xhr.status == 200) {\n\n //get a yes or forgetit or tryagain\n var payload = xhr.responseText;\n var payloadobject = JSON.parse(payload);\n if (payloadobject) {\n //returnCode > 0 indicates an error\n if (payloadobject.returnCode > 0) {\n console.log(payloadobject.returnMessage);\n return false;\n //if all good, then lets do the embed\n } else if (payloadobject.returnCode === 0){\n var pollyurl = payloadobject.returnMessage;\n callback(pollyurl);\n } else {\n console.log('Polly Signed URL Request failed:');\n console.log(payloadobject);\n }\n } else {\n console.log('Polly Signed URL Request something bad happened');\n }\n } else {\n console.log('Polly Signed URL Request Not 200 response:' + xhr.status);\n }\n }\n };\n\n //make our request\n var xhrparams = \"wstoken=\" + @@CLOUDPOODLLTOKEN@@\n + \"&wsfunction=\" + functionname\n + \"&moodlewsrestformat=\" + 'json'\n + \"&text=\" + encodeURIComponent(speaktext)\n + '&texttype=' + format\n + '&voice=' + voice\n + '&appid=' + 'filter_poodll'\n + '&owner=poodll'\n + '®ion=useast1';\n\n var serverurl = 'https://cloud.poodll.com' + \"/webservice/rest/server.php\";\n xhr.open(\"POST\", serverurl, true);\n xhr.setRequestHeader(\"Cache-Control\", \"no-cache\");\n xhr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\n xhr.send(xhrparams);\n };\n\n\nvar usetext = $('#' + @@AUTOID@@).text();\nvar theplayer = $('#' + @@AUTOID@@ + '_audioplayer');\nvar mf=@@speaker@@\n\nswitch(@@language@@){\ncase \"English(US)\": voice = mf=='Male'?'Joey':'Kendra';break;\ncase \"English(GB)\": voice = mf=='Male'?'Brian':'Amy';break;\ncase \"English(AU)\": voice = mf=='Male'?'Russell':'Nicole';break;\ncase \"English(IN)\": voice = mf=='Male'?'Aditi':'Raveena';break;\ncase \"English(WELSH)\": voice = mf=='Male'? 'Geraint':'Geraint';break;\ncase \"Arabic\": voice = mf=='Male'?'ar-XA-Wavenet-B':'Zeina';break;\ncase \"Danish\": voice = mf=='Male'?'Mads':'Naja';break;\ncase \"Dutch\": voice = mf=='Male'?'Ruben':'Lotte';break;\ncase \"Dutch(BE)\": voice = mf=='Male'?'nl-BE-Wavenet-B':'nl-BE-Wavenet-A';break;\ncase \"French(FR)\": voice = mf=='Male'?'Mathieu':'Celine';break;\ncase \"French(CA)\": voice = mf=='Male'?'Chantal':'Chantal';break;\ncase \"German\": voice = mf=='Male'?'Hans':'Marlene';break;\ncase \"Hebrew\": voice = mf=='Male'?'he-IL-Wavenet-B':'he-IL-Wavenet-A';break;\ncase \"Icelandic\": voice = mf=='Male'?'Karl':'Dora';break;\ncase \"Italian\": voice = mf=='Male'?'Carla':'Giorgio';break;\ncase \"Japanese\": voice = mf=='Male'?'Takumi':'Mizuki';break;\ncase \"Korean\": voice = mf=='Male'?'Seoyan':'Seoyan';break;\ncase \"Norwegian\": voice = mf=='Male'?'Liv':'Liv';break;\ncase \"Polish\": voice = mf=='Male'?'Jacek':'Ewa';break;\ncase \"Portugese(BR)\": voice = mf=='Male'?'Ricardo':'Vitoria';break;\ncase \"Portugese(PT)\": voice = mf=='Male'?'Cristiano':'Ines';break;\ncase \"Romanian\": voice = mf=='Male'?'Carmen':'Carmen';break;\ncase \"Russian\": voice = mf=='Male'?'Maxim':'Tatyana';break;\ncase \"Spanish(ES)\": voice = mf=='Male'?'Enrique':'Conchita';break;\ncase \"Spanish(US)\": voice = mf=='Male'?'Miguel':'Penelope';break;\ncase \"Swedish\": voice = mf=='Male'?'Astrid':'Astrid';break;\ncase \"Turkish\": voice = mf=='Male'?'Filiz':'Filiz';break;\ncase \"Welsh\": voice = mf=='Male'?'Gwyneth':'Gwyneth';break;\ndefault: voice = mf=='Male'?'Brian':'Amy';\n}\n\n\n//we replace tags with markers to survive going into a URL and out again\n//usetext = usetext.replace(/</gi, \"PPPP\");\n//usetext = usetext.replace(/>/gi, \"dddd\");\n\nvar datastring= @@format@@ + '|' + voice + '|' + usetext;\nvar format = @@format@@;\n\nfetch_polly_url(usetext,voice,format,function(audiourl){\n theplayer.attr('src',audiourl);\n }\n);\n\n","style":"","dataset":"","datasetvars":"","alternate":"","alternateend":""} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters