classroom/public/lessons/CertificateTest/js/certification_test.js
//This functions is called from everywhere ,to play TTS  

This functions is called from everywhere ,to play TTS
This functions is called from everywhere to play TTS
function playAudio(text, language) {
	console.log("in playAudio");
	text = text.toLowerCase().trim();
	temx = removeSpecialCharacter(text);
	text = text.replace("%","percent1");
	var processedText = decodeURI(text);
	processedText = processedText.replace("percent1","%");
	if(processedText in soundWords){
		processedText = soundWords[processedText];
	}
	stopAllAudio();
	var found = false;
	$(".audio").each(function(){
		if( removeSpecialCharacter($(this).attr("text").replace(/\s+/g, '')) == processedText.toLowerCase().trim().replace(/\s+/g, '')){
			if($(this)[0].duration > 0){
				$(this)[0].play();
			}else{
				$(this)[0].load();
				$(this)[0].play();
			}
			found = true;
			return false;
		}
	});
	if(!found){
		text=text.toLowerCase().trim();
		text=text.replace("%","percent1");
		var processedText = decodeURI(text);
		processedText = processedText.replace("percent1","%");
		var number = $('.audioDiv').children().size();
		$(".audioDiv").append('<audio class="audio audio'+number+'" text="'+processedText.toLowerCase().trim()+'" style="display:none;"><source class="source source'+number+'" src="" type="audio/mp3"></source></audio>');
		var x = $('.audio'+number)[0];
		var source = $('.source'+number);
		source.attr("src",'http://sound.culturealley.com/file/'+window.parent.defaultLocale+'/'+processedText);
		x.load();
		x.play();
	}
}
function playAudio ( text , language ) { console . log ( "in playAudio" ) ; text = text . toLowerCase ( ) . trim ( ) ; temx = removeSpecialCharacter ( text ) ; text = text . replace ( "%" , "percent1" ) ; var processedText = decodeURI ( text ) ; processedText = processedText . replace ( "percent1" , "%" ) ; if ( processedText in soundWords ) { processedText = soundWords [ processedText ] ; } stopAllAudio ( ) ; var found = false ; $ ( ".audio" ) . each ( function ( ) { if ( removeSpecialCharacter ( $ ( this ) . attr ( "text" ) . replace ( / \s+ / g , '' ) ) == processedText . toLowerCase ( ) . trim ( ) . replace ( / \s+ / g , '' ) ) { if ( $ ( this ) [ 0 ] . duration > 0 ) { $ ( this ) [ 0 ] . play ( ) ; } else { $ ( this ) [ 0 ] . load ( ) ; $ ( this ) [ 0 ] . play ( ) ; } found = true ; return false ; } } ) ; if ( ! found ) { text = text . toLowerCase ( ) . trim ( ) ; text = text . replace ( "%" , "percent1" ) ; var processedText = decodeURI ( text ) ; processedText = processedText . replace ( "percent1" , "%" ) ; var number = $ ( '.audioDiv' ) . children ( ) . size ( ) ; $ ( ".audioDiv" ) . append ( '<audio class="audio audio' + number + '" text="' + processedText . toLowerCase ( ) . trim ( ) + '" style="display:none;"><source class="source source' + number + '" src="" type="audio/mp3"></source></audio>' ) ; var x = $ ( '.audio' + number ) [ 0 ] ; var source = $ ( '.source' + number ) ; source . attr ( "src" , 'http://sound.culturealley.com/file/' + window . parent . defaultLocale + '/' + processedText ) ; x . load ( ) ; x . play ( ) ; } }
This functions is called from everywhere ,to play TTS
This functions is called from everywhere to play TTS
//console.log("play: "+text);
 //	var x = document.getElementById("audio"); 
 //	var source = document.getElementById("mp3_src");
 // source.src='http://voice.helloenglish.com/file/'+processedText;
 // x.load();
 //	x.play();
 //	var translatedWordlanguage = bcp47CodeForLanguage(language);
 //	var mySoundObject = soundManager.createSound({
 ////		url: "//mail.culturealley.com/ttsCultureAlley.php?tl="+translatedWordlanguage+"&q="+encodeURIComponent(processedText);
 //		url: "http://192.168.1.4:3000/file/"+encodeURIComponent(processedText),
 //		autoLoad: true,
 //		autoPlay: true,
 //		onload: function() {
 //			alert('The sound '+this.id+' loaded!');
 //		}
 //	});
