You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Michele Cella <mi...@gmail.com> on 2005/10/25 15:00:46 UTC
[Announce] speaking-portlets 1.0
Hi list,
In the last few weeks I've been working on implementing text to speech
support for velocity portlets as part of a project for one of my classes.
As outlined in my previous email [1] I decided to implement a convenient
framework based upon velocity and easily deployable as a single war
application, trying to be as unobtrusive as possible in respect to
jetspeed internals.
First of all I decided to compress the audio data in Speex audio format
[2] using the java implementation provided by Jspeex [3], this codec is
designed for speech applications and guarantees small bandwidth
occupation and pretty good quality.
I also wanted to provide the ability to reproduce the audio content
directly from the browser without the need of external players plugins,
so I developed a playback applet that uses javax.sound.* api and is
therefor easily extensible to support others formats thanks to spi
plugins, unfortunately not all JVMs allow applet to extend the sound
api, my implementation uses a workaround for such JVMs. The appplet does
not present any gui on the web page, it's behavior it's entirely
controlled by calling public methods from javascript.
The text to speech generation it's abstracted by a trivial TextToSpeech
Spring service, my implementation uses the FreeTTS speech synthesizer
engine and, again, Jspeex to compress the generated audio.
Finally the audio content it's streamed to the applet by a servlet.
From a portlet point of view, taking advantage of this framework it's
IMO quite simple, the portlet only needs to extend the
GenericVelocitySpeakingPortlet class to get the playback control decorator:
public class HelloWorldSpeakingPortlet extends
GenericVelocitySpeakingPortlet {
To define the text to speech it should provide an opportune velocity
template and declare it as TextToSpeechTemaplete under it's portlet.xml:
<init-param>
<name>TextToSpeechTemplate</name>
<value>/WEB-INF/view/helloworld-tts.vm</value>
</init-param>
Finally the portlet needs to properly populate the velocity context
(both for tge TextToSpeechTemplate and the ViewPage) on its doView() method.
public void doView(...) {
response.setContentType("text/html");
Context velocityContext = this.getContext(request);
velocityContext.put("message", "Hello World!");
super.doView(request, response);
}
The portlet should always call super.doView() under its doView() and
eventually super.processAction() under its processAction().
You want a customized playback control decoration for a certain portlet?
you can define it with another parameter under portlet.xml:
<init-param>
<name>PlaybackControlDecorator</name>
<value>/WEB-INF/view/mydecorator.vm</value>
</init-param>
To make the custom decorator you can take a look at the default one
(WEB-INF/view/private/playback-control.vm) and reuse the existing
velocity macros that I have already defined.
Source and a compiled war file are available here:
http://www.ce.unipr.it/~cella/jetspeed2/
Excuse me if they are so big (), unfortunately I need to bundle FreeTTS
libraries since there is no maven repository for it (or maybe I couldn't
find it).
To deploy the application you should simply put the war file on your
webapps directory, jetspeed will pick it up and register the portlet
application, at the moment there only a simple Hello World sample
portlet, you can add it to your page as:
speaking-portlets::HelloWorld
Here you can find a screenshot:
http://www.ce.unipr.it/~cella/jetspeed2/speaking-portlets.png
I'm releasing my code under the apache license.
FreeTTS uses a BSD-like license [5].
Speex uses the Xiph.org variant of the BSD license [6].
JSpeex uses a BSD license.
Sorry for this so looong email, I hope you appreciate what I've done and
maybe can find it useful.
Ciao
Michele
[1] http://tinyurl.com/92bw8
[2] http://www.speex.org/
[3] http://jspeex.sourceforge.net/
[4] http://freetts.sourceforge.net/
[5] http://freetts.sourceforge.net/license.terms
[6] http://www.xiph.org/licenses/bsd/speex/
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org