How to use the pycaption.SAMIReader function in pycaption

To help you get started, we’ve selected a few pycaption examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbs / pycaption / tests / test_sami_conversion.py View on Github external
def test_sami_to_webvtt_conversion(self):
        caption_set = SAMIReader().read(SAMPLE_SAMI)
        results = WebVTTWriter(
            video_width=640, video_height=360).write(caption_set)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_SAMI, results)
github pbs / pycaption / tests / test_sami_conversion.py View on Github external
def test_sami_to_dfxp_xml_output(self):
        captions = SAMIReader().read(SAMPLE_SAMI_SYNTAX_ERROR)
        results = DFXPWriter(relativize=False,
                             fit_to_screen=False).write(captions)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertTrue('xmlns="http://www.w3.org/ns/ttml"' in results)
        self.assertTrue(
            'xmlns:tts="http://www.w3.org/ns/ttml#styling"' in results)
github pbs / pycaption / tests / test_sami.py View on Github external
def test_sami_with_p_and_span_align(self):
        """ <span> align DOES NOT override <p> align if it is specified inline.
        """
        caption_set = SAMIReader().read(SAMPLE_SAMI_WITH_P_AND_SPAN_ALIGN)
        caption = caption_set.get_captions('en-US')[0]
        self.assertEqual(caption.layout_info.alignment.horizontal, HorizontalAlignmentEnum.RIGHT)
</p></span>
github pbs / pycaption / tests / test_sami.py View on Github external
def test_empty_file(self):
        self.assertRaises(
            CaptionReadNoCaptions,
            SAMIReader().read, SAMPLE_SAMI_EMPTY)
github pbs / pycaption / tests / test_sami_conversion.py View on Github external
def test_sami_to_dfxp_with_bad_span_align(self):
        caption_set = SAMIReader().read(SAMPLE_SAMI_WITH_BAD_SPAN_ALIGN)
        results = DFXPWriter(
            relativize=False, fit_to_screen=False).write(caption_set)
        self.assertDFXPEquals(
            SAMPLE_DFXP_FROM_SAMI_WITH_BAD_SPAN_ALIGN,
            results
        )
github pbs / pycaption / tests / test_sami.py View on Github external
def test_sami_with_bad_span_align(self):
        caption_set = SAMIReader().read(SAMPLE_SAMI_WITH_BAD_SPAN_ALIGN)
        caption = caption_set.get_captions('en-US')[0]
        self.assertEqual(caption.layout_info.alignment.horizontal, HorizontalAlignmentEnum.RIGHT)
github pbs / pycaption / tests / test_sami.py View on Github external
def test_proper_timestamps(self):
        captions = SAMIReader().read(SAMPLE_SAMI)
        paragraph = captions.get_captions("en-US")[2]

        self.assertEqual(17000000, paragraph.start)
        self.assertEqual(18752000, paragraph.end)
github pbs / pycaption / tests / test_sami_conversion.py View on Github external
def test_sami_with_css_inline_style_to_webvtt_conversion(self):
        caption_set = SAMIReader().read(SAMPLE_SAMI_WITH_CSS_INLINE_STYLE)
        results = WebVTTWriter(
            video_width=640, video_height=360).write(caption_set)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_SAMI_WITH_STYLE, results)
github pbs / pycaption / tests / test_sami.py View on Github external
def test_detection(self):
        self.assertTrue(SAMIReader().detect(SAMPLE_SAMI))
github pbs / pycaption / tests / test_sami_conversion.py View on Github external
def test_sami_with_style_tags_to_webvtt_conversion(self):
        caption_set = SAMIReader().read(SAMPLE_SAMI_WITH_STYLE_TAGS)
        results = WebVTTWriter(
            video_width=640, video_height=360).write(caption_set)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_SAMI_WITH_STYLE, results)