Hello World in pdfLaTeX

After many years being silent, TeX can now talk! Almost minimal code below! It should be of particular interest to Physicists and Cosmologists. Need to have Adobe Reader installed.

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[scaled =.92]{helvet}
\setlength{\paperwidth}{5.2075in}
\setlength{\paperheight}{4.90in}
\renewcommand*{\familydefault}{phv}
\usepackage[pdftex,margin=0.5in]{geometry}
\usepackage{soul}
\usepackage{fancyhdr}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[pdftex,pdfpagelayout=SinglePage,
]{hyperref}
\definecolor{background}{rgb}{0.99,0.98,0.90}
\pagecolor{background}
\setlength{\parindent}{0.0cm}
\usepackage[pdftex]{insdljs}

\begin{insDLJS}[test]{test}{JavaScript}
function Hello()
{
var cSpeaker = tts.getNthSpeakerName(0);
tts.speaker = cSpeaker;
tts.qText ("Hello, Tex Stack Exchange. Helloooo, can anybody hear me? Helloooo?");
tts.talk();
}

function HelloWorld()
{
var cSpeaker = tts.getNthSpeakerName(0);
tts.speaker = cSpeaker;
tts.qText ("Hello, Tex Stack Exchange. Helloooo, can anybody hear me?");
tts.qText("This is a new and alien TeX world.");
tts.talk();
}

function WhatsUp()
{
var cSpeaker = tts.getNthSpeakerName(0);
tts.speaker = cSpeaker;
tts.qText ("Humans are not proud of their ancestors, and rarely invite them round to dinner.");
tts.qText("What\'s up?");
tts.talk();
}

function Universe()
{
var cSpeaker = tts.getNthSpeakerName(0);
tts.speaker = cSpeaker;
tts.qText ("In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.In those days spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri. There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened. I am Douglas Adams");
tts.qText("Who are you? I may be a sorry case, but I don't write jokes in base 13");
tts.talk();
}

\end{insDLJS}

%% This must be here
\OpenAction{/S/JavaScript/JS(Hello();)}

%% Short hand commands
\newcommand{\textforlabel}[2]{%
\TextField[name={#1}, value={#2}, width=9em,align=2,%
bordercolor={0.990 .980 .85},%
}

\begin{document}
\phantom{0}
\begin{center}
\vspace{2cm}
\textbf{\Huge Hello World!\\[0.2cm] Can you hear me?}
\end{center}
\vfill
\newpage

\begin{Form}
\begin{center}
%% Push button is defined here
\PushButton[name=hello,%
onclick={HelloWorld();}, bordercolor={0.650 .790 .94}%
]{Hello World!}
\\[10pt]

\PushButton[name=hello,%
onclick={WhatsUp();}, bordercolor={0.650 .790 .94}%
]{What's Up?}
\\[10pt]

\PushButton[name=hello,%
onclick={Universe();}, bordercolor={0.650 .790 .94}%
]{What's with the Universe?}
\\[2cm]
\end{center}
\end{Form}

\end{document}


On a more serious note, does (all)TeX have a place in the "new" media?

-
Not that I want to spoil the fun, but what exactly is the question here? – Caramdir Jan 13 '11 at 23:10
@Yiannis: There are packages to typeset music. What about adjoining to these the possibility of playing the music that is typeset? – Bruno Le Floch Jan 14 '11 at 12:46
@Bruno Le Floch: TeX itself typesets text, so should it also be a text-to-speech reader? External utilities do that, as they should. I would think that score-to-music is significantly easier, since the notation is totally unambiguous and highly structured, so can't the same (or similar) utilities do this as well? – Ryan Reich Jan 14 '11 at 13:24
@Ryan Reich: TeX is (among other things) about placing text in the most pleasing way. Couldn't similar algorithms (or the same) be used to decide the time between two words, sentences, etc, instead of the spacing that TeX usually caters for? – Bruno Le Floch Jan 14 '11 at 16:04
@Bruno Le Floch: Oh, I see. That is an interesting idea for adapting the spacing algorithm. Just create a tonal "font" with chords interpreted to be words, and assign a space factor of the appropriate fraction to tones of various lengths. It would be up to the composer/author not to write "words" with tones of different lengths, though I don't see off the top of my head how to get chords in which one note hangs while the others change. Perhaps this should be implemented as box widths instead... – Ryan Reich Jan 14 '11 at 16:45

TeX is designed to solve a single problem: setting letters into words into lines into paragraphs into pages, interspersed with mathematics and with displays or inserts of various kinds. To facilitate the automation of this task in a variety of unanticipated circumstances, it provides a complete (if obtuse) programming language with many hooks into the typesetting functions with which it operates. The fact that this language is Turing-complete leads enthusiastic people to claim that TeX can do anything, but this is not true: the task in question must be capable of description in this language. By virtue of the hooks, those tasks include typesetting, but the only facilities provided for other tasks are: the \special command and the very limited input/output commands (particularly \write18). Effectively, TeX allows other kinds of programming applications only through the wholesale importation of external utilities.
I think it's a mistake to try to make TeX do more than it is designed to be easily capable of doing, and a mistake to try to insert new features into that design. For example, hyperref works because one can use \special simply to feed information to the viewer, but it would be silly to try to use some kind of Javascript program to rewrite the document in accordance with a hyperlink. The reason is that TeX thinks of a document as being a finished product, and so "runtime" operations are not even considered. This is necessary for the problem of typesetting ever to be solved. Of course, if your Javascript has no runtime effect on the document it can be embedded via \special, but since that is already possible I doubt it is the question. Whether it is a matter of practicality or of good taste...my opinion was already given in the first sentence.