def alignDependingOnWithDuration(URIrecordingNoExt, whichSection, pathToComposition, withDuration, withSynthesis, evalLevel, params, usePersistentFiles, htkParser): ''' call alignment method depending on whether duration or htk selected ''' Phonetizer.initLookupTable(withSynthesis) tokenLevelAlignedSuffix, phonemesAlignedSuffix = determineSuffix(withDuration, withSynthesis, evalLevel) if withDuration: alignmentErrors, detectedWordList, grTruthDurationWordList = alignOneChunk(URIrecordingNoExt, pathToComposition, whichSection, htkParser, params, evalLevel, usePersistentFiles) else: URIrecordingAnno = URIrecordingNoExt + ANNOTATION_EXT URIrecordingWav = URIrecordingNoExt + AUDIO_EXTENSION # new makamScore used lyricsObj = loadLyrics(pathToComposition, whichSection) lyrics = lyricsObj.__str__() # in case we are at no-lyrics section if not lyrics or lyrics =='_SAZ_': logger.warn("skipping section {} with no lyrics ...".format(whichSection)) return [], [], [], [] outputHTKPhoneAlignedURI = Aligner.alignOnechunk(MODEL_URI, URIrecordingWav, lyrics.__str__(), URIrecordingAnno, '/tmp/', withSynthesis) alignmentErrors = evalAlignmentError(URIrecordingAnno, outputHTKPhoneAlignedURI, evalLevel) detectedWordList = outputHTKPhoneAlignedURI grTruthDurationWordList = [] # store decoding results in a file FIXME: if with duration it is not mlf detectedAlignedfileName = [] detectedAlignedfileName = tokenList2TabFile(detectedWordList, URIrecordingNoExt, tokenLevelAlignedSuffix) return alignmentErrors, detectedWordList, grTruthDurationWordList, detectedAlignedfileName
def loadMakamScore(pathToComposition): ''' same as loadLyrics, but return MakamScore, so that all lyrics can be shown if needed ''' Phonetizer.initLookupTable(False) os.chdir(pathToComposition) pathTotxt = os.path.join(pathToComposition, glob.glob("*.txt")[0]) listExtensions = ["sections.json", "sections.tsv", "sections.txt"] sectionFiles = findFileByExtensions(pathToComposition, listExtensions) sectionFile = sectionFiles[0] pathToSectionTsv = os.path.join(pathToComposition, sectionFile) makamScore = MakamScore(pathTotxt, pathToSectionTsv) return makamScore
def loadMakamScore(pathToComposition): ''' same as loadLyrics, but return MakamScore, so that all lyrics can be shown if needed ''' Phonetizer.initLookupTable(False) os.chdir(pathToComposition) pathTotxt = os.path.join(pathToComposition, glob.glob("*.txt")[0]) listExtensions = [ "sections.json", "sections.tsv", "sections.txt"] sectionFiles = findFileByExtensions(pathToComposition, listExtensions) sectionFile = sectionFiles[0] pathToSectionTsv = os.path.join(pathToComposition, sectionFile) makamScore = MakamScore(pathTotxt, pathToSectionTsv ) return makamScore
def syllables2Lyrics(syllables): listWords = [] for syllable in syllables: # word of only one syllable word, dummy = createWord([], syllable) listWords.append(word) Phonetizer.initLookupTable(True, 'phonemeMandarin2METUphonemeLookupTableSYNTH') # load phonetic dict Phonetizer.initPhoneticDict('syl2phn46.txt') ## 3) create lyrics # here is called Syllable.expandToPhonemes. lyrics = Lyrics(listWords) return lyrics
def loadLyrics(pathToComposition, whichSection): Phonetizer.initLookupTable(False) os.chdir(pathToComposition) pathTotxt = os.path.join(pathToComposition, glob.glob("*.txt")[0]) listExtensions = ["sections.json", "sections.tsv", "sections.txt"] sectionFiles = findFileByExtensions(pathToComposition, listExtensions) sectionFile = sectionFiles[0] pathToSectionTsv = os.path.join(pathToComposition, sectionFile) makamScore = MakamScore(pathTotxt, pathToSectionTsv) # phoneme IDs lyrics = makamScore.getLyricsForSection(whichSection) return lyrics
def loadLyrics(pathToComposition, whichSection): Phonetizer.initLookupTable(False) os.chdir(pathToComposition) pathTotxt = os.path.join(pathToComposition, glob.glob("*.txt")[0]) listExtensions = [ "sections.json", "sections.tsv", "sections.txt"] sectionFiles = findFileByExtensions(pathToComposition, listExtensions) sectionFile = sectionFiles[0] pathToSectionTsv = os.path.join(pathToComposition, sectionFile) makamScore = MakamScore(pathTotxt, pathToSectionTsv ) # phoneme IDs lyrics = makamScore.getLyricsForSection(whichSection) return lyrics
syllablesInCurrWord.append(currSyllable) beginIndex = beginIndex + 1 return listWords, beginIndex ################################################################################# if __name__ == "__main__": pathTxt= '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey.txt' pathTsv= '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey.sections.tsv' pathTxt= '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data-synthesis/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin.txt' pathTsv= '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data-synthesis/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin.sections.tsv' Phonetizer.initLookupTable(False) symbTrParser = SymbTrParser(pathTxt, pathTsv) symbTrParser.syllables2Lyrics() # print them, put instrument as name print symbTrParser.sectionLyrics[5] print symbTrParser.sectionLyrics[0]
#restart counting syllablesInCurrWord = [] else: syllablesInCurrWord.append(currSyllable) beginIndex = beginIndex + 1 return listWords, beginIndex ################################################################################# if __name__ == "__main__": pathTxt = '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey.txt' pathTsv = '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey/nihavent--sarki--aksak--bakmiyor_cesm-i--haci_arif_bey.sections.tsv' pathTxt = '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data-synthesis/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin.txt' pathTsv = '/Users/joro/Documents/Phd/UPF/turkish-makam-lyrics-2-audio-test-data-synthesis/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin/nihavent--sarki--duyek--bir_ihtimal--osman_nihat_akin.sections.tsv' Phonetizer.initLookupTable(False) symbTrParser = SymbTrParser(pathTxt, pathTsv) symbTrParser.syllables2Lyrics() # print them, put instrument as name print symbTrParser.sectionLyrics[5] print symbTrParser.sectionLyrics[0]
def loadLyricsFromTextGridSentence(currSentence): Phonetizer.initLookupTable(True, 'phonemeMandarin2METUphonemeLookupTableSYNTH') syllables = currSentence[4] lyrics = syllables2Lyrics(syllables) return lyrics
pathHMMDuration = os.path.join(parentDir, 'AlignmentDuration') if pathHMMDuration not in sys.path: sys.path.append(pathHMMDuration) from Phonetizer import Phonetizer if __name__ == '__main__': aria = 'dan-xipi_02' aria = 'laosheng-xipi_02' aria = 'laosheng-erhuang_04' URI = '/Users/joro/Documents/Phd/UPF/arias_dev_01_t_70/' MusicXmlURI = URI + aria + '_score.xml' lyricsTextGrid = URI + aria + '.TextGrid' # MusicXmlURI = 'dan-xipi_01_score.xml' # lyricsTextGrid = 'dan-xipi_01.TextGrid' musicXMLParser = MusicXMLParser(MusicXmlURI, lyricsTextGrid) Phonetizer.initLookupTable(True, 'phonemeMandarin2METUphonemeLookupTableSYNTH') for i in range(len(musicXMLParser.listSentences)): print i, " ", musicXMLParser.getLyricsForSection(i) # for syll in musicXMLParser.listSyllables: # print syll
sys.path.append(pathHMMDuration) from Phonetizer import Phonetizer if __name__=='__main__': aria = 'dan-xipi_02' aria = 'laosheng-xipi_02' aria = 'laosheng-erhuang_04' URI = '/Users/joro/Documents/Phd/UPF/arias_dev_01_t_70/' MusicXmlURI = URI + aria + '_score.xml' lyricsTextGrid = URI + aria + '.TextGrid' # MusicXmlURI = 'dan-xipi_01_score.xml' # lyricsTextGrid = 'dan-xipi_01.TextGrid' musicXMLParser = MusicXMLParser(MusicXmlURI, lyricsTextGrid) Phonetizer.initLookupTable(True, 'phonemeMandarin2METUphonemeLookupTableSYNTH') for i in range(len(musicXMLParser.listSentences)): print i, " ", musicXMLParser.getLyricsForSection(i) # for syll in musicXMLParser.listSyllables: # print syll