User:IagoQnsi/ipareader.js

// powered by  // full list of voices at https://docs.aws.amazon.com/polly/latest/dg/voicelist.html

function loadConfig { var config = window.ipareaderConfig; if (typeof config === 'undefined') { config = {}; }	if (typeof config.voice === 'undefined') { config.voice = 'Salli'; }	return config; }

function speak(text, voice) { var requestData = { text: text, voice: voice }; $.ajax({		url: "https://iawll6of90.execute-api.us-east-1.amazonaws.com/production",		method: "POST",		contentType: "application/json",		data: JSON.stringify(requestData),		success: function(data) {			var uri = "data:audio/mpeg;base64," + data;			(new Audio(uri)).play;		}	}); }

(function {	var config = loadConfig;	mw.util.addCSS('.ipareader-play { cursor:pointer; margin-left: 0.25em; }');	$('.IPA').each(function { var button = $(' 🔈 '); $(this).append(button); button.click(function {			var text = $(this).parent.text;			speak(text, config.voice);		}); }); });