Пример #1
0
             (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")
for tmpfile, dest in toMove:
Пример #2
0
        toMove.append(tm)
        scld[textToSynth.lower().encode('utf-8') + '_' + langToSynth +
             dotwav] = 1
        return
    generating[k] = 1
    global count
    while gradint.fileExists(newStuff + os.sep + str(count) + "_" +
                             langToSynth + dottxt):
        count += 1
    open(newStuff + os.sep + str(count) + "_" + langToSynth + dottxt,
         "w").write(textToSynth[len(sporadic):].encode('utf-16'))
    count += 1


print "Checking for new ones"
for _, s1, s2 in samples + gradint.parseSynthVocab(gradint.vocabFile):
    if type(s1) == type([]): [maybe_cache(i) for i in s1]
    else: maybe_cache(s1)
    maybe_cache(s2)

if toMove: sys.stderr.write("Renaming\n")
for tmpfile, dest in toMove:
    oldDest = dest
    try:
        rename(tmpfile, gradint.synthCache + os.sep + dest)
    except OSError:  # not a valid filename
        while gradint.fileExists(
                gradint.synthCache + os.sep + ("__file%d" % count) +
                dotwav) or gradint.fileExists(gradint.synthCache + os.sep +
                                              ("__file%d" % count) + dotmp3):
            count += 1
# 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
Пример #4
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(","):