Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Add audio to Web images
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
build
demos
lib
resources
src
.bowerrc
.gitignore
README.md
bower.json
gruntfile.js
package.json

README.md

Talking Image

Add audio to Web images

What is Talking Image?

Talking Image is a JavaScript library for playing audio appended to GIF, JPEG, and PNG images. Include the talking-image.min.js on a webpage with a talking image (image with appended audio) and hear the sound come alive.

Give me a quick demo!

Demos be here: http://hacksparrow.github.io/talking-image/

To see the demos from the repo, make sure you have Node.js installed on your system. Clone the repo and run the demo server to see the demos. Follow these instructions:

$ git clone git@github.com:hacksparrow/talking-image.git  
$ npm install  
$ node demos

Then load http://localhost:3000/demos.html.

If you don't want to clone the repo, download talking-image.min.js and the files from the demo/public directory and host them on any HTTP server of your own.

What is a talking image

Talking image refers to an image with an audio payload appended at the end of image data. Currently OGG and MP3 audio formats are supported.

How do I add talking images to my webpage?

You use the regular <img> tag but add an additional attribute called data-audio, in which you set the options. Eg: <img src="cool.gif" data-audio="autoplay loop">.

Options for the audio attribute

  1. autoplay - start playing the audio as soon as possible. If autoplay is not set, you will have to click on the image to start playing the sound.
  2. sync - try to sync the animation and the audio. There is no guarantee they will be in sync.
  3. loop - loop the audio
  4. volume - specify the volume. 1 for max volume. Eg: <img src="" data-audio="volume=0.5">

Note: You can click on the image to mute the audio any time you want.

Where can I find some talking images?

This project hosts some talking images in the public directory under the demos directory.

How can I create talking images?

The idea behind talking images is to append OGG or MP3 data to an existing image file - nothing more than that.

On Linux / Mac:

$ cat music.ogg >> funny.gif

or

$ cat beethoven.mp3 >> welcome.jpg

On Windows:

> copy /b funny.gif + music.ogg funny-music.gif

There are some 'clean' images and audio snippets in the resources directory, play around with it.

Note: Audio file should be appended to the image file to create a valid talking file. Reversing the order will generate a corrupted file.

Why is it called Talking Image?

Images on the Web have been 'mute' so far, the technique described here and the library add sound to Web images. The 'talking' in Talking Image comes from talkies.

Is it of any use?

Now you can enjoy the audio-visual experience of Nyan Cat for infinite hours without loading a YouTube video.

How does it work?

Using binary data in the browser powered by jDataView and jBinary.

License (MIT)

Copyright (c) 2012 Hage Yaapa <http://www.hacksparrow.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.