(textToSynth + "_" + langToSynth + gradint.dotmp3).lower()): return # it's already been done if synth_fileExists(("__rejected_" + textToSynth + "_" + langToSynth + gradint.dotwav).lower()) or synth_fileExists( ("__rejected_" + textToSynth + "_" + langToSynth + gradint.dotmp3).lower()): return # it's been rejected by the GUI if (textToSynth.lower(), langToSynth) in generating: return # we're already generating it generating[(textToSynth.lower(), langToSynth)] = 1 sys.stderr.write("Generating %s\n" % (textToSynth, )) toMove.append((gradint.synth_event(langToSynth, textToSynth).getSound(), (textToSynth + "_" + langToSynth + gradint.dotwav).lower())) for _, s1, s2 in gradint.scanSamples() + gradint.parseSynthVocab( gradint.vocabFile): if type(s1) == type([]): [maybe_cache(i, gradint.samplesDirectory) for i in s1] else: maybe_cache(s1, gradint.samplesDirectory) maybe_cache(s2, gradint.samplesDirectory) for f in gradint.AvailablePrompts().lsDic.values(): for f2 in f: if f2.endswith("txt"): maybe_cache(f2, gradint.promptsDirectory) for l in langs: gradint.get_synth_if_possible(l).finish_makefile() count = 0 gradint.soundCollector = 0 if toMove: sys.stderr.write("Renaming\n") else: sys.stderr.write("No additional words need to be synthesized\n")
def decache(s): textToSynth, langToSynth = getTxtLang(s) if not textToSynth: return textToSynth = "_" + textToSynth # sporadic mode generating[(textToSynth.lower(), langToSynth)] = 1 # don't re-generate it s = textToSynth.lower().encode('utf-8') + "_" + langToSynth if delete_old and langToSynth == languageToCache: for ext in [dottxt, dotwav, dotmp3]: if s + ext in scld: os.remove(gradint.synthCache + os.sep + s + ext) del scld[s + ext] samples = gradint.scanSamples( ) # MUST call before sporadic so variantFiles is populated if sporadic: pd = gradint.ProgressDatabase() if delete_old: print "Checking for old words to remove" else: print "Sporadic mode: Checking for old words to avoid" for t, prompt, target in pd.data: if t >= gradint.reallyKnownThreshold: if type(prompt) == type([]): for p in prompt: decache(p) else: decache(prompt) decache(target) count = 0
# for summarizing it to a teacher or native speaker. # Reads from progressFile and progressFileBackup. # Version 1.04 (c) 2011 Silas S. Brown. License: GPL # Example use: # python lesson-table.py | ssh some-server 'mutt -e "set record = \"\";" -e "set charset=\"utf-8\"; set send_charset=\"utf-8\"; set content_type=\"text/html\";" to-address -s "Gradint report"' || echo Send failed samples_url = None # or "http://example.org/path/to/samples/" import gradint, os newpf = gradint.progressFile gradint.progressFile = gradint.progressFileBackup gradint.pickledProgressFile = None mergeIn = gradint.scanSamples() + gradint.parseSynthVocab(gradint.vocabFile) oldProg = gradint.ProgressDatabase(alsoScan=0) oldProg.data += oldProg.unavail # because it might be available in newProg gradint.mergeProgress(oldProg.data, mergeIn) opd = {} for tries, l1, l2 in oldProg.data: key = gradint.norm_filelist(l1, l2) if tries: opd[key] = tries del oldProg gradint.progressFile = newpf newProg = gradint.ProgressDatabase(alsoScan=0) gradint.mergeProgress(newProg.data, mergeIn) del mergeIn changes = [] count = 0
if not langToSynth == lang: return # we're not listing that language if textToSynth.lower() in listed: return d = textToSynth.decode('utf-8') if hanzi_only and langToSynth == "zh" and not gradint.fix_compatibility( d).replace(" ", "") == gradint.hanzi_and_punc(d): return global wroteChars if paragraph_size and wroteChars and wroteChars + len(d) > paragraph_size: toList.append("") wroteChars = 0 wroteChars += (len(d) + 2) # comma and \n toList.append(textToSynth + ",") listed[textToSynth.lower()] = 1 inList = gradint.scanSamples() + gradint.parseSynthVocab(gradint.vocabFile) if reverse_grouping: inList.reverse() # will be reversed again on output for _, s1, s2 in inList: if type(s1) == type([]): [maybe_list(i, gradint.samplesDirectory) for i in s1] else: maybe_list(s1, gradint.samplesDirectory) maybe_list(s2, gradint.samplesDirectory) for f in gradint.AvailablePrompts().lsDic.values(): for f2 in f: if f2.endswith("txt"): maybe_list(f2, gradint.promptsDirectory) if reverse_grouping: toList.reverse() for i in range(len(toList) + 1): if i and (i == len(toList) or toList[i] == "\n") and toList[i - 1].endswith(","):