当前位置: 首页>>代码示例>>Python>>正文


Python AudioFile.verify方法代码示例

本文整理汇总了Python中audiotools.AudioFile.verify方法的典型用法代码示例。如果您正苦于以下问题:Python AudioFile.verify方法的具体用法?Python AudioFile.verify怎么用?Python AudioFile.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在audiotools.AudioFile的用法示例。


在下文中一共展示了AudioFile.verify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: verify

# 需要导入模块: from audiotools import AudioFile [as 别名]
# 或者: from audiotools.AudioFile import verify [as 别名]
    def verify(self, progress=None):
        """verifies the current file for correctness

        returns True if the file is okay
        raises an InvalidFile with an error message if there is
        some problem with the file"""

        # Checking for a truncated Ogg stream typically involves
        # verifying that the "end of stream" flag is set on the last
        # Ogg page in the stream in the event that one or more whole
        # pages is lost.  But since the OpusFile decoder doesn't perform
        # this check and doesn't provide any access to its internal
        # Ogg decoder (unlike Vorbis), we'll perform that check externally.
        #
        # And since it's a fast check, we won't bother to update progress.

        from audiotools.ogg import PageReader
        import os.path

        try:
            reader = PageReader(open(self.filename, "rb"))
        except IOError as err:
            raise InvalidOpus(str(err))

        try:
            page = reader.read()
            while (not page.stream_end):
                page = reader.read()
            reader.close()
        except (IOError, ValueError) as err:
            raise InvalidOpus(str(err))

        return AudioFile.verify(self, progress)
开发者ID:ryechus,项目名称:python-audio-tools,代码行数:35,代码来源:opus.py

示例2: PageReader

# 需要导入模块: from audiotools import AudioFile [as 别名]
# 或者: from audiotools.AudioFile import verify [as 别名]
        import os.path

        try:
            reader = PageReader(open(self.filename, "rb"))
        except IOError, err:
            raise InvalidOpus(str(err))

        try:
            page = reader.read()
            while (not page.stream_end):
                page = reader.read()
            reader.close()
        except (IOError, ValueError), err:
            raise InvalidOpus(str(err))

        return AudioFile.verify(self, progress)

    @classmethod
    def available(cls, system_binaries):
        """returns True if all necessary compenents are available
        to support format"""

        try:
            from audiotools.decoders import OpusDecoder
            from audiotools.encoders import encode_opus

            return True
        except ImportError:
            return False

    @classmethod
开发者ID:wuye9036,项目名称:python-audio-tools,代码行数:33,代码来源:opus.py


注:本文中的audiotools.AudioFile.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。