| Machine Transal...'s profileMachine Translation - th...PhotosBlog | Help |
|
October 09 Translating using the Bing Api/Traduzindo usando a Api do BingVery few people know that anyone can write code using our translation Api, and even fewer know about the interface available in the Bing Api. I’ll use the later for this next sample: an ASPX page that invokes the translation services, show the result and then invokes the Speech feature from the client (using Javascript). Let’s start with the basics: the Bing Api offers tons of services, and anyone can use it - all you need to to is apply for an AppId. Follow the instructions at http://www.bing.com/developers/appids.aspx and you’ll get one immediately. Once you have your shiny new code, you can then start playing with the many (many) samples available at http://msdn.microsoft.com/en-us/library/dd251056.aspx. It’s a quite powerful Api, and it works really well. For the sake of this project we’ll only use the Translate methods. There are three “flavors” of protocols available: JSON, XML and SOAP. the XML protocol is really simple: it’s basically a REST implementation that returns a Xml as response. As any REST interface, you can even invoke it from the browser. For example: ,returns (This AppId is registered to H2KTech, so please get your own) As you can see, the result is a very simple Xml that can be loaded and parsed very easily. MSDN has a pretty good example that I copied and modified for this sample application: http://msdn.microsoft.com/en-us/library/dd877832.aspx. This application is also very simple, and I even kept the Javascript Speech interface code (I think it’s pretty neat that it runs totally asynchronously from the rest of the page). The code is available here: http://www.h2ktech.net/h2ktechsamples/TranslateUsingBingSpeechSample.txt, and the application here: http://www.h2ktech.net/h2ktechsamples/TranslateUsingBingSpeechSample.aspx Looking at the code you’ll notice that querying the translation services is really simple: just format the url string correctly and open an Http request:
The response comes in the form of a Xml formatted string, so it’s ready to be loaded into a XmlDocument object. After that, just add the namespace and you’re ready to parse it:
Note that I’ve hooked the call to the Search Api to the OnClick handler, so the response will be blocked until we get a result back – and this is bad. However, for the sake of this exercise it doesn’t hurt much. Once we have the translation results, we populate the text box and return. The client Javascript code will then detect that the text box is not empty and invokes the Speech service using the Active X inside the IFrame, just like in the previous sample. I didn’t add any checks for exceptions, so if the results text box is populated with an error message funny things will certainly happen :-). Cheers, Helvecio English - Portuguese October 08 A simple ASP Translate to Speech Application/Um exemplo de Traducao com Voz em ASPSo here is a first sample application using the new service. It’s a really basic Javascript client that doesn’t do much more than formatting a string with the url and the correct parameters to invoke the T2S feature. The only thing that is remotely interesting is that this string is passed directly to the Media Player Active X, so there’s no extra work to play the wave file. You can play with the app here: http://www.h2ktech.net/h2ktechsamples/Translate2SpeechSample.aspx (by the way, I’ll be posting all new samples to this very same location). You can ‘view source’ to check the code, or simply download it from the text file: http://www.h2ktech.net/h2ktechsamples/Translate2SpeechSample.cs.txt The two Javascript functions work as follows:
Here’s a good reference on embedding Media Active X controls: http://cit.ucsf.edu/embedmedia/step3.php Give it a try, and feel free to play with the code – just don’t use it for any commercial application alright? Cheers, English - Portuguese October 07 Making the case for Text-to-Speech Integration with Machine Translation/Integrando Sintese de Voz ‘a Traducao AutomaticaSo my new personal project is taking shape, but as I mentioned in my previous post it will probably take a long time before there’s any real product implementation of a Speech-to-speech translator. That said, I believe there’s nothing preventing us from seriously integrating Text-to-Speech with our current offerings. For the few of you that have been following this blog – yes, I know it’s not a new concept. The first TBot even had it implemented somehow (see http://mtbotprototype.spaces.live.com/blog/cns!3F1A4578DEE8B!376.entry ). Unfortunately, it takes a while to create momentum to push for ideas. The circumstances have changed since February 2008, and now I believe it’s time to start pushing – our team now has open APIS for translations (http://msdn.microsoft.com/en-us/library/dd576287.aspx), more languages and a heck of a lot more hits daily. Since we’ve already reached out and offered developers and webmasters/blog owners ways to incorporate MT to theirs sites or products, offering a way to add Translated TTS seems like a natural progression. So I’m putting my money where my mouth is (literally) and I’ve acquired a domain to host some of my prototypes. The first is a simple ASPX page that works similar to our Http Translate method – you invoke it thru a url that takes query parameters. The utility translates the sentence and then returns a wave file back to the caller. It even works directly from the browser, so anyone can add links to invoke the service – like these: or For now I’m only offering 4 languages – English, French, Spanish and German (en, fr, es, de). If there’s interest in the service I’ll try to add more languages. Hopefully people out there will build interesting applications using the utility (attention mobile developers: it doesn’t get any easier to integrate than that!) , and help build the case for TTS. On my side, I’ll keep pushing for adoption: I honestly believe that all of our offerings should offer something similar to that... Enjoy the new free service! Cheers,
English - Portuguese |
|
|