Examples of VideoTranscript


Examples of io.lumify.core.ingest.video.VideoTranscript

    private static final String PROPERTY_KEY = SubRipTranscriptGraphPropertyWorker.class.getName();

    @Override
    public void execute(InputStream in, GraphPropertyWorkData data) throws Exception {
        StreamingPropertyValue youtubeccValue = SubRipTranscriptFileImportSupportingFileHandler.SUBRIP_CC.getPropertyValue(data.getElement());
        VideoTranscript videoTranscript = SubRip.read(youtubeccValue.getInputStream());

        ExistingElementMutation<Vertex> m = data.getElement().prepareMutation();
        Map<String, Object> metadata = data.createPropertyMetadata();
        metadata.put(LumifyProperties.META_DATA_TEXT_DESCRIPTION, "Sub-rip Transcript");
        addVideoTranscriptAsTextPropertiesToMutation(m, PROPERTY_KEY, videoTranscript, metadata, data.getVisibility());
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

            respondWithHtml(response, highlightedText);
            return;
        }

        VideoTranscript videoTranscript = MediaLumifyProperties.VIDEO_TRANSCRIPT.getPropertyValue(artifactVertex, propertyKey);
        if (videoTranscript != null) {
            LOGGER.debug("returning video transcript for vertexId:%s property:%s", artifactVertex.getId(), propertyKey);
            Iterable<Vertex> termMentions = termMentionRepository.findBySourceGraphVertexAndPropertyKey(artifactVertex.getId(), propertyKey, authorizations);
            VideoTranscript highlightedVideoTranscript = entityHighlighter.getHighlightedVideoTranscript(videoTranscript, termMentions, workspaceId, authorizations);
            respondWithJson(response, highlightedVideoTranscript.toJson());
            return;
        }

        videoTranscript = JsonSerializer.getSynthesisedVideoTranscription(artifactVertex, propertyKey);
        if (videoTranscript != null) {
            LOGGER.debug("returning synthesised video transcript for vertexId:%s property:%s", artifactVertex.getId(), propertyKey);
            Iterable<Vertex> termMentions = termMentionRepository.findBySourceGraphVertexAndPropertyKey(artifactVertex.getId(), propertyKey, authorizations);
            VideoTranscript highlightedVideoTranscript = entityHighlighter.getHighlightedVideoTranscript(videoTranscript, termMentions, workspaceId, authorizationsWithTermMention);
            respondWithJson(response, highlightedVideoTranscript.toJson());
            return;
        }

        respondWithNotFound(response);
    }
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

            in.close();
        }
    }

    public static VideoTranscript read(InputStream in) throws IOException {
        VideoTranscript result = new VideoTranscript();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
        ReadState readState = ReadState.Frame;
        VideoTranscript.Time time = null;
        String line;
        StringBuilder text = new StringBuilder();
        int frame;
        while ((line = reader.readLine()) != null) {
            switch (readState) {
                case Frame:
                    try {
                        frame = Integer.parseInt(line);
                        readState = ReadState.Time;
                    } catch (NumberFormatException e) {
                        LOGGER.warn("%s is not a number.", line);
                    }
                    break;
                case Time:
                    time = parseTimeLine(line);
                    readState = ReadState.Text;
                    break;
                case Text:
                    if (line.trim().length() == 0) {
                        readState = ReadState.Frame;
                        result.add(time, text.toString().trim());
                        time = null;
                        text = new StringBuilder();
                        continue;
                    }
                    text.append(line.trim());
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

                    },
                    null,
                    data.getLocalFile().getAbsolutePath() + ": "
            );

            VideoTranscript videoTranscript = SubRip.read(ccFile);
            if (videoTranscript.getEntries().size() == 0) {
                return;
            }

            ExistingElementMutation<Vertex> m = data.getElement().prepareMutation();
            Map<String, Object> metadata = data.createPropertyMetadata();
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

    private static final String PROPERTY_KEY = YoutubeTranscriptGraphPropertyWorker.class.getName();

    @Override
    public void execute(InputStream in, GraphPropertyWorkData data) throws Exception {
        StreamingPropertyValue youtubeccValue = YoutubeTranscriptFileImportSupportingFileHandler.YOUTUBE_CC.getPropertyValue(data.getElement());
        VideoTranscript videoTranscript = YoutubeccReader.read(youtubeccValue.getInputStream());

        ExistingElementMutation<Vertex> m = data.getElement().prepareMutation();
        addVideoTranscriptAsTextPropertiesToMutation(m, PROPERTY_KEY, videoTranscript, data.createPropertyMetadata(), data.getVisibility());
        Vertex v = m.save(getAuthorizations());
        getAuditRepository().auditVertexElementMutation(AuditAction.UPDATE, m, v, PROPERTY_KEY, getUser(), data.getVisibility());
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

            in.close();
        }
    }

    public static VideoTranscript read(InputStream in) throws Exception {
        VideoTranscript videoTranscript = new VideoTranscript();
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(in);
        NodeList textElements = doc.getElementsByTagName("text");
        for (int i = 0; i < textElements.getLength(); i++) {
            Element textElement = (Element) textElements.item(i);
            double start = Double.parseDouble(textElement.getAttribute("start"));
            double duration = Double.parseDouble(textElement.getAttribute("dur"));
            String text = textElement.getTextContent().trim();
            VideoTranscript.Time time = new VideoTranscript.Time((long) (start * 1000), (long) ((start + duration) * 1000));
            videoTranscript.add(time, text);
        }
        return videoTranscript;
    }
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

public class YoutubeccReaderTest {
    @Test
    public void testRead() throws Exception {
        YoutubeccReader reader = new YoutubeccReader();
        InputStream in = IOUtils.toInputStream("<?xml version=\"1.0\" encoding=\"utf-8\" ?><transcript><text start=\"3.502\" dur=\"4.739\">PRESIDENT MR. PRESIDENT THANKS </text><text start=\"7.173\" dur=\"1.735\">SO MUCH FOR JOINING US. </text></transcript>");
        VideoTranscript videoTranscript = reader.read(in);
        List<VideoTranscript.TimedText> entries = videoTranscript.getEntries();
        assertEquals(2, entries.size());

        VideoTranscript.TimedText entry1 = entries.get(0);
        assertEquals("PRESIDENT MR. PRESIDENT THANKS", entry1.getText());
        assertEquals(3502L, entry1.getTime().getStart().longValue());
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

        Map<Integer, List<OffsetItem>> videoTranscriptOffsetItems = convertOffsetItemsToVideoTranscriptOffsetItems(videoTranscript, offsetItems);
        return getHighlightedVideoTranscript(videoTranscript, videoTranscriptOffsetItems);
    }

    private VideoTranscript getHighlightedVideoTranscript(VideoTranscript videoTranscript, Map<Integer, List<OffsetItem>> videoTranscriptOffsetItems) {
        VideoTranscript result = new VideoTranscript();
        int entryIndex = 0;
        for (VideoTranscript.TimedText videoTranscriptEntry : videoTranscript.getEntries()) {
            VideoTranscript.TimedText entry = videoTranscript.getEntries().get(entryIndex);

            List<OffsetItem> offsetItems = videoTranscriptOffsetItems.get(entryIndex);
            String highlightedText;
            if (offsetItems == null) {
                highlightedText = entry.getText();
            } else {
                highlightedText = getHighlightedText(entry.getText(), offsetItems);
            }
            result.add(videoTranscriptEntry.getTime(), highlightedText);
            entryIndex++;
        }
        return result;
    }
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

        return resultsJson;
    }


    public static VideoTranscript getSynthesisedVideoTranscription(Vertex artifactVertex, String propertyKey) throws IOException {
        VideoTranscript videoTranscript = new VideoTranscript();
        for (Property property : artifactVertex.getProperties()) {
            VideoFrameInfo videoFrameInfo = VideoPropertyHelper.getVideoFrameInfoFromProperty(property);
            if (videoFrameInfo == null) {
                continue;
            }
            if (videoFrameInfo.getPropertyKey().equals(propertyKey)) {
                Object value = property.getValue();
                String text;
                if (value instanceof StreamingPropertyValue) {
                    text = IOUtils.toString(((StreamingPropertyValue) value).getInputStream());
                } else {
                    text = value.toString();
                }
                videoTranscript.add(new VideoTranscript.Time(videoFrameInfo.getFrameStartTime(), videoFrameInfo.getFrameEndTime()), text);
            }
        }
        if (videoTranscript.getEntries().size() > 0) {
            return videoTranscript;
        }
        return null;
    }
View Full Code Here

Examples of io.lumify.core.ingest.video.VideoTranscript

    public static final String MULTI_VALUE_KEY = SphinxGraphPropertyWorker.class.getName();
    private ProcessRunner processRunner;

    @Override
    public void execute(InputStream in, GraphPropertyWorkData data) throws Exception {
        VideoTranscript transcript = extractTranscriptFromAudio(data.getLocalFile());
        if (transcript == null) {
            return;
        }

        ExistingElementMutation<Vertex> m = data.getElement().prepareMutation();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.