Monday, May 12, 2014

Mozilla on the New Mac :)

Hi,

After going through the Pico Service, the previous week had two major tasks :

> Testing the pico on my Linux Machine

> Setting up SAPI on the windows

Regarding the first part, I have tested Pico on my linux. Here are the steps if anyone wants to try :
Install Pico on your linux. It's a simple one-liner. After that

1. Set the LD_LIBRARY_PATH environment variable to wherever your libttspico.so is.
2. Set the PICO_LANG_PATH environment variable to wherever the language files are.

3. Add "ac_add_options --enable-synth-pico" to your .mozconfig, in the root directory.
4. Build the firefox again and then, set "media.webspeech.synth.enabled" to true in about:config.
This preference is present by default in the firefox and you have to create it. I have created Bug 1007834 so that the preference is present by default, and it will soon be included.


So, these are the steps that you need to follow. After that, you can test the api here.
You can also test this page with other browsers who have tts, and file bugs if they have any.
The second part was to get started with SAPI, Microsoft Speech API. The API provides a high-level interface between the application and speech engines. It implements all the low-level details needed to control and manage the real-time operations of various speech engines.
So, I began with setting up Sapi on my Windows 8 and have started with some basic programs to get familiar with sapi, which I'll be updating here : MS-SAPI-demo.
I haven't done any windows programming till now so it will take some extra effort and time to get familiar with COM (Component Object Model) and Win32 API, which is needed to get the most out of this api.

That's it for this week, and btw ! I got myself a new Mac :D

Cheers ! :)


Wednesday, May 7, 2014

Preparing to Code !


The current status is that, we already have the Pico Speech Synthesis Service on Gonk, i.e. the Firefox OS devices already have the synthesis via the pico engine.

After discussing with my mentor, Eitan Isaacson, my first step in the project, was to study the implementation of Pico service, to get inspiration for the future work.

After spending some time on the service, I have understood the basic workflow of the process. In this post, I would be explaining, or rather documenting the same, so that it helps in the future.


For any OS, Desktop support should be implemented as nsISpeechService and nsISpeechTaskCalback. When speak() is called on that interface, it is provided with a nsISpeechTask object that has methods for doing all the things that we would want to do. 

Following are the Pico specific classes:

nsPicoService :> our main service, subclasses nsISpeechService.


PicoCallbackRunnable :> a runnable class that subclasses nsISpeechTaskCallback.

Helper Classes : 


PicoApi :> acts as a wrapper for us and directly interacts with the pico library.

PicoVoice :> handles the voices


PicoSynthDataRunnable :> a runnable class that is used to send the synthesized data back to the browser.


The functions of the all the classes are defined in the following workflow:

The browser calls the speak method of the nsPicoService, with a reference to the nsISpeechTask object, along with four other parameters : text to utter, a unique voice identifier, rate to speak voice and the pitch.


The service then instantiates a new PicoCallbackRunnable object by pasing all these parameters, along with itself, and obtains a reference to that object.

Then, the PicoCallbackRunnable is executed on a new worker thread. In this process, all the text is fed to the engine in buffers of specified size and the output data from the engine is received in chunks.


These chunks are then sent to the DispatchSynthDataRunnable method. This method implements PicoSynthDataRunnable class.
This runnable is then executed on the main thread again, and it sends the synthesized data back to browser, using the functions of the nsISpeechTask object, passed to it.     


The nsPicoService is also used for other utility functions, such as, to initialize the PicoApi class, to register the voices and to load/unload the pico engine(this is done via PicoApi class ofcourse).

This is it for this week. Next week, my aim would be to test the Pico service and with that, start with the windows.

Cheers !