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)
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)
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_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 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)
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_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)
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)