예제 #1
0
    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")
for tmpfile, dest in toMove:
    oldDest = dest
    try:
        os.rename(tmpfile, gradint.synthCache + os.sep + dest)
    except OSError:  # not a valid filename
        while gradint.fileExists(gradint.synthCache + os.sep +
                                 ("__file%d" % count) +
예제 #2
0
#!/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 = {}