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


Python TextFile.add_fragment方法代码示例

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


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

示例1: check_espeak

# 需要导入模块: from aeneas.textfile import TextFile [as 别名]
# 或者: from aeneas.textfile.TextFile import add_fragment [as 别名]
    def check_espeak(cls):
        """
        Check whether ``espeak`` can be called.

        Return ``True`` on failure and ``False`` on success.

        :rtype: bool
        """
        try:
            from aeneas.textfile import TextFile
            from aeneas.textfile import TextFragment
            from aeneas.ttswrappers.espeakttswrapper import ESPEAKTTSWrapper
            text = u"From fairest creatures we desire increase,"
            text_file = TextFile()
            text_file.add_fragment(TextFragment(language=u"eng", lines=[text], filtered_lines=[text]))
            handler, output_file_path = gf.tmp_file(suffix=u".wav")
            ESPEAKTTSWrapper().synthesize_multiple(text_file, output_file_path)
            gf.delete_file(handler, output_file_path)
            gf.print_success(u"espeak         OK")
            return False
        except:
            pass
        gf.print_error(u"espeak         ERROR")
        gf.print_info(u"  Please make sure you have espeak installed correctly")
        gf.print_info(u"  and that its path is in your PATH environment variable")
        gf.print_info(u"  You might also want to check that the espeak-data directory")
        gf.print_info(u"  is set up correctly, for example, it has the correct permissions")
        return True
开发者ID:danielbair,项目名称:aeneas,代码行数:30,代码来源:diagnostics.py

示例2: test_add_fragment_multiple

# 需要导入模块: from aeneas.textfile import TextFile [as 别名]
# 或者: from aeneas.textfile.TextFile import add_fragment [as 别名]
 def test_add_fragment_multiple(self):
     tfl = TextFile()
     self.assertEqual(len(tfl), 0)
     tfl.add_fragment(TextFragment(u"a1", Language.ENG, [u"fragment 1"]))
     self.assertEqual(len(tfl), 1)
     tfl.add_fragment(TextFragment(u"a2", Language.ENG, [u"fragment 2"]))
     self.assertEqual(len(tfl), 2)
     tfl.add_fragment(TextFragment(u"a3", Language.ENG, [u"fragment 3"]))
     self.assertEqual(len(tfl), 3)
     self.assertEqual(tfl.chars, 30)
开发者ID:ptrwtts,项目名称:aeneas,代码行数:12,代码来源:test_textfile.py

示例3: tfl

# 需要导入模块: from aeneas.textfile import TextFile [as 别名]
# 或者: from aeneas.textfile.TextFile import add_fragment [as 别名]
 def tfl(self, frags):
     tfl = TextFile()
     for language, lines in frags:
         tfl.add_fragment(TextFragment(language=language, lines=lines, filtered_lines=lines))
     return tfl
开发者ID:danielbair,项目名称:aeneas,代码行数:7,代码来源:base_ttswrapper.py

示例4: test_add_fragment

# 需要导入模块: from aeneas.textfile import TextFile [as 别名]
# 或者: from aeneas.textfile.TextFile import add_fragment [as 别名]
 def test_add_fragment(self):
     tfl = TextFile()
     self.assertEqual(len(tfl), 0)
     tfl.add_fragment(TextFragment(u"a1", Language.ENG, [u"fragment 1"]))
     self.assertEqual(len(tfl), 1)
     self.assertEqual(tfl.chars, 10)
开发者ID:ptrwtts,项目名称:aeneas,代码行数:8,代码来源:test_textfile.py

示例5: test_invalid_add_fragment

# 需要导入模块: from aeneas.textfile import TextFile [as 别名]
# 或者: from aeneas.textfile.TextFile import add_fragment [as 别名]
 def test_invalid_add_fragment(self):
     tfl = TextFile()
     with self.assertRaises(TypeError):
         tfl.add_fragment("foo")
开发者ID:ptrwtts,项目名称:aeneas,代码行数:6,代码来源:test_textfile.py


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