コード例 #1
0
def test_AMCuervo(display):
    try:
        assert (os.path.exists("../testTextPyData/Cuervo/audio"))
    except AssertionError:
        os.mkdir("../testTextPyData/Cuervo/audio")

    audioFilename = "../testData/Cargos.ogg"
    elanXmlFilename = "newcuervo.eaf"
    targetDirectory = "../testTextPyData/Cuervo/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testTextPyData/Cuervo"
    tierGuideFile = "../testTextPyData/Cuervo/tierGuide.yaml"
    elanFile = os.path.join(projectDirectory, elanXmlFilename)
    ae = AudioExtractor(audioFilename, elanFile, targetDirectory)
    ae.determineStartAndEndTimes()
    ae.extract()
    times = ae.startStopTable
    text = Text(elanFile,
                audioFilename,
                grammaticalTermsFile=None,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    print("--- test_toHTML")

    text.getLineAsTable(0)

    htmlText = text.toHTML()
    # filename = "../testTextPyData/Cuervo/CuervoNew.html"
    # f = open(filename, "w")
    # f.write(indent(htmlText))
    # f.close()

    if (display):
        os.system("open %s" % filename)
コード例 #2
0
def test_praying_6_Line_from_webapp(display):
    print("--- test_praying_6_Line_from_webappn")
    audioFilename = "../testData/Cargos.ogg"
    elanXmlFilename = "../testData/s/praying.eaf"
    targetDirectory = "../testData/s/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testData/s"
    tierGuideFile = "../testData/s/tierGuide.yaml"
    grammaticalTermsFile = "../testData/s/grammaticalTerms.txt"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.determineStartAndEndTimes()
    times = ae.startStopTable
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    # text.getTable(1)
    display = False
    htmlText = text.toHTML()
    if (display):
        filename = "6test.html"
        f = open(filename, "w")
        f.write(indent(htmlText))
        f.close()
        os.system("open %s" % filename)
コード例 #3
0
ファイル: test_TextPy.py プロジェクト: davidjamesbeck/slexil
def test_GhostWagon(display,extract):
    '''tests .eaf file with empty and missing line or translation annotations'''

    print("--- test_GhostWagon")

    audioFilename = "../testTextPyData/GhostInWagon/GhostInWagon.ogg"
    elanXmlFilename = "../testTextPyData/GhostInWagon/GhostInWagon_original.eaf"
    targetDirectory = "../testTextPyData/GhostInWagon/audio"
    soundFile = os.path.join(targetDirectory, "GhostInWagon.ogg")
    projectDirectory = "../testTextPyData/GhostInWagon"
    tierGuideFile = "../testTextPyData/Cuervo/tierGuide.yaml"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    if extract:
        ae.extract()
    times = ae.startStopTable

    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=None,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    htmlText = text.toHTML()
    if (display):
        filename = "../testTextPyData/GhostInWagon/GhostInWagon.html"
        f = open(filename, "w")
        f.write(indent(htmlText))
        f.close()
        os.system("open %s" % filename)
コード例 #4
0
ファイル: test_TextPy.py プロジェクト: davidjamesbeck/slexil
def test_AYAFW(display,audioFilename,extract):
    print("--- test_AYAFW")
    # audioFilename = "../testData/Cargos.ogg"
    elanXmlFilename = "../testTextPyData/AYAFW/AYAFW.eaf"
    targetDirectory = "../testTextPyData/AYAFW/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testTextPyData/AYAFW"
    tierGuideFile = "../testTextPyData/AYAFW/tierGuide.yaml"
    grammaticalTermsFile = "../testTextPyData/AYAFW/abbreviations.txt"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    if extract:
        ae.extract()
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)  # ,
    # 				startStopTable=times)

    # IjalLine.getTable(1)

    htmlText = text.toHTML()
    if (display):
        filename = "../testTextPyData/AYAFW/test_AYAFW.html"
        f = open(filename, "w")
        f.write(indent(htmlText))
        f.close()
        os.system("open %s" % filename)
コード例 #5
0
ファイル: text.py プロジェクト: davidjamesbeck/slexil
 def __init__(self,
              xmlFilename,
              soundFileName,
              grammaticalTermsFile,
              tierGuideFile,
              projectDirectory,
              quiet=True):
     self.xmlFilename = xmlFilename
     self.soundFileName = soundFileName
     self.audioPath = "audio"
     self.audioFileType = self.soundFileName[-3:]
     self.grammaticalTermsFile = grammaticalTermsFile
     self.tierGuideFile = tierGuideFile
     self.projectDirectory = projectDirectory
     self.validInputs()
     self.quiet = quiet
     self.xmlDoc = etree.parse(self.xmlFilename)
     with open(tierGuideFile, 'r') as f:
         self.tierGuide = yaml.safe_load(f)
     self.speechTier = self.tierGuide['speech']
     self.speechTierList = identifyLines.getList(self.xmlDoc,
                                                 self.tierGuide)
     self.lineCount = len(self.speechTierList)
     if os.path.isfile(os.path.join(projectDirectory, "ERRORS.log")):
         os.remove(os.path.join(projectDirectory, "ERRORS.log"))
     logging.basicConfig(filename=os.path.join(projectDirectory,
                                               "ERRORS.log"),
                         format="%(levelname)s %(message)s")
     logging.getLogger().setLevel(logging.WARNING)
     targetDirectory = os.path.join(projectDirectory, "audio")
     self.audio = AudioExtractor(soundFileName, xmlFilename,
                                 targetDirectory)
コード例 #6
0
ファイル: test_TextPy.py プロジェクト: davidjamesbeck/slexil
def test_Inferno(display,audioFilename,extract):
    print("--- test_Inferno")
    try:
        assert(os.path.exists("../testTextPyData/Inferno/audio"))
    except AssertionError:
        os.mkdir("../testTextPyData/Inferno/audio")

    # audioFilename = "../testTextPyData/Inferno/inferno-threeLines.wav"
    elanXmlFilename = "../testTextPyData/Inferno/inferno-threeLines.eaf"
    targetDirectory = "../testTextPyData/Inferno/audio"
    soundFile = os.path.join(targetDirectory, audioFilename)
    projectDirectory = "../testTextPyData/Inferno"
    tierGuideFile = "../testTextPyData/Inferno/tierGuide.yaml"
    grammaticalTermsFile = "../testTextPyData/Inferno/abbreviations.txt"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    if extract:
        ae.extract()
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    htmlText = text.toHTML()
    if (display):
        filename = "../testTextPyData/Inferno/inferno-threeLines.html"
        f = open(filename, "w")
        f.write(indent(htmlText))
        f.close()
        os.system("open %s" % filename)
コード例 #7
0
ファイル: test_TextPy.py プロジェクト: davidjamesbeck/slexil
def test_Cuervo(display,audioFilename,extract):
    print("--- test_Cuervo")

    # audioFilename = "../testData/Cargos.ogg"
    elanXmlFilename = "../testTextPyData/Cuervo/newcuervo.eaf"
    targetDirectory = "../testTextPyData/Cuervo/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testTextPyData/Cuervo"
    tierGuideFile = "../testTextPyData/Cuervo/tierGuide.yaml"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    if extract:
        ae.extract()
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=None,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    htmlText = text.toHTML()
    if (display):
        filename = "../testTextPyData/Cuervo/newcuervo.html"
        f = open(filename, "w")
        f.write(indent(htmlText))
        f.close()
        os.system("open %s" % filename)
コード例 #8
0
def createText():
    audioFilename = "../testData/Cargos.ogg"
    print("--- testing normal file")
    elanXmlFilename = "../infernoDemo/inferno-threeLines.eaf"
    validFile = validate_EAF(elanXmlFilename)
    print("--- testing file with broken HTML tags")
    elanXmlFilename = "../testData/praying/Prayer_broken-HTML_tags.eaf"
    validFile = validate_EAF(elanXmlFilename)
    if not validFile:
        return False
    print("--- testing file with HTML tags")
    elanXmlFilename = "../testData/praying/Prayer_HTML_tags.eaf"
    validFile = validate_EAF(elanXmlFilename)
    if not validFile:
        print("=== failed to validate file with tags")
    targetDirectory = "../testData/praying/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testData/praying"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.determineStartAndEndTimes()

    text = Text(
        elanXmlFilename,
        audioFilename,
        grammaticalTermsFile="../testData/praying/grammaticalTerms.txt",
        tierGuideFile="../testData/praying/tierGuide.yaml",
        projectDirectory=projectDirectory,
        quiet=True)
    return (text)
コード例 #9
0
def test_ogg(display):

    print("--- test_ogg")
    audioFilename = "inferno-threeLines.ogg"
    elanXmlFilename = "../testData/inferno-threeLines/inferno-threeLines.eaf"
    targetDirectory = "../testData/inferno-threeLines/audio"
    projectDirectory = "../testData/inferno-threeLines"
    soundFile = os.path.join(projectDirectory, audioFilename)
    print(soundFile)
    tierGuideFile = "../testData/inferno-threeLines/tierGuide.yaml"
    grammaticalTermsFile = "../testData/inferno-threeLines/grammaticalTerms.txt"
    ae = AudioExtractor(soundFile, elanXmlFilename, targetDirectory)
    ae.validInputs()
    ae.extract(False)
    times = ae.startStopTable
    text = Text(elanXmlFilename,
                soundFile,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    htmlText = text.toHTML()
    if (display):
        filename = "../testData/inferno-threeLines/inferno-threeLinesogg.html"
        f = open(filename, "w")
        f.write(indent(htmlText))
        f.close()
        os.system("open %s" % filename)
コード例 #10
0
def test_Lazy_extraction():
    elanXmlFilename = "../testTextPyData/Lazybones/Lazybones.eaf"
    targetDirectory = "../testTextPyData/Lazybones/audio"
    projectDirectory = "../testTextPyData/Lazybones"
    tierGuideFile = "../testTextPyData/Lazybones/tierGuide.yaml"
    grammaticalTermsFile = "../testTextPyData/Lazybones/abbreviations.txt"
    audioFilename = "/Users/David/OpenSource/github/OldSlexilTestData/TEX_Lazy/4_TEX_TheLazyWoman.wav"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.extract()
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)
コード例 #11
0
def createText():
	audioFilename = "../testData/Cargos.ogg"
	elanXmlFilename="../testData/featherSnake/featherSnake.eaf"
	targetDirectory = "../testData/featherSnake/audio"
	soundFile = os.path.join(targetDirectory,"Cargos.ogg")
	ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
	ae.determineStartAndEndTimes()
	times = ae.startStopTable
	text = Text(elanXmlFilename,
				audioFilename,
				grammaticalTermsFile="../testData/featherSnake/grammaticalTerms.txt",
				tierGuideFile="../testData/featherSnake/tierGuide.yaml",
				projectDirectory="../testData/featherSnake",
				#startStopTable=times,
				quiet=False)
	return(text)
コード例 #12
0
def createText():
	audioFilename = "../testData/Cargos.ogg"
	elanXmlFilename="../testData/loco/loco.eaf"
	targetDirectory = "../testData/loco/audio"
	soundFile = os.path.join(targetDirectory,"Cargos.ogg")
	projectDirectory="../testData/loco"
	tierGuideFile="../testData/loco/tierGuide.yaml"
	grammaticalTermsFile="../testData/loco/grammaticalTerms.txt"
	ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
	ae.determineStartAndEndTimes()
	times = ae.startStopTable	
	text = Text(elanXmlFilename,
				audioFilename,
				grammaticalTermsFile=grammaticalTermsFile,
				tierGuideFile=tierGuideFile,
				projectDirectory=projectDirectory)# ,
# 				startStopTable=times)

	return(text)
コード例 #13
0
def createText():
    audioFilename = "../testData/aktzini/18-06-03Aktzini-GA.wav"
    elanXmlFilename = "../testData/aktzini/18-06-03Aktzini-GA.eaf"
    targetDirectory = "../testData/aktzini/audio"
    soundFile = os.path.join(targetDirectory, audioFilename)
    projectDirectory = "../testData/aktzini"
    tierGuideFile = "../testData/aktzini/tierGuide.yaml"
    grammaticalTermsFile = "../testData/aktzini/grammaticalTerms.txt"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.extract()
    ae.determineStartAndEndTimes()
    times = ae.startStopTable
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory,
                quiet=False)
    return (text)
コード例 #14
0
def createText():
    audioFilename = "inferno-threeLines.wav"
    elanXmlFilename = "../testData/inferno-threeLines/inferno-threeLines.eaf"
    targetDirectory = "../testData/inferno-threeLines/audio"
    soundFile = os.path.join(targetDirectory, audioFilename)
    projectDirectory = "../testData/inferno-threeLines"
    tierGuideFile = "../testData/inferno-threeLines/tierGuide.yaml"
    grammaticalTermsFile = "../testData/inferno-threeLines/grammaticalTerms.txt"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.determineStartAndEndTimes()

    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory,
                quiet=True)

    return (text)
コード例 #15
0
def test_inferno_plus():
    print("--- test_inferno_plus")

    elanXmlFilename = "../testData/test_alignable/inferno-threeLines_plus_one.eaf"
    audioFilename = "../testData/test_alignable/inferno-threeLines.wav"
    targetDirectory = "../testData/test_alignable/audio"
    fileList = os.listdir(targetDirectory)
    for f in fileList:
        target = os.path.join(targetDirectory, f)
        os.remove(target)
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.determineStartAndEndTimes()
    ae.extract()
    fileList = [
        f for f in os.listdir(targetDirectory) if not f.startswith('.')
    ]
    try:
        assert (len(fileList) == 3)
        print("There is the correct number of audiophrases.")
    except AssertionError as e:
        print("Error: There are %d audiophrases rather than 3" % len(fileList))
コード例 #16
0
def test_aktzini():
    print("--- test_aktzini")

    elanXmlFilename = "../testData/aktzini/18-06-03Aktzini-GA.eaf"
    audioFilename = "../testData/aktzini/18-06-03Aktzini-GA.wav"
    targetDirectory = "../testData/aktzini/audio"
    fileList = os.listdir(targetDirectory)
    for f in fileList:
        target = os.path.join(targetDirectory, f)
        os.remove(target)
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.determineStartAndEndTimes()
    ae.extract()
    fileList = [
        f for f in os.listdir(targetDirectory) if not f.startswith('.')
    ]
    try:
        assert (len(fileList) == 16)
        print("There is the correct number of audiophrases.")
    except AssertionError as e:
        print("Error: There are %d audiophrases rather than 3" % len(fileList))
コード例 #17
0
def test_Lazybones():
    print("--- test_Lazybones")

    elanXmlFilename = "../testTextPyData/Lazybones/Lazybones.eaf"
    audioFilename = "../testData/Cargos.ogg"
    targetDirectory = "../testTextPyData/Lazybones/audio"
    fileList = os.listdir(targetDirectory)
    for f in fileList:
        target = os.path.join(targetDirectory, f)
        os.remove(target)
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    ae.determineStartAndEndTimes()
    ae.extract()
    fileList = [
        f for f in os.listdir(targetDirectory) if not f.startswith('.')
    ]
    try:
        assert (len(fileList) == 396)
        print("There is the correct number of audiophrases.")
    except AssertionError as e:
        print("Error: There are %d audiophrases rather than 396" %
              len(fileList))
コード例 #18
0
ファイル: test_TextPy.py プロジェクト: davidjamesbeck/slexil
def test_Prayer(display,audioFilename,extract):
    print("--- test_Prayer")
    # audioFilename = "../testData/Cargos.ogg"
    elanXmlFilename = "../testTextPyData/Prayer_superscript/praying.eaf"
    targetDirectory = "../testTextPyData/Prayer_superscript/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testTextPyData/Prayer_superscript"
    tierGuideFile = "../testTextPyData/Prayer_superscript/tierGuide.yaml"
    grammaticalTermsFile = "../testTextPyData/Prayer_superscript/grammaticalTerms.txt"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    if extract:
        ae.extract()
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)  # ,
    # 				startStopTable=times)

    # IjalLine.getTable(1)

    try:
        htmlText = text.toHTML()
        if (display):
            filename = "../testTextPyData/Prayer_superscript/test_Prayer.html"
            f = open(filename, "w")
            f.write(indent(htmlText))
            f.close()
            os.system("open %s" % filename)
    except TooManyMorphsError as e:
        print(
            "EAF error: There are more morphs (%d) than glosses (%d) in line %s." % (e.morphs, e.glosses, e.lineNumber))
    except TooManyGlossesError as e:
        print(
            "EAF error: There are more glosses (%d) than morphs (%d) in line %s." % (e.glosses, e.morphs, e.lineNumber))
    except EmptyTiersError as e:
        print("EAF error: There are empty tiers or incomplete glosses after line %s" % e.lineNumber)
コード例 #19
0
ファイル: test_TextPy.py プロジェクト: davidjamesbeck/slexil
def test_Lazybones(display,audioFilename,extract):
    print("--- test_Lazybones")

    # audioFilename = "../testData/Cargos.ogg"
    elanXmlFilename = "../testTextPyData/Lazybones/Lazybones.eaf"
    targetDirectory = "../testTextPyData/Lazybones/audio"
    soundFile = os.path.join(targetDirectory, "Cargos.ogg")
    projectDirectory = "../testTextPyData/Lazybones"
    tierGuideFile = "../testTextPyData/Lazybones/tierGuide.yaml"
    grammaticalTermsFile = "../testTextPyData/Lazybones/abbreviations.txt"
    # audioFilename ="/Users/David/OpenSource/github/OldSlexilTestData/TEX_Lazy/4_TEX_TheLazyWoman.wav"
    ae = AudioExtractor(audioFilename, elanXmlFilename, targetDirectory)
    if extract:
        ae.extract()
    text = Text(elanXmlFilename,
                audioFilename,
                grammaticalTermsFile=grammaticalTermsFile,
                tierGuideFile=tierGuideFile,
                projectDirectory=projectDirectory)

    try:
        htmlText = text.toHTML()
        if (display):
            filename = "../testTextPyData/Lazybones/test_Lazybones.html"
            f = open(filename, "w")
            f.write(indent(htmlText))
            f.close()
            os.system("open %s" % filename)
    except TooManyMorphsError as e:
        print(
            "EAF error: There are more morphs (%d) than glosses (%d) in line %s." % (e.morphs, e.glosses, e.lineNumber))
    except TooManyGlossesError as e:
        print(
            "EAF error: There are more glosses (%d) than morphs (%d) in line %s." % (e.glosses, e.morphs, e.lineNumber))
    except EmptyTiersError as e:
        print("EAF error: There are empty tiers or incomplete glosses after line %s" % e.lineNumber)