Skip to content

Commit

Permalink
support for Arabic and Hebrew on TTS widgets and addition of multi sp…
Browse files Browse the repository at this point in the history
…eed player widget
  • Loading branch information
justinhunt committed Mar 31, 2023
1 parent 4022576 commit 28a5a7f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Change List
=========
Version 3.1.64 (Build 2023033001)
- Support for Arabic and Hebrew on Text to Audio (cloud) and Passage Reader (cloud) widgets
- Support for Arabic and Hebrew on Poodll Audio Player widget
- Added multi speed player widget

Version 3.1.63 (Build 2023033000)
- fixed tabs and accordians widgets for Moodle4.x
- fixed custom course field fetching in filter using @@COURSE:customfieldshortname@@
Expand Down
1 change: 1 addition & 0 deletions presets/pw-multispeedplayer.txt
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":""}
2 changes: 1 addition & 1 deletion presets/textblockreader.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion presets/tta.txt
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 + '&region=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 + '&region=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":""}
5 changes: 5 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4945,4 +4945,9 @@ video.poodll_multivideoplayer_video {
.poodll_multivideoplayer .volume-control {
display: none;
}
}

.filter_poodll_rtl {
direction: rtl;
/* text-align: right; */
}
10 changes: 10 additions & 0 deletions templates/pw-poodllaudio.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@
app.loadVTT(app.options.vtt, function(captions) {
app.captions = captions;
});
//set right to left if necessary
switch(app.options.lang){
case 'ar-AE':
case 'ar-SA':
case 'fa-IR':
case 'he-IL':
$("#{{AUTOID}}_poodll-super-player-captions").addClass('filter_poodll_rtl');
break;
}
} else {
$("#{{AUTOID}}_poodll-super-player-captions").hide();
}
Expand Down Expand Up @@ -302,6 +311,7 @@
options.hasVtt = mediadetails.subtitlesurl ? true : false;
options.vtt= mediadetails.subtitlesurl; //"https://s3.amazonaws.com/poodll-audioprocessing-out-us-east-1/CP/365/jjustin/misc.poodll.com/21232f297a57a5a743894a0e4a801fc3/poodllfile5ec34af9814891.mp3.vtt",
options.audio= mediadetails.mediaurl;//"https://s3.amazonaws.com/poodll-audioprocessing-out-us-east-1/CP/365/jjustin/misc.poodll.com/21232f297a57a5a743894a0e4a801fc3/poodllfile5ec34af9814891.mp3",
options.lang=mediadetails.lang;
options.captions= [];
options.waveform= true;
options.hasImage= mediadetails.imgurl ? true : false;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023033000;
$plugin->version = 2023033001;
$plugin->requires = 2016052300;//moodle 3.1.0
$plugin->component = 'filter_poodll';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '3.1.63 (Build 2023033000)';
$plugin->release = '3.1.64 (Build 2023033001)';

0 comments on commit 28a5a7f

Please sign in to comment.