Lingua::Translator::Microsoft - A client library for the Microsoft Translator API
my $api_key = read_file('/home/myapp/priv/translator.priv'); my $translator = Lingua::Translator::Microsoft->new( api_key => $api_key, app_id => $app_id, ); say $translator->translate('nl', 'en', 'voorbeeld'); # outputs 'example' my $mp3 = $translator->speak('de', 'Worüber man nicht sprechen kann, darüber muss man schweigen'); open(my $fh, ">", "tractatus.mp3", {format => "mp3"}); print $fh $mp3; system("mplayer tractatus.mp3"); say $translator->detect("Ci vuole un fiore."); # outputs 'it'
This is a client library for Microsoft's translate service. Currently you can use the following calls from the API:
All API-calling methods croak() unless they get a successful reply from the service.
Instantiate a new Lingua::Translator::Microsoft object.
Arguments:
api_key [required]
The API key (client secret).
app_id [required]
Your application ID (client id). You need to register your application to be able to use the service.
auth_url [optional]
The URL to get the OAuth token from. Defaults to https://datamarket.accesscontrol.windows.net/v2/OAuth2-13. You probably don't need to change this.
api_url [optional]
The URL for the Microsoft Translator API (v2). Defaults to http://api.microsofttranslator.com/v2/Http.svc. You probably don't need to change this.
Returns:
A new Lingua::Translator::Microsoft instance.
Translate some text
source_language_code [required] (String)
target_language_code [required] (String)
text [required] (String)
The text to translate.
The translated text as a string.
Translate some text (with multiple results).
This function is sensitive to context. It returns an arrayref of translation in scalar context but a list of translations in list context.
options [optional] (Hashref)
A struct containing options to the call. For now the only option that you can put here is max_translations which limits the number of results to a given number. max_translations defaults to 5.
In list context the results as a list of strings (translations).
In scalar context an arrayref of strings (translations).
Pronounce some text
language_code [required] (String)
The text to synthetize.
A wav stream containing the text spoken in the chosen language.
Detect the language of a text.
The text to do language detection on.
The code of the detected language.
This module is written by Larion Garaczi <larion@cpan.org> (2016)
The source code for this module is hosted on GitHub https://github.com/larion/lingua-translator-microsoft.
Feel free to contribute :)
This module is free software and is published under the same terms as Perl itself.
To install Lingua::Translator::Microsoft, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::Translator::Microsoft
CPAN shell
perl -MCPAN -e shell install Lingua::Translator::Microsoft
For more information on module installation, please visit the detailed CPAN module installation guide.