Check that input sourceLanguage is valid for Amazon's StartStreamTranscription
@@ -56,6 +56,15 @@ public class AmazonTranscribe implements Transcriber {
public String transcribe(String filepath, String sourceLanguage) throws TikaException, IOException {
if (!this.isAvailable)
return "";
+
+ boolean validSourceLanguageFlag = false; // Tracks if we have seen the input sourceLanguage in validSourceLanguages
+ for (int i = 0; i < validSourceLanguages.length; i++){
+ if (validSourceLanguages[i].equals(sourceLanguage)) {
+ validSourceLanguageFlag = true; }
+ }
+ if (!validSourceLanguageFlag) { // Throws TikaException if the input sourceLanguage is not present in validSourceLanguages
+ throw new TikaException("Provided Source Language is Not Valid. Please select one of: " +
+ "en-US, en-GB, es-US, fr-CA, fr-FR, en-AU, it-IT, de-DE, pt-BR, ja-JP, ko-KR"); }
//TODO
return null;
}
