本文整理汇总了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
示例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)
示例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
示例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)
示例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")