Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
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)
Exemple #4
0
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)
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)
Exemple #6
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)
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)
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)
Exemple #9
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))
Exemple #10
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))
Exemple #11
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))
Exemple #12
0
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)
Exemple #13
0
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)