@Test public void testGetGeneratedTranscriptionNoJobId() throws Exception { database.storeJobControl(MP_ID, TRACK_ID, JOB_ID, TranscriptionJobControl.Status.InProgress.name(), TRACK_DURATION, DATE_EXPECTED, PROVIDER); database.storeJobControl(MP_ID, "audioTrack2", "jobId2", TranscriptionJobControl.Status.InProgress.name(), TRACK_DURATION, DATE_EXPECTED, PROVIDER); database.updateJobControl(JOB_ID, TranscriptionJobControl.Status.TranscriptionComplete.name()); URI uri = new URI("http: + JOB_ID + ".json"); EasyMock.expect(workspace.getCollectionURI(GoogleSpeechTranscriptionService.TRANSCRIPT_COLLECTION, JOB_ID + ".json")) .andReturn(uri); EasyMock.expect(workspace.get(uri)).andReturn(null); EasyMock.replay(workspace); MediaPackageElement mpe = service.getGeneratedTranscription(MP_ID, null); Assert.assertEquals("captions", mpe.getFlavor().getType()); Assert.assertEquals("google-speech-json", mpe.getFlavor().getSubtype()); Assert.assertEquals(uri.toString(), mpe.getURI().toString()); }
@Override public MediaPackageElement getGeneratedTranscription(String mpId, String jobId) throws TranscriptionServiceException { try { if (jobId == null || "null".equals(jobId)) { jobId = null; for (TranscriptionJobControl jc : database.findByMediaPackage(mpId)) { if (TranscriptionJobControl.Status.Closed.name().equals(jc.getStatus()) || TranscriptionJobControl.Status.TranscriptionComplete.name().equals(jc.getStatus())) { jobId = jc.getTranscriptionJobId(); } } } if (jobId == null) { throw new TranscriptionServiceException( "No completed or closed transcription job found in database for media package " + mpId); } URI uri = workspace.getCollectionURI(TRANSCRIPT_COLLECTION, buildResultsFileName(jobId)); try { workspace.get(uri); } catch (Exception e) { try { getAndSaveJobResults(jobId); } catch (IOException ex) { logger.error("Unable to retrieve transcription job, error: {}", ex.toString()); } } MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder(); return builder.elementFromURI(uri, Attachment.TYPE, new MediaPackageElementFlavor("captions", "google-speech-json")); } catch (TranscriptionDatabaseException e) { throw new TranscriptionServiceException("Job id not informed and could not find transcription", e); } }
GoogleSpeechTranscriptionService extends AbstractJobProducer implements TranscriptionService { @Override public MediaPackageElement getGeneratedTranscription(String mpId, String jobId) throws TranscriptionServiceException { try { if (jobId == null || "null".equals(jobId)) { jobId = null; for (TranscriptionJobControl jc : database.findByMediaPackage(mpId)) { if (TranscriptionJobControl.Status.Closed.name().equals(jc.getStatus()) || TranscriptionJobControl.Status.TranscriptionComplete.name().equals(jc.getStatus())) { jobId = jc.getTranscriptionJobId(); } } } if (jobId == null) { throw new TranscriptionServiceException( "No completed or closed transcription job found in database for media package " + mpId); } URI uri = workspace.getCollectionURI(TRANSCRIPT_COLLECTION, buildResultsFileName(jobId)); try { workspace.get(uri); } catch (Exception e) { try { getAndSaveJobResults(jobId); } catch (IOException ex) { logger.error("Unable to retrieve transcription job, error: {}", ex.toString()); } } MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder(); return builder.elementFromURI(uri, Attachment.TYPE, new MediaPackageElementFlavor("captions", "google-speech-json")); } catch (TranscriptionDatabaseException e) { throw new TranscriptionServiceException("Job id not informed and could not find transcription", e); } } }
GoogleSpeechTranscriptionService extends AbstractJobProducer implements TranscriptionService { @Override public MediaPackageElement getGeneratedTranscription(String mpId, String jobId) throws TranscriptionServiceException { try { if (jobId == null || "null".equals(jobId)) { jobId = null; for (TranscriptionJobControl jc : database.findByMediaPackage(mpId)) { if (TranscriptionJobControl.Status.Closed.name().equals(jc.getStatus()) || TranscriptionJobControl.Status.TranscriptionComplete.name().equals(jc.getStatus())) { jobId = jc.getTranscriptionJobId(); } } } if (jobId == null) { throw new TranscriptionServiceException( "No completed or closed transcription job found in database for media package " + mpId); } URI uri = workspace.getCollectionURI(TRANSCRIPT_COLLECTION, buildResultsFileName(jobId)); try { workspace.get(uri); } catch (Exception e) { try { getAndSaveJobResults(jobId); } catch (IOException ex) { logger.error("Unable to retrieve transcription job, error: {}", ex.toString()); } } MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder(); return builder.elementFromURI(uri, Attachment.TYPE, new MediaPackageElementFlavor("captions", "google-speech-json")); } catch (TranscriptionDatabaseException e) { throw new TranscriptionServiceException("Job id not informed and could not find transcription", e); } } GoogleSpeechTranscriptionService(); }
GoogleSpeechTranscriptionService extends AbstractJobProducer implements TranscriptionService { @Override public MediaPackageElement getGeneratedTranscription(String mpId, String jobId) throws TranscriptionServiceException { try { if (jobId == null || "null".equals(jobId)) { jobId = null; for (TranscriptionJobControl jc : database.findByMediaPackage(mpId)) { if (TranscriptionJobControl.Status.Closed.name().equals(jc.getStatus()) || TranscriptionJobControl.Status.TranscriptionComplete.name().equals(jc.getStatus())) { jobId = jc.getTranscriptionJobId(); } } } if (jobId == null) { throw new TranscriptionServiceException( "No completed or closed transcription job found in database for media package " + mpId); } URI uri = workspace.getCollectionURI(TRANSCRIPT_COLLECTION, buildResultsFileName(jobId)); try { workspace.get(uri); } catch (Exception e) { try { getAndSaveJobResults(jobId); } catch (IOException ex) { logger.error("Unable to retrieve transcription job, error: {}", ex.toString()); } } MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder(); return builder.elementFromURI(uri, Attachment.TYPE, new MediaPackageElementFlavor("captions", "google-speech-json")); } catch (TranscriptionDatabaseException e) { throw new TranscriptionServiceException("Job id not informed and could not find transcription", e); } } GoogleSpeechTranscriptionService(); void activate(ComponentContext cc); @Override Job startTranscription(String mpId, Track track, String language); @Override Job startTranscription(String mpId, Track track); @Override void transcriptionDone(String mpId, Object obj); @Override String getLanguage(); @Override void transcriptionError(String mpId, Object obj); String getTranscriptionResults(String jobId); @Override MediaPackageElement getGeneratedTranscription(String mpId, String jobId); String getTranscriptionStatus(String mpId); void setServiceRegistry(ServiceRegistry serviceRegistry); void setSecurityService(SecurityService securityService); void setUserDirectoryService(UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); void setSmtpService(SmtpService service); void setWorkspace(Workspace ws); void setWorkingFileRepository(WorkingFileRepository wfr); void setDatabase(TranscriptionDatabase service); void setAssetManager(AssetManager service); void setWorkflowService(WorkflowService service); }
GoogleSpeechTranscriptionService extends AbstractJobProducer implements TranscriptionService { @Override public MediaPackageElement getGeneratedTranscription(String mpId, String jobId) throws TranscriptionServiceException { try { if (jobId == null || "null".equals(jobId)) { jobId = null; for (TranscriptionJobControl jc : database.findByMediaPackage(mpId)) { if (TranscriptionJobControl.Status.Closed.name().equals(jc.getStatus()) || TranscriptionJobControl.Status.TranscriptionComplete.name().equals(jc.getStatus())) { jobId = jc.getTranscriptionJobId(); } } } if (jobId == null) { throw new TranscriptionServiceException( "No completed or closed transcription job found in database for media package " + mpId); } URI uri = workspace.getCollectionURI(TRANSCRIPT_COLLECTION, buildResultsFileName(jobId)); try { workspace.get(uri); } catch (Exception e) { try { getAndSaveJobResults(jobId); } catch (IOException ex) { logger.error("Unable to retrieve transcription job, error: {}", ex.toString()); } } MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder(); return builder.elementFromURI(uri, Attachment.TYPE, new MediaPackageElementFlavor("captions", "google-speech-json")); } catch (TranscriptionDatabaseException e) { throw new TranscriptionServiceException("Job id not informed and could not find transcription", e); } } GoogleSpeechTranscriptionService(); void activate(ComponentContext cc); @Override Job startTranscription(String mpId, Track track, String language); @Override Job startTranscription(String mpId, Track track); @Override void transcriptionDone(String mpId, Object obj); @Override String getLanguage(); @Override void transcriptionError(String mpId, Object obj); String getTranscriptionResults(String jobId); @Override MediaPackageElement getGeneratedTranscription(String mpId, String jobId); String getTranscriptionStatus(String mpId); void setServiceRegistry(ServiceRegistry serviceRegistry); void setSecurityService(SecurityService securityService); void setUserDirectoryService(UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); void setSmtpService(SmtpService service); void setWorkspace(Workspace ws); void setWorkingFileRepository(WorkingFileRepository wfr); void setDatabase(TranscriptionDatabase service); void setAssetManager(AssetManager service); void setWorkflowService(WorkflowService service); static final String DEFAULT_WF_DEF; static final String ENABLED_CONFIG; static final String GOOGLE_SPEECH_LANGUAGE; static final String PROFANITY_FILTER; static final String WORKFLOW_CONFIG; static final String DISPATCH_WORKFLOW_INTERVAL_CONFIG; static final String COMPLETION_CHECK_BUFFER_CONFIG; static final String MAX_PROCESSING_TIME_CONFIG; static final String NOTIFICATION_EMAIL_CONFIG; static final String CLEANUP_RESULTS_DAYS_CONFIG; static final String GOOGLE_CLOUD_CLIENT_ID; static final String GOOGLE_CLOUD_CLIENT_SECRET; static final String GOOGLE_CLOUD_REFRESH_TOKEN; static final String GOOGLE_CLOUD_BUCKET; static final String GOOGLE_CLOUD_TOKEN_ENDPOINT_URL; static final String ENCODING_EXTENSION; }