public class TranscribeTranslateExample extends Object
Tika.parseToString(Path)
into Translator.translate(String, String)
.
The GoogleTranslator
is configured with a target
language of "en-US".Constructor and Description |
---|
TranscribeTranslateExample() |
Modifier and Type | Method and Description |
---|---|
static String |
amazonTranscribe(Path tikaConfig,
Path file)
Use
AmazonTranscribe to execute transcription
on input data. |
static String |
googleTranslateToEnglish(String text)
Use
GoogleTranslator to execute translation on
input data. |
static void |
main(String[] args)
Main method to run this example.
|
public static String googleTranslateToEnglish(String text)
GoogleTranslator
to execute translation on
input data. This implementation needs configured as explained in the Javadoc.
In this implementation, Google will try to guess the input language. The target
language is "en-US".text
- input text to translate.public static String amazonTranscribe(Path tikaConfig, Path file) throws Exception
AmazonTranscribe
to execute transcription
on input data.
This implementation needs to be configured as explained in the Javadoc.file
- the name of the file (which needs to be on the Java Classpath) to transcribe.Exception
public static void main(String[] args) throws Exception
transcribe-translate ${tika-config.xml} ${file}
; which executes both
transcription then translation on the given resource, or
transcribe ${tika-config.xml} ${file}
; which executes only translationargs
- either of the commands described above and the input file
(which needs to be on the Java Classpath).
${tika-config.xml} must include credentials for aws and a temporary storage bucket:
<properties>
<parsers>
<parser class="org.apache.tika.parser.DefaultParser"/>
<parser class="org.apache.tika.parser.transcribe.aws.AmazonTranscribe">
<params>
<param name="bucket" type="string">bucket</param>
<param name="clientId" type="string">clientId</param>
<param name="clientSecret" type="string">clientSecret</param>
</params>
</parser>
</parsers>
</properties>
Exception
Copyright © 2007–2022 The Apache Software Foundation. All rights reserved.