def serializePhonemesForSection(self, whichSection, outputFileName): ''' list of all phonemes. print to file @param outputFileName ''' lyrics = self.getLyricsForSection(whichSection) if not lyrics: sys.exit("no lyrics") writeListToTextFile(lyrics.phonemesNetwork, None, outputFileName ) return lyrics.phonemesNetwork
def serializePhonemesForSection(self, whichSection, outputFileName): ''' list of all phonemes. print to file @param outputFileName ''' lyrics = self.getLyricsForSection(whichSection) if not lyrics: sys.exit("no lyrics") writeListToTextFile(lyrics.phonemesNetwork, None, outputFileName) return lyrics.phonemesNetwork
def serializeIndices(makamScore, whichSection, withDurations, URI_IndicesFile): ''' helper method ''' if withDurations: indices = getBeginIndicesWords_Withdurations(makamScore, whichSection) else: indices = getIndicesPhonemes(makamScore, whichSection) writeListToTextFile(indices, None, URI_IndicesFile)
def serializeIndices( makamScore, whichSection, withDurations, URI_IndicesFile): ''' helper method ''' if withDurations: indices = getBeginIndicesWords_Withdurations(makamScore, whichSection) else: indices = getIndicesPhonemes(makamScore, whichSection) writeListToTextFile(indices, None, URI_IndicesFile )
def serializeLyrics(lyrics, outputFileNoExt): ''' @deprecated ''' writeListToTextFile(lyrics.phonemesNetwork, None, outputFileNoExt + '.phn') listDurations = [] for phoneme_ in lyrics.phonemesNetwork : listDurations.append(phoneme_.duration) writeListToTextFile(listDurations, None, outputFileNoExt + '.dur') # lyrics.printSyllables() lyrics.printPhonemeNetwork()
def METULyrics2phoneticDict(inputFileName, outputFileName, withSynthesis): pronunciationList = [] inputFileHandle = open(inputFileName, 'r') outputFileHandle = open(outputFileName, 'w') METUlyrics = inputFileHandle.read() METUlyrics = METUlyrics.replace('\n', ' ') words = METUlyrics.split() # sort and uniq the words uniqWords = list(set(words)) uniqWords.sort() for word in uniqWords: # list of METU phonemes for current word phonemeList = PhonetizerOld.grapheme2Phoneme(word, withSynthesis) # create a pronunciation entry wordAndPronunciation = word + "\t" for phoneme in phonemeList: wordAndPronunciation += phoneme wordAndPronunciation += " " # here add sp wordAndPronunciation += 'sp' wordAndPronunciation = wordAndPronunciation.rstrip() wordAndPronunciation += '\n' pronunciationList.append(wordAndPronunciation) pronunciationList.append('sil\tsil\n') pronunciationList.append('NOISE\tNOISE\n') writeListToTextFile(pronunciationList, None, outputFileName) inputFileHandle.close() return
def setDurForStates(self, listDurations): ''' mapping of state to its duration (in number of frames). @param listDurations read from state.Durations ''' if listDurations == []: for stateWithDur_ in self.statesNetwork: listDurations.append(stateWithDur_.getDurationInFrames()) # sanity check if len(listDurations) != self.n: sys.exit("#Durations from list = {}, whereas #states={}".format(len(listDurations), self.n )) self.durationMap = numpy.array(listDurations, dtype=int) # DEBUG: writeListToTextFile(self.durationMap, None , PATH_LOGS + '/durationMap') # STUB # self.durationMap = numpy.arange(1,self.n+1) # self.durationPdf = DurationPdf(self.R_MAX, self.usePersistentFiles) self.R_MAX = int( self.durationPdf.getMaxRefDur(numpy.amax(self.durationMap) ) )
def parseScoreAndSerialize(pathToComposition, whichSection, withDurations): ''' Main method for DTW in matlab prints sequence of phonemes, sequence of durarions. indices of word start positions ''' makamScore = MakamScore.loadScore(pathToComposition) # DEBUG makamScore.printSyllables(whichSection) # 1. phoneme IDs and durations loaded listPhonemes = makamScore.serializePhonemesForSection( whichSection, '/tmp/test.phn') listDurations = [] for phoneme_ in listPhonemes: listDurations.append(phoneme_.duration) writeListToTextFile(listDurations, None, '/tmp/test.durations') # 2. indices serializeIndices(makamScore, whichSection, withDurations, '/tmp/test.indices')
def parseScoreAndSerialize(pathToComposition, whichSection, withDurations): ''' Main method for DTW in matlab prints sequence of phonemes, sequence of durarions. indices of word start positions ''' makamScore = MakamScore.loadScore(pathToComposition) # DEBUG makamScore.printSyllables(whichSection) # 1. phoneme IDs and durations loaded listPhonemes = makamScore.serializePhonemesForSection(whichSection, '/tmp/test.phn') listDurations = [] for phoneme_ in listPhonemes : listDurations.append(phoneme_.duration) writeListToTextFile(listDurations, None, '/tmp/test.durations') # 2. indices serializeIndices(makamScore, whichSection, withDurations, '/tmp/test.indices')