{"name":"Polly Pantheon","key":"ppa","version":"1.0.0","instructions":"Enter the text to be read in the text area. Choose a voice and hear it read","showatto":"1","showplayers":"0","requirecss":"","requirejs":"","shim":"","defaults":"format=\"text|ssml\"","amd":"1","body":"
\n
\n\n
\nPLAY
\n\nDownload","bodyend":"","script":"var langselect = $('#' + @@AUTOID@@ + '_language');\nvar voiceselect = $('#' + @@AUTOID@@ + '_voice');\nvar poodllfilelib = M.cfg.wwwroot + '/filter/poodll/poodllfilelib.php?datatype=speaktext¶mone=';\nvar thetextarea = $('#' + @@AUTOID@@+ '_textbox');\nvar thefilename = $('#' + @@AUTOID@@+ '_filename');\nvar theplaybutton = $('#' + @@AUTOID@@+ '_playbutton');\nvar thedownloadbutton = $('#' + @@AUTOID@@+ '_downbutton');\nvar theplayer = $('#' + @@AUTOID@@ + '_audioplayer');\nvar langoptiontemplate ='';\nvar voiceoptiontemplate ='';\n\nvar langvoices=[\n {\"lang\": \"English(US)\", \"voices\": [{name: 'Joey', mf: 'm'},{name: 'Kendra', mf: 'f'}]},\n{\"lang\": \"English(GB)\", \"voices\": [{name: 'Brian', mf: 'm'},{name: 'Amy', mf: 'f'}]}, \n{\"lang\": \"English(AU)\", \"voices\": [{name: 'Russell', mf: 'm'},{name: 'Nicole', mf: 'f'}]}, \n{\"lang\": \"English(IN)\", \"voices\": [{name: 'Aditi', mf: 'm'},{name: 'Raveena', mf: 'f'}]}, \n{\"lang\": \"English(WELSH)\", \"voices\": [{name: 'Geraint', mf: 'm'}]},\n{\"lang\": \"Danish\", \"voices\": [{name: 'Mads', mf: 'm'},{name: 'Naja', mf: 'f'}]}, \n{\"lang\": \"Dutch\", \"voices\": [{name: 'Ruben', mf: 'm'},{name: 'Lotte', mf: 'f'}]}, \n{\"lang\": \"French(FR)\", \"voices\": [{name: 'Mathieu', mf: 'm'},{name: 'Celine', mf: 'f'}]}, \n{\"lang\": \"French(CA)\", \"voices\": [{name: 'Chantal', mf: 'm'}]},\n{\"lang\": \"German\", \"voices\": [{name: 'Hans', mf: 'm'},{name: 'Marlene', mf: 'f'}]},\n{\"lang\": \"Icelandic\", \"voices\": [{name: 'Karl', mf: 'm'},{name: 'Dora', mf: 'f'}]},\n{\"lang\": \"Italian\", \"voices\": [{name: 'Carla', mf: 'f'},{name: 'Bianca', mf: 'f'},{name: 'Giorgio', mf: 'm'}]}, \n{\"lang\": \"Japanese\", \"voices\": [{name: 'Takumi', mf: 'm'},{name: 'Mizuki', mf: 'f'}]}, \n{\"lang\": \"Korean\", \"voices\": [{name: 'Seoyan', mf: 'f'}]},\n{\"lang\": \"Norwegian\", \"voices\": [{name: 'Liv', mf: 'f'}]},\n{\"lang\": \"Polish\", \"voices\": [{name: 'Jacek', mf: 'm'},{name: 'Ewa', mf: 'f'}]}, \n{\"lang\": \"Portugese(BR)\", \"voices\": [{name: 'Ricardo', mf: 'm'},{name: 'Vitoria', mf: 'f'}]}, \n{\"lang\": \"Portugese(PT)\", \"voices\": [{name: 'Cristiano', mf: 'm'},{name: 'Ines', mf: 'f'}]}, \n{\"lang\": \"Romanian\", \"voices\": [{name: 'Carmen', mf: 'f'}]},\n{\"lang\": \"Russian\", \"voices\": [{name: 'Maxim', mf: 'm'},{name: 'Tatyana', mf: 'f'}]}, \n{\"lang\": \"Spanish(ES)\", \"voices\": [{name: 'Enrique', mf: 'm'},{name: 'Conchita', mf: 'f'}]}, \n{\"lang\": \"Spanish(US)\", \"voices\": [{name: 'Miguel', mf: 'm'},{name: 'Penelope', mf: 'f'}]}, \n{\"lang\": \"Swedish\", \"voices\": [{name: 'Astrid', mf: 'f'}]},\n{\"lang\": \"Turkish\", \"voices\": [{name: 'Filiz', mf: 'f'}]},\n{\"lang\": \"Welsh\", \"voices\": [{name: 'Gwyneth', mf: 'f'}]}, \n];\n\n//init drop downs\n$.each(langvoices, function(index,voiceset){\n langselect.append(langoptiontemplate.replace(/@lang@/gi,voiceset.lang)); \n});\n//init events\n//play button event\ntheplaybutton.on('click',function(){\n var usetext = thetextarea.val();\n var usevoice = voiceselect.val();\n var audiourl = fetch_audiourl(usetext,usevoice);\n play_audio(audiourl);\n});\n\n//download button event\nthedownloadbutton.on('click',function(){\n var usetext = thetextarea.val();\n var uselang = langselect.val();\n var usevoice = voiceselect.val();\n var audiourl = fetch_audiourl(usetext,usevoice);\n var filename=thefilename.val() + '_' + uselang + '_' + usevoice;\n thedownloadbutton.attr('download',filename);\n thedownloadbutton.attr('href',audiourl);\n});\n\n//lang change event\nlangselect.on('change',function(){\n voiceselect.find('option').remove();\n var thelang =this.value;\n $.each(langvoices, function(index,voiceset){\n if(voiceset.lang==thelang){\n \n $.each(voiceset.voices, function(index,voice){\n var newoption =voiceoptiontemplate.replace(/@voice@/gi,voice.name);\n newoption = newoption.replace(/@mf@/gi,voice.mf);\n voiceselect.append(newoption); \n });\n } \n });\n});\n\n//set first item in lang to kick it all off\nlangselect.trigger(\"change\")\n\n//fetch audio url\nfunction fetch_audiourl(usetext,voice){\n//we replace tags with markers to survive going into a URL and out again\nusetext = usetext.replace(//gi, \"dddd\");\n\nvar datastring= @@format@@ + '|' + voice + '|' + usetext;\nvar audiourl = poodllfilelib+encodeURIComponent(datastring);\nreturn audiourl;\n}\n\n//play whatever\nfunction play_audio(audiourl){\n theplayer.attr('src',audiourl);\n theplayer[0].play();\n}","style":"","dataset":"","datasetvars":"","alternate":"","alternateend":""}