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 toMove = []
# 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 newProg.data.sort() for tries, l1, l2 in newProg.data:
#!/usr/bin/env python2 # Script to recover vocabulary from the "unavailable" # entries in Gradint's progress file. Use if for some # reason the vocab file has been truncated (e.g. filesystem # problems) and this propagated to your backup system before # you noticed. # v1.0 (c) 2012 Silas S. Brown. License: GPL ignore_words_that_are_also_in_backup_unavail = True # if the fault just happened import gradint, time gradint.availablePrompts = gradint.AvailablePrompts() d = gradint.ProgressDatabase() if ignore_words_that_are_also_in_backup_unavail: gradint.progressFile = gradint.progressFileBackup gradint.pickledProgressFile = None d2 = gradint.ProgressDatabase(alsoScan=0) for x in d2.unavail: d.unavail.remove(x) print "# Words recovered %d-%02d-%02d" % time.localtime()[:3] print "# - capitalisation and comments are missing; order may be approximate" gradint.reallyKnownThreshold = 0 poems, line2index = gradint.find_known_poems(d.unavail) output = [] doneAlready = {}