Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
def total_FA(soundfile, mylines, myhead, mytail, config=None):
    """Runs Aeneas as a library. This function isn't in use, currently,
    as we haven't managed to get reliable results in this way."""
    # create Task object
    if config is None:
        config_string = (
            u"task_language=nor|is_text_type=plain|os_task_file_format=json|is_audio_file_head_length=%s|is_audio_file_tail_length=%s"
            % (myhead, mytail))
        print(config_string)
    else:
        config_string = (
            u"task_language=nor|is_text_type=plain|os_task_file_format=json|is_audio_file_head_length=%s|is_audio_file_tail_length=%s|%s"
            % (myhead, mytail, config))
        print(config_string)
    task = Task(config_string=config_string)
    print(task)
    task.audio_file_path_absolute = soundfile
    textfile = TextFile()
    print(textfile)
    #task.sync_map_file_path_absolute = outfile
    for identifier, frag_text in mylines:
        textfile.add_fragment(
            TextFragment(identifier, Language.NOR, frag_text, frag_text))
    task.text_file = textfile
    print(len(task.text_file))
    ExecuteTask(task).execute()
    syncmaplist = task.sync_map.fragments
    return syncmaplist
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 def tfl(self, frags):
     tfl = TextFile()
     for language, lines in frags:
         tfl.add_fragment(
             TextFragment(language=language,
                          lines=lines,
                          filtered_lines=lines))
     return tfl
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 def tfl(self, frags):
     tfl = TextFile()
     for language, lines in frags:
         tfl.add_fragment(TextFragment(language=language, lines=lines, filtered_lines=lines))
     return tfl
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 def test_invalid_add_fragment(self):
     tfl = TextFile()
     with self.assertRaises(TypeError):
         tfl.add_fragment("foo")
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 def test_invalid_add_fragment(self):
     tfl = TextFile()
     with self.assertRaises(TypeError):
         tfl.add_fragment("foo")