-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from MarcWeberFS:7-transcribe-audio-into-text
7-transcribe-audio-into-text
- Loading branch information
Showing
6 changed files
with
131 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
video-downloader-backend/src/main/java/ch/marc/delegates/TranscribeVideoDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ch.marc.delegates; | ||
|
||
import org.camunda.bpm.engine.delegate.DelegateExecution; | ||
import org.camunda.bpm.engine.delegate.JavaDelegate; | ||
import org.springframework.stereotype.Component; | ||
|
||
import software.amazon.awssdk.services.transcribe.TranscribeClient; | ||
import software.amazon.awssdk.services.transcribe.model.*; | ||
|
||
@Component | ||
public class TranscribeVideoDelegate implements JavaDelegate { | ||
|
||
@Override | ||
public void execute(DelegateExecution execution) { | ||
String downloadLink = (String) execution.getVariable("downloadLink"); | ||
|
||
String s3Uri = downloadLink.replace("https://video-download-temp.s3.amazonaws.com/", "s3://video-download-temp/"); | ||
|
||
TranscribeClient transcribeClient = TranscribeClient.builder().build(); | ||
|
||
StartTranscriptionJobRequest transcriptionJobRequest = StartTranscriptionJobRequest.builder() | ||
.transcriptionJobName("TranscriptionJob_" + System.currentTimeMillis()) | ||
.languageCode(LanguageCode.EN_US) | ||
.mediaFormat(MediaFormat.MP4) | ||
.media(Media.builder().mediaFileUri(s3Uri).build()) | ||
.subtitles(Subtitles.builder().formats(SubtitleFormat.SRT).build()) | ||
.build(); | ||
|
||
try { | ||
StartTranscriptionJobResponse transcriptionJobResponse = transcribeClient.startTranscriptionJob(transcriptionJobRequest); | ||
System.out.println("Transcription job started with ID: " + transcriptionJobResponse.transcriptionJob().transcriptionJobName()); | ||
|
||
execution.setVariable("transcriptionJobId", transcriptionJobResponse.transcriptionJob().transcriptionJobName()); | ||
|
||
} catch (TranscribeException e) { | ||
System.err.println("Error starting transcription job: " + e.awsErrorDetails().errorMessage()); | ||
throw new RuntimeException("Transcription job failed", e); | ||
} finally { | ||
transcribeClient.close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters