Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Compiling the SuperJAR File #12

Closed
nicolasguzca opened this issue Jul 12, 2019 · 12 comments
Closed

Compiling the SuperJAR File #12

nicolasguzca opened this issue Jul 12, 2019 · 12 comments

Comments

@nicolasguzca
Copy link

Hi! I made some edits to the transcribelamda folder and I need to recompile it to generate the TranscribeStreamingJavaLambda.jar. Could you please tell me how can I do that? I have tried using Maven or Gradle shadowJar but its always giving me an error (maybe I am missing some dependencies?)

Thank you!

@eggoynes
Copy link
Contributor

Hi @nicolasguzca
Do you have a copy of the error you are seeing?

@nicolasguzca
Copy link
Author

nicolasguzca commented Jul 12, 2019

* What went wrong:
A problem was found with the configuration of task ':shadowJar'.
> No value has been specified for property 'mainClassName'.

I'm running gradle shadowJar, same error with gradle build

@eggoynes
Copy link
Contributor

I found this issue here.
GradleUp/shadow#336

I just fixed it. I added mainClassName to the build.gradle file. Add it under the apply plugin: 'application'

apply plugin: 'application'

mainClassName = "com.amazonaws.transcribestreaming.cli.TranscribeStreamingDemoApp"

@nicolasguzca
Copy link
Author

Thank you @EddieGoynesAmazon ! That worked perfectly. I also need to upgrade the plugin version to id "com.github.johnrengelman.shadow" version "5.0.0"

@nicolasguzca
Copy link
Author

Quick question @EddieGoynesAmazon, what will be the best approach to transcribe Spanish instead of English?

Thank you!

@eggoynes
Copy link
Contributor

Change the language code in the Java code file.
https://github.com/awslabs/live-streaming-with-automated-multi-language-subtitling/blob/master/source/transcribelambda/gradle/src/main/java/com/amazonaws/transcribestreaming/cli/TranscribeStreamingDemoApp.java

In the function on line 196 replace the two places that say EN_US with ES_US
See how that works, you may need to rename English to Spanish in the CaptionCreationLambda too.

  private static StartStreamTranscriptionRequest getRequest(Integer mediaSampleRateHertz, String customVocabulary) {
        if(customVocabulary == null || customVocabulary.equals("")){
            return StartStreamTranscriptionRequest.builder()
                    .languageCode(LanguageCode.EN_US.toString())
                    .mediaEncoding(MediaEncoding.PCM)
                    .mediaSampleRateHertz(mediaSampleRateHertz)
                    .build();
        }else {
            return StartStreamTranscriptionRequest.builder()
                    .languageCode(LanguageCode.EN_US.toString())
                    .mediaEncoding(MediaEncoding.PCM)
                    .mediaSampleRateHertz(mediaSampleRateHertz)
                    .vocabularyName(customVocabulary)
                    .build();
        }
    }

https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html

@nicolasguzca
Copy link
Author

nicolasguzca commented Jul 12, 2019

Thank you, I was able to compile it and uploaded to the TranscribeStreamingLambda but I am getting the following error when I run the Lambda function:

{
  "errorMessage": "java.net.MalformedURLException: no protocol: ",
  "errorType": "java.lang.RuntimeException",
  "stackTrace": [
    "com.amazonaws.transcribestreaming.cli.TranscribeStreamingDemoApp.getStreamFromFileUrl(TranscribeStreamingDemoApp.java:154)",
    "com.amazonaws.transcribestreaming.cli.TranscribeStreamingDemoApp.getTextFromURL(TranscribeStreamingDemoApp.java:120)",
    "LambdaPackage.Lambda.handleRequest(Lambda.java:45)",
    "sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)",
    "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
    "java.lang.reflect.Method.invoke(Method.java:498)"
  ],
  "cause": {
    "errorMessage": "no protocol: ",
    "errorType": "java.net.MalformedURLException",
    "stackTrace": [
      "java.net.URL.<init>(URL.java:593)",
      "java.net.URL.<init>(URL.java:490)",
      "java.net.URL.<init>(URL.java:439)",
      "com.amazonaws.transcribestreaming.cli.TranscribeStreamingDemoApp.getStreamFromFileUrl(TranscribeStreamingDemoApp.java:150)",
      "com.amazonaws.transcribestreaming.cli.TranscribeStreamingDemoApp.getTextFromURL(TranscribeStreamingDemoApp.java:120)",
      "LambdaPackage.Lambda.handleRequest(Lambda.java:45)",
      "sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)",
      "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
      "java.lang.reflect.Method.invoke(Method.java:498)"
    ]
  }
}

I think it has to do something with my machine compiling since I returned the LanguageCode.ES_US.toString() to its default value and it still shows the same error. I also re cloned this project, compiled it without modifications and it shows the same error.

I am using the gradle shadowJar command and uploading the gradle-all.jar. Is this correct? It's been a while since I've worked with Java so sorry for this newbie question :)

@eggoynes
Copy link
Contributor

Hi @nicolasguzca

You have to upload a PCM 16bit audio file that you want to Transcribe onto S3 or some HTTP location. Make the file you are Transcribing public as well just for this test.

When testing the Java Lambda are you invoking with the following JSON? Does this fix your problem?
image

@nicolasguzca
Copy link
Author

Hi @EddieGoynesAmazon !
I tested it and it shows the same error with my compiled .jar, with the compile superjar you provide it works perfectly. This is why I think I am maybe compiling it wrong or something.

@eggoynes
Copy link
Contributor

By working perfectly you mean you are able to submit a URL encoded URL as the body in a POST request to the Lambda?

I looked around for that error I was able to find this post. I will have to look into this more depth.
https://stackoverflow.com/questions/22093864/java-net-malformedurlexception-no-protocol-on-url-based-on-a-string-modified-wi

@nicolasguzca
Copy link
Author

Yes, I am able to submit an encoded URL when I try it with your provided .jar. When I compile the Jar, even if I don't modify it, I get the MalformedURLException error. That is why I think it has to do more with a compiling error from my end than a encoding error.

@nicolasguzca
Copy link
Author

Hi Eddie, my bad, I was able to compile the .jar and I stopped receiving the above errors! Silly mistake from my part.

I am using the new .jar with now erros and the spanish language code but it doesn't seem to transcribe spanish, do I need to change something else?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants