def test_create_no_transcribe(self):
     remote_media_file = settings.get('test', 'audio_test_remote_mp3')
     self.model = Media.create(client=self.client, media_filename=remote_media_file, transcribe=False)
     media_item = Media.get(client=self.client, uuid=self.model.uuid)
     assert Media.get(client=self.client, uuid=self.model.uuid).uuid == self.model.uuid
     assert media_item.title == remote_media_file
     assert media_item.status in (MEDIA_STATUS['UPLOAD'], MEDIA_STATUS['TRANSCODE'])
 def test_create_no_transcribe(self):
     remote_media_file = settings.get('test', 'audio_test_remote_mp3')
     self.model = Media.create(client=self.client,
                               media_filename=remote_media_file,
                               transcribe=False)
     media_item = Media.get(client=self.client, uuid=self.model.uuid)
     assert Media.get(client=self.client,
                      uuid=self.model.uuid).uuid == self.model.uuid
     assert media_item.title == remote_media_file
     assert media_item.status in (MEDIA_STATUS['UPLOAD'],
                                  MEDIA_STATUS['TRANSCODE'])
    def test_align_remote(self):
        media_item = Media.create(
            client=self.client,
            media_filename=settings.get('test', 'audio_test_remote_mp3'),
            aligndata="%s/%s" % (settings.get('base', 'path.local.transcripts'), settings.get('test', 'transcript.align')),
            transcribe=False
        )

        assert hasattr(media_item, 'process_alignment')
        assert media_item.process_alignment.status == 'PENDING'
        assert media_item.process_alignment.progress == 0
        assert hasattr(media_item.process_alignment, 'uuid')
    def test_align_remote(self):
        media_item = Media.create(
            client=self.client,
            media_filename=settings.get('test', 'audio_test_remote_mp3'),
            aligndata="%s/%s" %
            (settings.get('base', 'path.local.transcripts'),
             settings.get('test', 'transcript.align')),
            transcribe=False)

        assert hasattr(media_item, 'process_alignment')
        assert media_item.process_alignment.status == 'PENDING'
        assert media_item.process_alignment.progress == 0
        assert hasattr(media_item.process_alignment, 'uuid')
def upload_transcribe(media_filename):
    """
    Upload a media file to Koemei for transcription
    """

    try:
        log.info("Upload and transcribe file %s ..." % media_filename)
        media_item = Media.create(client=client, media_filename=media_filename)
        log.info("... OK - media uuid: %s" % media_item.uuid)
    except Exception, e:
        log.error("... Error creating media %s ..." % media_filename)
        log.error(e)
        log.error(traceback.format_exc())
        raise e
def upload_transcribe(media_filename):
    """
    Upload a media file to Koemei for transcription
    """

    try:
        log.info("Upload and transcribe file %s ..." % media_filename)
        media_item = Media.create(client=client, media_filename=media_filename)
        log.info("... OK - media uuid: %s" % media_item.uuid)
    except Exception, e:
        log.error("... Error creating media %s ..." % media_filename)
        log.error(e)
        log.error(traceback.format_exc())
        raise e
    def test_get_all(self):
        local_media_files = ['test_mp4_short.mp4', 'test_64K_short.mp3']
        for local_media_file in local_media_files:
            media_filename = "%s/%s" % (settings.get(
                'base', 'path.local.media'), local_media_file)

            m = Media.create(
                client=self.client,
                media_filename=media_filename,
            )

        media = Media.get_all(client=self.client)
        assert len(media) > 0
        for m in media:
            assert hasattr(m, 'title')
            assert hasattr(m, '')
    def test_create_local(self):
        local_media_files = ['test_mp4_short.mp4', 'test_64K_short.mp3']
        for local_media_file in local_media_files:
            media_filename = "%s/%s" % (settings.get(
                'base', 'path.local.media'), local_media_file)

            self.model = Media.create(
                client=self.client,
                media_filename=media_filename,
            )

            media_item = Media.get(client=self.client, uuid=self.model.uuid)
            assert media_item.uuid == self.model.uuid
            assert media_item.title == "%s/%s" % (settings.get(
                'base', 'path.local.media'), local_media_file)
            assert media_item.status == MEDIA_STATUS['ASR']
            assert media_item.progress == 0
    def test_create_remote(self):
        remote_media_files = [
            settings.get('test', 'audio_test_remote_mp3'),
            settings.get('test', 'audio_test_remote_youtube'),
            settings.get('test', 'audio_test_remote_youtube_https'),
        ]

        for remote_media_file in remote_media_files:
            self.model = Media.create(
                client=self.client,
                media_filename=remote_media_file,
            )
            media_item = Media.get(client=self.client, uuid=self.model.uuid)
            assert Media.get(client=self.client, uuid=self.model.uuid).uuid == self.model.uuid
            assert media_item.title == remote_media_file
            assert media_item.status == MEDIA_STATUS['ASR']
            assert media_item.progress == 0
    def test_create_local(self):
        local_media_files = [
            'test_mp4_short.mp4',
            'test_64K_short.mp3'
        ]
        for local_media_file in local_media_files:
            media_filename = "%s/%s" % (settings.get('base', 'path.local.media'), local_media_file)

            self.model = Media.create(
                client=self.client,
                media_filename=media_filename,
            )

            media_item = Media.get(client=self.client, uuid=self.model.uuid)
            assert media_item.uuid == self.model.uuid
            assert media_item.title == "%s/%s" % (settings.get('base', 'path.local.media'), local_media_file)
            assert media_item.status == MEDIA_STATUS['ASR']
            assert media_item.progress == 0
    def test_get_all(self):
        local_media_files = [
            'test_mp4_short.mp4',
            'test_64K_short.mp3'
        ]
        for local_media_file in local_media_files:
            media_filename = "%s/%s" % (settings.get('base', 'path.local.media'), local_media_file)

            m = Media.create(
                client=self.client,
                media_filename=media_filename,
            )

        media = Media.get_all(client=self.client)
        assert len(media) > 0
        for m in media:
            assert hasattr(m, 'title')
            assert hasattr(m, '')
    def test_create_remote(self):
        remote_media_files = [
            settings.get('test', 'audio_test_remote_mp3'),
            settings.get('test', 'audio_test_remote_youtube'),
            settings.get('test', 'audio_test_remote_youtube_https'),
        ]

        for remote_media_file in remote_media_files:
            self.model = Media.create(
                client=self.client,
                media_filename=remote_media_file,
            )
            media_item = Media.get(client=self.client, uuid=self.model.uuid)
            assert Media.get(client=self.client,
                             uuid=self.model.uuid).uuid == self.model.uuid
            assert media_item.title == remote_media_file
            assert media_item.status == MEDIA_STATUS['ASR']
            assert media_item.progress == 0
def upload_align(media_filename, aligndata):
    """
    Upload a media file to Koemei for alignment
    NOTE : you will need your account to be specially setup to use this feature
    """

    try:
        log.info("Upload and align media %s ..." % media_filename)

        media_item = Media.create(client=client,
                                  media_filename=media_filename,
                                  aligndata=aligndata,
                                  transcribe=False)

        log.info("... OK - media uuid: %s" % media_item.uuid)
    except Exception, e:
        log.error("... Error aligning media %s ..." % media_filename)
        log.error(e)
        log.error(traceback.format_exc())
        raise e
    def test_get(self):
        """
        Create a media and do a get request on it
        """
        fields = {
            'title': 'Test media title',
            'description': 'Test media description',
            'local_media_file': 'test_64K_short.mp3',
        }

        media_filename = "%s/%s" % (settings.get('base', 'path.local.media'), fields['local_media_file'])
        m = Media.create(
            client=self.client,
            media_filename=media_filename,
            title=fields['title'],
            description=fields['description'],
        )

        m = Media.get(client=self.client, uuid=m.uuid)
        assert m.title == fields['title']
        assert m.description == fields['description']
def upload_align(media_filename, aligndata):
    """
    Upload a media file to Koemei for alignment
    NOTE : you will need your account to be specially setup to use this feature
    """
    register_openers()
    try:
        log.info("Upload and align media %s ..." % media_filename)

        media_item = Media.create(
            client=client,
            media_filename=media_filename,
            aligndata=aligndata,
            transcribe=False
        )

        log.info("... OK - media uuid: %s" % media_item.uuid)
    except Exception, e:
        log.error("... Error aligning media %s ..." % media_filename)
        log.error(e)
        log.error(traceback.format_exc())
        raise e
    def test_get(self):
        """
        Create a media and do a get request on it
        """
        fields = {
            'title': 'Test media title',
            'description': 'Test media description',
            'local_media_file': 'test_64K_short.mp3',
        }

        media_filename = "%s/%s" % (settings.get(
            'base', 'path.local.media'), fields['local_media_file'])
        m = Media.create(
            client=self.client,
            media_filename=media_filename,
            title=fields['title'],
            description=fields['description'],
        )

        m = Media.get(client=self.client, uuid=m.uuid)
        assert m.title == fields['title']
        assert m.description == fields['description']
    def test_create_local_metadata(self):
        """
        Test creation of a media from a local file, by specifying some metadata (title, description, ...)
        """
        local_media = {
            'path': 'test_mp4_short.mp4',
            'title': 'Test media title',
            'description': 'Test media description',
        }

        media_filename = "%s/%s" % (settings.get('base', 'path.local.media'), local_media['path'])

        self.model = Media.create(
            client=self.client,
            media_filename=media_filename,
            title=local_media['title'],
            description=local_media['description'],
        )

        media_item = Media.get(client=self.client, uuid=self.model.uuid)
        assert media_item.title == local_media['title']
        assert media_item.description == local_media['description']
Example #18
0
    def test_get_all(self):
        local_media_files = [
            'test_mp4_short.mp4',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3',
            'test_64K_short.mp3'
        ]
        for local_media_file in local_media_files:
            media_filename = "%s/%s" % (settings.get('base', 'path.local.media'), local_media_file)

            m = Media.create(
                client=self.client,
                media_filename=media_filename,
            )

        # vanilla test
        media = Media.get_all(client=self.client)
        assert len(media) > 0
        for m in media:
            assert hasattr(m, 'title')
        assert len(media) == 10

        # test pagination
        page_size = 5
        media = Media.get_all(client=self.client, start=0, count=page_size)
        assert len(media) == page_size

        media2 = Media.get_all(client=self.client, start=page_size-1, count=page_size)
        assert media[page_size-1].uuid == media2[0].uuid
    def test_create_local_metadata(self):
        """
        Test creation of a media from a local file, by specifying some metadata (title, description, ...)
        """
        local_media = {
            'path': 'test_mp4_short.mp4',
            'title': 'Test media title',
            'description': 'Test media description',
        }

        media_filename = "%s/%s" % (settings.get(
            'base', 'path.local.media'), local_media['path'])

        self.model = Media.create(
            client=self.client,
            media_filename=media_filename,
            title=local_media['title'],
            description=local_media['description'],
        )

        media_item = Media.get(client=self.client, uuid=self.model.uuid)
        assert media_item.title == local_media['title']
        assert media_item.description == local_media['description']