Free Text to speech using Google service

I was looking for some text to speech service to get good mp3 file for some text in my project and I found couple of paid services which are really great but having this as part time project I wouldn’t pay. So I kept looking and I found that Google provide text to speech service. just use the following url and pass the text as q parameter and url generate MP3 output which you can store and use it. http://translate.google.com/translate_tts?ie=utf-8&tl=en&q={text} There are also some PHP wrapper classes available which uitlize same service.

check out these links for more info

http://www.masnun.com/2009/12/14/googles-text-to-speech-api-a-php-wrapper-class.html

http://ctrlq.org/listen/

http://ctrlq.org/code/19147-text-to-speech-php

using javascript, you can also use audio class to play mp3 from web url like as follow.

var audio = new Audio();
audio.src ='http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=Hello%20World';
audio.play();
Advertisements

Export canvas drawing to image

Often you would like to export or save image generated on canvas.

here is simple script which does exactly the same.

to get string output to save image you can use stringOutput.

If you run following script you might get following error

Uncaught Error: SECURITY_ERR: DOM Exception 18

As browser can’t set cookies on file://, to run successfully you have to host file on web server.

var c = document.getElementById("sketch");
var dataString = c.toDataURL("image/png");
var index = dataString.indexOf( "," )+1;
var stringOutput = dataString.substring( index );
window.open(dataString);

Detect touch using js

use following function to detect touch supportive browser using javascript

function isTouchDevice() {
	   var el = document.createElement('div');
	   el.setAttribute('ongesturestart', 'return;');
	   return typeof el.ongesturestart === "function";
	}

Awesome wordpress ecommerce themes

Bootstrap is amazing font end framework with list of css and javascripts which allows designer to design amazing website with ease. During my previous project I was looking for boostrap based e-commerce templates which might suite for wordpress templates as well. Following templates which I fond really easy and to start with. You might think the same.

bootstrap_img_2

Click Here to download

bootstrap_img_3

Click Here to download

bootstrap_img_4

Click Here to download

bootstrap_img_5

Click Here to download

bootstrap_img_6

Click Here to download

bootstrap_img_9

Click Here to download

bootstrap_img_8

Click Here to download

bootstrap_img_10

Click Here to download

How to fire event using javascript

how to create custom event and fire using javascript

the following code shows how you can fire event using javascript by create event object and use either dispatchEvent or fireEvent function of DOM element to fire event.

function fireClickEvent(obj){
	var event;
	if(document.createEvent){
		event = document.createEvent("HTMLEvents"); // for chrome and firefox
		event.initEvent("click", true, true);
	}else{
		event = document.createEventObject(); // for IE
		event.eventType = 'click';
	}
	if(document.createEvent){
		obj.dispatchEvent(event); // for chrome and firefox
	}else{
		obj.fireEvent("on" + event.eventType, event); // for IE
	}
}