September 07, 2007

Make Your Computer Sing With Festival

Festival is a free speech synthesis system from The Centre for Speech Technology Research at The University of Edinburgh in Scotland. Besides doing typical Text to Speech tasks that most operating systems can do today, Festival has a special Singing mode, which can accept an XML input file full of words to sing, pitches, and durations. Here is an example from the documentation:

<?xml version="1.0"?>
<!DOCTYPE SINGING PUBLIC "-//SINGING//DTD SINGING mark up//EN" 
      "Singing.v0_1.dtd"
[]>
<SINGING BPM="30">
<PITCH NOTE="G3"><DURATION BEATS="0.3">doe</DURATION></PITCH>
<PITCH NOTE="A3"><DURATION BEATS="0.3">ray</DURATION></PITCH>
<PITCH NOTE="B3"><DURATION BEATS="0.3">me</DURATION></PITCH>
<PITCH NOTE="C4"><DURATION BEATS="0.3">fah</DURATION></PITCH>
<PITCH NOTE="D4"><DURATION BEATS="0.3">sew</DURATION></PITCH>
<PITCH NOTE="E4"><DURATION BEATS="0.3">lah</DURATION></PITCH>
<PITCH NOTE="F#4"><DURATION BEATS="0.3">tee</DURATION></PITCH>
<PITCH NOTE="G4"><DURATION BEATS="0.3">doe</DURATION></PITCH>
</SINGING>
I decided to create a song based on a Barbershop Quartet from a book in my collection. To do this, I created one XML file for each of the four parts and played them individually while recording them into an audio program. Then I combined them all into a single audio file. Voila! Here is the final product - a computerized version of the song M-O-T-H-E-R:

Mother.wav (6 MB)
Mother.m4a (580k, for iTunes and QuickTime)

Here are the XML files I created that were inputted into Festival:

mother1.xml
mother2.xml
mother3.xml
mother4.xml

Lyrics:

M is for the million things she gave me.
O means only that she's growing old.
T is for the tears were shed to save me.
H is for her heart of purest gold.
E is for her eyes with love-light shining.
R means right and right she will always be.
Put them all together they spell MOTHER,
A word that means the world to me.

NOTE: Keep in mind that only the source code for Festival is officially released. If you wish to use it, you will need to either build the binaries from the sources or find the binaries somewhere online. I was able to get the Windows binaries from a project called Flinger, which uses speech synthesis to sing based on a MIDI input. I did notice that Flinger did not include all of the configuration files needed for singing via an XML, so I had to also download the Festival sources and add them to my Flinger install. You might have to play around with it a little bit, but you should be able to get Festival/Flinger to sing from an XML file without too much trouble.

Posted by Chuck at 03:58 PM | Comments (0)

July 02, 2007

How to Convert a YouTube Video to an Animated GIF

With the right tools, it is very easy to convert a YouTube video to an animated GIF in a nearly automated way. This tutorial should work roughly the same way on any operating system as long as you have the required tools:

1. Make sure you have access to all the required tools. As far as command line tools go, you will need wget, grep, sed, and xargs. These come with almost all Linux installations, or on Windows, you can use Cygwin. In addition, you need to have MPlayer installed.

2. Create a script called youtube.sh on the file system with the following contents:

wget -q -O - http://www.youtube.com/watch?v=$1|grep "/watch_fullscreen?.*video_id=.*\&t="|sed "s/^.*\&t=//"|sed "s/\&.*//"|xargs -i wget -O $2 http://youtube.com/get_video?video_id=$1\&t={}

Make it executable by typing chmod +x youtube.sh

3. Find the YouTube video you would like to convert. Make sure it is short, as a 5 minute video will become an animated GIF that is about 36 MB. The URL for the video should look like the following:
http://www.youtube.com/watch?v=34Sb0hGUNIQ
Note the part after the ?v=, e.g. 34Sb0hGUNIQ. Copy this code to your clipboard or write it down.

4. Run the script as follows:

./youtube.sh 34Sb0hGUNIQ ducktales.flv

This will download the video to your computer in Flash Video format. The file will be called whatever you specified when you ran the script, e.g. ducktales.flv. Now we just need to use MPlayer to convert it to an animated GIF.

5. Do the conversion by typing:

./mplayer -vo gif89a ducktales.flv

It takes about as long as the video normally runs in order to finish converting. When it is done, there will be a new file in the same directory called output.gif. Try dragging it into a browser to see it run.

You have just successfully converted a YouTube video to an animated GIF! Click here to see the final output. Note that if it seems slow, it is most likely because the video (7.5 MB) is still loading.

Posted by Chuck at 03:51 PM | Comments (2)

June 06, 2007

Firefox, Gmail, and GPG Encryption with FireGPG

FireGPG is a FireFox extension that hooks into GPG to allow you to encrypt, decrypt, sign, and verify text in the browser using various encryption keys. Though it can work with any text in the Firefox browser, there are also special buttons that appear specifically in Gmail.

For those who don't know, GPG is a GNU version of PGP, which allows data to be encrypted and sign via public and private keys (among other features). GPG is command-line software, but FireGPG hooks it into Firefox in a completely graphical way.

The first step to getting started is to install GPG on your computer. It is available for many operating systems, and can be downloaded here. Make sure to download the binaries for your specific operating system. As an alternative to installing on a Windows machine, you can also install Cygwin and add the GPG package during the Cygwin installation.

Once GPG is installed, you should install FireGPG. The install is very similar to other Firefox extension installs. Make sure to restart the browser when you are finished.

Now that you have both pieces of software installed, you need to make sure that the Firefox extension has the proper path of your GPG install. In Firefox, go to Tools --> FireGPG --> Options. If you get a message about how GPG cannot be found, manually change the path in the options window to the 'gpg' (or gpg.exe in Windows) command in your filesystem. The other options can be left alone, though you can definitely edit them if you have a need.

Now that the Firefox extension is configured properly, we need to generate a private / public key combination for you. Once this is done, you can give other people your public key and they can encrypt messages and send them to you. Only you will be able to decrypt them since you have the private key (and the password you will create). In addition, you can sign a message with your private key and when you send it to others, they will be able to verify that it actually came from you with the public key.

From the command line (in Windows, click on Start --> Run and then type 'cmd' and click 'OK'), change to the GPG directory (in Windows, type:
cd "\Program Files\GNU\GnuPG"). Then, type 'gpg --gen-key'. Follow the instructions to generate your key. You can always hit Enter to accept the default, which is probably a good idea unless you know what you are doing. Make sure to enter your real name and email address. The comment on the key is optional. Once you finish following the prompts, your key will be stored in the GPG keystore. You can now close the command line window.

Now that you have your own key, you want to give others your public key so that they can send you messages. Open Firefox and go to Tools --> FireGPG --> Export, choose the key you just created and click OK. Your public key will be displayed in a new window. Copy the entire thing and paste it into an email, document, etc. in order to give your key to others.

Likewise, other people will most likely be giving their public keys to you so you can send them encrypted messages and verify their signature. To import a key, highlight it on a page in the browser. You can use my signature as an example. Right-click on the selection and choose FireGPG --> Import. Assuming the key is valid, you will see a message that it was imported successfully.

To send someone an encrypted message, highlight some text in the browser, right-click and choose FireGPG --> Crypt. A window will appear asking you to choose which public key. Choose the public key of the person you are sending the message. The encrypted text will appear. Copy the entire thing into your message and send it to them. If you are using Gmail, you can use the new buttons that appear while creating a message for encrypting, signing, etc.

If someone sends you an encrypted message with your public key, you can use your private key to decrypt it by highlighting the message, right-clicking, and choosing FireGPG --> Decrypt.

FireGPG also makes it very easy to sign messages and verify other messages that are signed. To sign a message with your private key, highlight the message, right-click, and choose FireGPG --> Sign. To verify a message that someone has signed with their private key, highlight the signed message, right-click and choose Verify. The window will then prompt you to choose the public key of the person that signed it. Assuming the message verifies, you will get a message saying the signature is valid.

Keep in mind that while FireGPG works great as is, it is still actively being developed, so new features and fixes should be released regularly. There is an active forum that people participate in for troubleshooting and bug reporting. For instance, users have requested to be able to sign and encrypt a message at the same time. In addition, many users do not like the command prompt windows that open and close quickly when using FireGPG with Windows.

As you can see, FireGPG makes it very easy to encrypt / decrypt and sign / verify messages in Firefox, as well as import public keys. Give it a try and you will see how easy it is to use FireGPG once it is installed. Feel free to send me a message using my public key to chuck at chuckcaplan d o t com and I will respond.

Posted by Chuck at 01:09 PM | Comments (0)


Powered by Movable Type 3.121