Google Translate API - English subscripts to translated script - google-api

I am trying to convert English to Hindi via Google's API but I also need the English translation of the Hindi string.
To illustrate, if I convert
"a quick brown fox...."
to Hindi , it reads
"फुर्तीली भूरी लोमड़ी आलसी कुत्ते के उपर से कूद गई।"
But if you look at the web interface, Google also translates the Hindi version as
"phurtilee bhoori lomdi ..".
This doesn't show up in the response format of Translate API. I tried searching all their docs but this is all I got https://cloud.google.com/translate/docs/reference/translate#translatetextresponsetranslation and it just has a translated text in the response.

Google Translation API does not currently offer phonetic translation, despite being available in the web interface.
You can file a request for that feature to be included in the API by following the procedure explained in this forum where your same question is made.

Related

Using Google's API to split string into words?

I'm trying to figure out which API I should use to get Google to intelligently split a string into words.
Input:
thequickbrownfoxjumpsoverthelazydog
Output:
the quick brown fox jumps over the lazy dog
When I go to Google Translate and input the string (with auto-detect language) and click on the "Listen" icon for Google to read out the string, it breaks up the words and reads it out correctly. So, I know they're able to do it.
But what I can't figure out is if it's the API for Google Translate or their Text-To-Speech API that's breaking up the words. Or if there's any way to get those broken up words in an API response somewhere.
Does anyone have experience using Google's APIs to do this?
AFAIK, there isn't an API in Google Cloud that does that specifically, although, it looks like when you translate text using the Translation API it is indeed parsing the concatenated words in the background.
So, as you can't use it with the same source language as the target language, what you could do is translate to any language and then translate back to the original language. This seems a bit overkill though.
You could create a Feature Request to ask for such a feature to be implemented in the NLP API for example.
But, depending on your use case, I suppose that you could also use the method suggested in this other Stackoverflow Answer that uses dynamic programming to infer the location of spaces in a string without spaces.
Another user even made a pip package named wordninja (See second answer on the same post) based on that.
pip3 install wordninja to install it.
Example usage:
$ python
>>> import wordninja
>>> wordninja.split('thequickbrownfoxjumpsoverthelazydog')
['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']

translate language in image preserving structure

we are looking to translate images found in pdf documents from different languages to english.
they are scanned images and many times have tables or some structure in them.. we would like to translate to English but preserve the structure of document as much possible. Hence just a pure text based translation doesn't suffice.
we saw the Google translate app on Android which seems to do something similar with photos on phone..is there a Google cloud api which does the same?
In order to do this over the Google cloud , which api should we use, can you point us to the api an documentation that does this...
thanks
Using Google Cloud products, you can achieve this using an OCR to extract text and translate API to translate the text to English.
I suggest to use Document AI for OCR since the API is designed to parse forms and tables. You can check Document AI Table parsing and Document AI Document parsing for examples on how to use the API. Using the extracted text, you can use Translate API to translate the extracted text.
High level steps:
Use Document AI to extract data from pdf files
Use Translate API to translate the extracted data to English

How can I change the pronunciation of a specific word by Alexa in a custom skill?

Sometimes, when developing an Alexa skill and programming the responses from my service, Alexa mispronounces one of the words in my reply, confusing the user.
For example, if I wanted Alexa to say a word, let it be live, how can I tell Alexa how to pronounce the word correctly because there exist two pronunciations for live.
Is there a way to dictate to Alexa the correct pronunciation, or replace it with a custom sound that is correct? Do I need to use additional markup or an API call?
Alexa supports SSML, which is an XML-like markup language for speech. Instead of returning plain text from your service, you can use SSML responses. The <phoneme> tag is what you need in particular:
phoneme
Provides a phonemic/phonetic pronunciation for the contained text. For example, people may pronounce words like “pecan” differently.
For English words (especially US English), Alexa should be able to pronounce any word if you give it the correct phonetic pronunciation:
The following tables list the supported symbols for use with the phoneme tag. These symbols provide full coverage for the sounds of US English. Note that many non-English languages require the use of symbols not included in this list, which are not supported. Using symbols not included in this list is discouraged, as it may result in suboptimal speech synthesis.
Quotes from Amazon documentation on SSML.
Here's an example of giving Alexa a specific pronunciation for your word live:
<speak>
<phoneme alphabet="ipa" ph="lɪv">live 1</phoneme>.
<phoneme alphabet="ipa" ph="laɪv">live 2</phoneme>.
</speak>
The <phoneme> tag supports the IPA and X-SAMPA phonetic alphabets. You can typically find IPA spellings for any word on Wiktionary or through Google.
For longer messages, it may be best to use the <audio> tag and record a custom voice:
The audio tag lets you provide the URL for an MP3 file that the Alexa service can play while rendering a response. You can use this to embed short, pre-recorded audio within your service’s response. For example, you could include sound effects alongside your text-to-speech responses, or provide responses using a voice associated with your brand.
Quoted from Amazon documentation on <audio>.

Microsoft Cognitive Serivces Bing News API how to search multiple languages in 1 query

I am attempting to use the V5 Bing News API. On the documentation here (https://msdn.microsoft.com/en-us/library/dn760793.aspx#news) it shows that for multiple language searches, you would specify the Accept-Language in the header, and the cc field in the query.
So for example if I want both French and English results, from both US and France, I did:
Accept-Language: fr,en
cc=FR,US
But this is not working. This only returns US/English results. If I remove the US/English portion, I would get french results.
What am I doing wrong?
You can only get results from one language per API call. If you want to get results for multiple languages for the query, then you need to call the API twice passing the appropriate headers/params to customize the language.

Youtube Api v3 restricting result in one language

Is there any way to restrict to get result from youtube in one language? My code is almost working nice but it returns some videos that has title or description in other language. For example in Turkish we have word "iş" means work or "aşk" means love. Youtube returns some videos including in its title/description "is","ask". We have speacial charachter in Turkish but youtube makes it resembling to English. How can i avoid from this?
Could it be due to i am encoding my code and database UTF-8?
You can use region codes for the videos, that will help.
E.g. For Turkish videos, you can use regionCode = "TR"
GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=is&regionCode=TR&key={YOUR_API_KEY}

Resources