Homework 8 - AJAX Application




Explanation of AJAX

The script program or function in our local computer, named loadDoc, connects to or brings in (instantiates) a piece of a computer program (called an XMLHttpRequest object) that can talk to our remotely located web server (a place that stores, manages, and provides global access to information, in addition to performing useful tasks). This connection allows the script program that is running on our local computer to communicate with the web server that is likely quite far away (remote). This script sets up the connection to the server (via an open) in order to get a specific document from the web server that we want to see, and then the script asks the server to provide us with that document (send). In our case, the document is called hw8_cd_catalog.xml and contains music song titles and the author artist.

It takes a little time for the server to get our choosen document to us, so we asks our script, loadDoc, to notify us when the document is available for us to see (onload). We tell the loadDoc script how to inform us by defining access to another piece of computer script program (called myFunction).

When our requested document is available on our local computer, our loadDoc script calls our myFunction script and hands it (passes to it) the received document via a parameter (we've named xml). Through the parameter, myFunction can now see and access the document provided by the web server, and in our case here, with a click of a button, myFunction displays the information contained within the XML formatted document onto our computer screen for us to see.


REST API

IBM Watson Text To Speech
I chose this API example because it seemed simple to implement, with no strings attached, and it's an 'official' API from IBM.

(Jokingly, Ha Ha, I admit some bias here; I also chose this example because it contains my name, and actually I was initially trained on computers at IBM Corp., Kingston, NY, 1961, so there is a bit of nostalgia associated with my choice.)

However, based on my reading, I do believe this might be a good choice to perform simple text to speech translation. More research, analysis, and discussion is needed.

From online searching, I found the following statement:
"The IBM WatsonTM Text to Speech service provides APIs that use IBM's speech-synthesis capabilities to synthesize text into natural-sounding speech in a variety of languages, dialects, and voices. The service supports at least one male or female voice, sometimes both, for each language. The audio is streamed back to the client with minimal delay."

The request format is URI Query String/CRUD and response is XML and Audio. A Speech resource key for the endpoint is required.


Using a REST API (text to speech)

      

TODO FIXME - Coming, not so soon.

Above is my user interface; below is my design thought. One enters text and clicks Submit, the speech is then rendered to the user. I thought this would be simple before I started; now I'm not so sure (possibly I had an incorrect idea about this API); REST and JSON are all new to me. Anyway, from my research, the process is as follows:

  1. Create the resourse on the server that will produce the speech (see the API documentation for the necessary authorization and procedure). A REST POST authorization request and the text element to convert to speech is used for creation.
  2. Use GET to retrieve the XML Audio data based on the text that was passed to the server.
  3. During the retrival process one must continually send GET and monitor the returned status until a 200 OK (completed) or an error is received.
  4. Render the speech to the user.
The YouTube example at Calling a RESTful API from Java sheds insight to the process.

 

Go back to Homework main page