FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ssb22/gradint
  • st822/gradint
2 results
Show changes
Showing
with 66 additions and 40 deletions
......@@ -10,26 +10,20 @@ C:\Windows\system32 or somewhere.
All require Python (from www.python.org). All systems
except Windows have that anyway if you can run gradint.
However, some of these utilities are still Python2-only,
while the main Gradint is now compatible with both 2 and 3.
SPLITTING SOUND FILES
---------------------
splitter.py - lets you split a long recording into
individual files while you listen to the recording. Needs
fast reaction times. Works best with recordings that are
not TOO big (max 5 to 10 minutes at a time).
autosplit.py - splits a long recording into individual files
completely automatically, but only if the recording has been
made in near-broadcasting-studio conditions.
strip0.py - strips absolute silence off the beginning and
end of audio files (only useful if you're dealing with files
from a textbook CD or something)
manual-splitter.py (Unix only but not too difficult to
modify for other systems) - a helper script so that you can
use Audacity (or another sound editor) to split the file.
use Audacity (or another sound editor) to split the file
in non-realtime. (Realtime splitting can be done in Gradint.)
Use the "export selection as wav" command (you can assign a
hot-key to it), and you don't have to type in a different
filename each time because this script can run in the
......@@ -39,23 +33,11 @@ Useful if the recording is so messy that nothing else works.
OTHER PROCESSING
----------------
equalise.py - adjusts the volume of all files to a similar
level (usually increasing it also). Use this if the volume
of your recordings varies too much.
filemove.sh - a Unix script that can help you to re-organise
your directories while automatically reflecting those
changes in the gradint progress database, so the
re-organisation does not interfere with your progress so far
make-smaller - some brief notes on what to do in Unix if you
find that your collection of words is taking up too much
hard disk space (or too much space on the backup device)
email-lesson* - scripts that can help you to
automatically distribute daily lessons to students
using a web server with reminder emails
cache-synth.py and cleanup-cache.py - cache all words that
can be synthesized, and cleanup the cache (if you later
remove some words from the vocabulary). Useful if you have
......@@ -65,13 +47,11 @@ you run your gradint on.
list-synth.py and list2cache.py - aids in adding words from
online synthesizers (or real people) to the synth cache
vocab2html.py - make an HTML index for the synth
cache, with the help of vocab.txt
(you can also use it with espeak.cgi)
transliterate.py - make a transliterated vocab report
(for use with grep or on PDAs or whatever)
player.py - play
diagram.py - make a diagram of a gradint lesson
log2opl.py - translate a lesson to speaker's notes on EPOC PDA
trace.py - make a raytraced animation of a lesson
......@@ -4,13 +4,12 @@ import os, struct, sndhdr, sys
try: import winsound
except: winsound=None
macsound = (sys.platform.find("mac")>=0 or sys.platform.find("darwin")>=0)
if macsound: sys.stderr.write("Warning: You need to have qtplay (from gradint or wherever) in your PATH for this to work\n")
# python 3+:
try: input
except: input=lambda x:eval(raw_input(x))
startCount = 1 # or 0, or 485 or whatever
startCount = 0 # or however many WAVs already exist (should be even)
threshold = 10 # 3 is too low for recorded sound, but if using speech synth you might want to set it to 1
shortestSilence = 0.3
......@@ -18,17 +17,29 @@ shortestSound = 0.4
if len(sys.argv)>1: exec(" ".join(sys.argv[1:])) # so you can override the above on the command line
sox_8bit, sox_16bit, sox_32bit, sox_signed, sox_unsigned = "-b", "-w", "-l", "-s", "-u"
if not winsound: # adapted from gradint (see comments there)
sox_formats=os.popen("sox --help 2>&1").read()
sf2 = ' '.join(sox_formats.lower().split())
if sf2.startswith("sox: sox v"):
if sf2[10]==' ': soxMaj=15
else: soxMaj = int(sf2[10:sf2.index('.')])
else: soxMaj=0
if soxMaj>=14:
if soxMaj==14 and sf2[13]<'4': sox_8bit, sox_16bit, sox_32bit = "-1", "-2", "-4"
else: sox_8bit, sox_16bit, sox_32bit, sox_signed, sox_unsigned = "-b 8", "-b 16", "-b 32", "-e signed-integer", "-e unsigned-integer" # TODO: check the last one
def autosplit(filename,lang1,lang2,threshold):
(wtype,rate,channels,wframes,bits) = sndhdr.what(filename)
if bits==8:
soxBits="-b -u"
soxBits=sox_8bit+" "+sox_unsigned
structBits="B"
elif bits==16:
soxBits="-w -s"
soxBits=sox_16bit+" "+sox_signed
structBits="h"
threshold *= 256
elif bits==32:
soxBits="-l -s"
soxBits=sox_32bit+" "+sox_signed
structBits="i"
threshold *= (256 * 256 * 256)
else: raise Exception("Unsupported bits per sample")
......@@ -47,7 +58,8 @@ def autosplit(filename,lang1,lang2,threshold):
(sounding, bytes) = nextSample()
if inSilence and not sounding and bytes: continue
elif bytes:
dataToWriteout.append(bytes)
if dataToWriteout or sounding:
dataToWriteout.append(bytes)
if sounding: numSilences = inSilence = 0
else: numSilences += 1
if numSilences >= int(shortestSilence*rate) or not bytes:
......@@ -64,8 +76,9 @@ def autosplit(filename,lang1,lang2,threshold):
open(fname, "wb").write(''.join(dataToWriteout))
os.system("sox %s \"%s\" \"%s.wav\"" % (soxParams,fname,fname))
os.unlink(fname)
print fname+".wav"
if winsound: winsound.PlaySound(fname+".wav",winsound.SND_FILENAME)
elif macsound: os.system("qtplay "+fname+".wav")
elif macsound: os.system("afplay "+fname+".wav")
else: os.system("play "+fname+".wav")
# Anyway, clear the output buffer
dataToWriteout = []
......
#!/usr/bin/env python
#!/usr/bin/env python2
# cache-synth.py [--test] language [language ...]
......@@ -9,6 +9,9 @@
# the same directory as gradint.py with all the
# settings.
# For a more advanced version of this, see the
# actually_generate option in synth-batchconvert-helper.py
import sys,os,time
langs = sys.argv[1:] ; testMode = False
if langs and langs[0]=='--test':
......
#!/usr/bin/env python
#!/usr/bin/env python2
# delete cached synthesized words that are not used
# (i.e. not mentioned in vocab.txt or samples).
......
#!/usr/bin/env python2
# diagram.py: script to generate diagrams of gradint lessons
# (C) 2008 Silas S. Brown. License: GPL
# gradint is run normally (passing any command-line arguments on)
# Gradint is run normally (passing any command-line arguments on)
# and then a diagram of the lesson it made is written to diagram.svg
# you can get .ps by doing: inkscape -p '> diagram.ps' diagram.svg
......@@ -59,7 +60,7 @@ def CompositeEvent_draw(self,startTime,pixelsPerSec,topY,height):
gradint.CompositeEvent.draw=CompositeEvent_draw
def Event_colour(self,language):
if hasattr(self,"wordToCancel"):
if self.makesSenseToLog():
if language==gradint.firstLanguage: return "yellow" # TODO: 2nd to 3rd lang etc?
else: return "green"
else: return "grey" # prompts
......
#!/bin/bash
SamplesDir="samples/" # Must include trailing /
ProgressFile="progress.txt"
if ! [ -e $SamplesDir ]; then echo "Error: $SamplesDir does not exist (are you in the right directory?)"; exit 1; fi
if ! [ -e $ProgressFile ]; then echo "Error: $ProgressFile does not exist (are you in the right directory?)";exit 1;fi
if test "a$1" == a; then
echo "Usage: $0 oldname newname"
echo "oldname and newname are relative to $SamplesDir, and can be prefixes of several files/directories"
echo "Moves files from one samples directory to another, keeping $ProgressFile adjusted. Make sure gradint is not running (including waiting for start) when in use."
exit 1
fi
Src=$1
Dest=$2
find "$SamplesDir" -follow -type f | grep "^$SamplesDir$Src" | \
while true; do read || break;
SrcFile=$REPLY
DestFile=$(echo "$SrcFile"|sed -e "s|^$SamplesDir$Src|$SamplesDir$Dest|")
mkdir -p "$DestFile" ; rmdir "$DestFile" # ensure parent dirs exist before moving file across
mv -b "$SrcFile" "$DestFile"
SrcFile=$(echo "$SrcFile"|sed -e "s|$SamplesDir||")
DestFile=$(echo "$DestFile"|sed -e "s|$SamplesDir||")
gzip -fdc "$ProgressFile" | sed -e "s|$SrcFile|$DestFile|g" > /tmp/newprog ; mv /tmp/newprog "$ProgressFile" # (ideally should re-write to batch these changes, but leave like this for now in case need to recover from unfinished operation)
done
rmdir "$SamplesDir$Src" 2>/dev/null >/dev/null # IF it's a directory
#!/usr/bin/env python
#!/usr/bin/env python2
# list-synth.py language [language ...]
# list all words that can be synthesized
......
#!/usr/bin/env python
#!/usr/bin/env python2
# list2cache.py language
......