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 7 additions and 388 deletions
Note: Now that gradint supports MP3 input, you
can replace your WAVs with MP3s instead of
following the instructions here. See samples/ReadmeMP3.txt
for notes on getting this to work. You can
update all progress.txt's with the change like
this:
for N in $(find . -name progress.txt); do sed -e "s/\.wav/.mp3/g" < $N > n ; mv n $N; done
and do the encoding itself (in-place) with:
for N in $(find samples|grep wav$); do lame --cbr -b 48 -h -m m $N $(echo $N|sed -e s/.wav$/.mp3) && rm $N; done
---------------------
To squash down to 128kbps (16k bytes/s), be in the directory above 'samples' and do:
for Dir in $(find samples/ -type d); do mkdir -p "compressed-$Dir"; done; for F in $(find samples/ -type f|grep wav$); do if test "$F" -nt "compressed-$F"; then sox "$F" -r 16000 -c 1 -b -u test.wav; if test $(wc -c test.wav|sed -e 's/ .*//') -lt $(wc -c "$F"|sed -e 's/ .*//'); then mv test.wav "compressed-$F"; else rm test.wav; cp -p "$F" "compressed-$F"; fi; fi; done; for F in $(find samples/|grep -v wav$); do cp -up "$F" "compressed-$F" 2>/dev/null; done
The result will be in a directory called compressed-samples. Any samples that were already smaller than the "compressed" versions, or anything that is not a .wav file, will simply be copied into compressed-samples uncompressed. Any files already in compressed-samples will not be touched unless the "samples" equivalent is newer. Additionally you may want to delete any samples in compressed-samples that are no longer in samples, in which case do this as well:
for F in $(find compressed-samples/ -type f); do if ! test -e $(echo "$F"|sed -e s/compressed-//); then rm "$F"; fi; done
To compress in place (erasing original files), go into samples directory and do:
for F in $(find . -type f|grep wav$); do sox "$F" -r 16000 -c 1 -b -u test.wav; if test $(wc -c test.wav|sed -e 's/ .*//') -lt $(wc -c "$F"|sed -e 's/ .*//'); then mv test.wav "$F"; else rm test.wav; fi; done
On some systems, 8-bit playback is noisy (e.g. because volume adjustments cause too many of those 8 bits to be lost); if you can't work around this then you could use 16-bit by deleting '-b -u' from the above commands, but the result will be twice as big.
#!/usr/bin/env python
# Program to support splitting a long sound file into
# several little ones.
# Needs 'sox' - if Windows, download from
# sox.sourceforge.net
# (e.g. http://prdownloads.sourceforge.net/sox/sox12172.zip
# - note gives a "select a mirror" dialogue) and put sox.exe
# in the same directory or on the path
# -----------------------
# lowpri: 2nd sort key by length ? (only matters if adding a lot of new words & phrases at same time)
import time,os,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")
def rawcut(allData,fromSecs,toSecs,rate=22050,bits=16,channels=1):
return allData[secbyte(fromSecs,rate,channels,bits):secbyte(toSecs,rate,channels,bits)]
def secbyte(sec,rate,channels,bits):
# Convert a time in seconds to a byte offset in the raw
# data
# Note: Result MUST be a multiple of bytesPerSample
# 'sec' is not necessarily an integer
sampleNo = int(0.5+sec*rate) # nearest integer sample no
bytesPerSample = channels*int(bits/8)
return sampleNo * bytesPerSample
def readTimings(langs):
if macsound: time.sleep(1) # OS X hack due to qtplay delay (1sec on an Intel 2GHz Core Duo running OSX 10.5)
sys.stdout.write("Starting clock\n")
# Now using time.time() rather than time.clock()
# due to clock units confusion
# Just have to hope the system is accurate enough
offset = time.time()
ret = [] ; ip=''
start = offset
while not ip=='q':
ip = raw_input(langs[len(ret)%len(langs)]+": ")
t = time.time()
if ip=="c" and ret: ret[-1]=(ret[-1][0],t-offset)
elif not ip: ret.append((start-offset,t-offset))
start = t
sys.stdout.write("Finishing at %f seconds\n" % (t-offset,))
return ret
def instructions():
sys.stdout.write("Press Return between samples\n")
sys.stdout.write("Enter 'c' to change the time of the last Return to this one\n")
sys.stdout.write("Enter 'x' to omit this bit (e.g. silence)\n")
sys.stdout.write("Enter 'q' when done (AFTER stopping last sample)\n")
sys.stdout.write("PRESS RETURN TO START\n")
raw_input()
def getParams():
wavFile=raw_input("Enter filename of main recording: ")
header = sndhdr.what(wavFile)
if not header:
sys.stdout.write("Problem opening that file\n")
return None
(wtype,rate,channels,wframes,bits) = header
sys.stdout.write("WAV file is %d-bit\n" % (bits,))
if bits==8: soxBits="-b -u" # unsigned
elif bits==16: soxBits="-w -s" # signed
elif bits==32: soxBits="-l -s" # signed
else:
sys.stdout.write("Unsupported bits per sample '%s'\n" % (bits,))
return None
soxParams = "-t raw %s -r %d -c %d" % (soxBits,rate,channels)
rawFile = wavFile + ".raw"
convertToRaw(soxParams,wavFile,rawFile)
lang1=lang2=None
while not lang1: lang1=raw_input("Enter first language on recording (e.g. zh): ")
interleaved=input("Are two languages interleaved? (1/0): ") # (horrible hack)
if interleaved:
while not lang2: lang2=raw_input("Enter second language on recording (e.g. en): ")
else:
lang2=lang1
sys.stdout.write("OK - should run this program again for other language's recording\n")
return soxParams,wavFile,rawFile,lang1,lang2,rate,bits,channels
def convertToWav(soxParams,rawFile,wavFile):
os.system("sox %s \"%s\" \"%s\"" % (soxParams,rawFile,wavFile))
def convertToRaw(soxParams,wavFile,rawFile):
os.system("sox \"%s\" %s \"%s\"" % (wavFile,soxParams,rawFile))
def main():
tuple=None
while not tuple: tuple=getParams()
soxParams,wavFile,rawFile,lang1,lang2,rate,bits,channels = tuple
mainLoop(soxParams,wavFile,rawFile,lang1,lang2,rate,bits,channels)
os.unlink(rawFile)
# Set lang1 & lang2 equal if not interleaving
def mainLoop(soxParams,wavFile,rawFile,lang1="zh",lang2="en",rate=22050,bits=16,channels=1):
allData=open(rawFile,"rb").read()
open(wavFile,"rb").read() # to cache before starting clock and 'play' (especailly because just loaded the separate raw data) (could also play from raw data if got sox)
instructions()
# Start sound asynchronously - hope for the best that
# the first clock reading is near enough to the actual
# start of the sound
if winsound: winsound.PlaySound(wavFile,winsound.SND_FILENAME | winsound.SND_ASYNC)
elif macsound: os.spawnlp(os.P_NOWAIT,"qtplay","qtplay",wavFile)
# else: os.spawnlp(os.P_NOWAIT,"play","play",wavFile)
# Problem: What if 'play' o/p's at slightly less than the correct rate - will think the cuts are further on in the file than they really are. (e.g. 16000Hz on a z61p Cygwin, "time play" shows it takes slightly longer than sox thinks the file is)
# Better convert to 44100 just to make sure.
else: os.system("sox \"%s\" -r 44100 -t wav - | play -t wav - &" % wavFile)
# Read timings, cut up, and write out the samples
samples = [ rawcut(allData,s,f,rate,bits,channels) for s,f in readTimings([lang1,lang2]) ]
formatString = "%0"+str(len(str(int(len(samples)/(2-(lang2==lang1))-1))))+"d_%s"
# (pad with 0s as necessary so it's in order)
# (len(samples)-1 gives highest number, so len(str(l..))
# gives number of digits in it)
for i in range(len(samples)):
if i%2: lang=lang2
else: lang=lang1
if lang1==lang2: c=i
else: c=int(i/2)
fname = formatString % (c,lang)
f=open(fname, "wb")
f.write(samples[i])
f.close()
convertToWav(soxParams,fname,fname+".wav")
os.unlink(fname)
sys.stdout.write("Written %s.wav\n" % (fname,))
if __name__=="__main__":
main()
#!/usr/bin/env python
# Program to strip any silence from the beginning/end of a
# sound file (must be real 0-bytes not background noise)
# (This is useful as a "splitter" post-processor when
# getting samples from CD-ROMs e.g. "Colloquial Chinese" -
# don't use audacity here because some versions of audacity
# distort 8-bit audio files)
# Needs 'sox' + splitter
from splitter import *
for wavFile in sys.argv[1:]:
# Figure out sox parameters
header = sndhdr.what(wavFile)
if not header: raise IOError("Problem opening %s" % (wavFile,))
(wtype,rate,channels,wframes,bits) = header
if bits==8: soxBits="-b -u" # unsigned
elif bits==16: soxBits="-w -s" # signed
elif bits==32: soxBits="-l -s" # signed
else: raise Exception("Unsupported bits per sample")
soxParams = "-t raw %s -r %d -c %d" % (soxBits,rate,channels)
rawFile = wavFile + ".raw"
# Now ready to convert to raw, and read it in
convertToRaw(soxParams,wavFile,rawFile)
o=open(rawFile,"rb")
allData=o.read()
o.close()
# Now figure out how many samples we can take out
bytesPerSample = channels*int(bits/8)
if bytesPerSample==1: silenceVal=chr(128)
else: silenceVal=chr(0)
startIdx = 0
while startIdx < len(allData):
if not allData[startIdx]==silenceVal: break
startIdx = startIdx + 1
startIdx = int(startIdx/bytesPerSample) * bytesPerSample
endIdx = len(allData)
while endIdx:
if not allData[endIdx-1]==silenceVal: break
endIdx = endIdx - 1
endIdx = endIdx - len(allData) # put it into -ve notatn
endIdx = int(endIdx/bytesPerSample) * bytesPerSample
endIdx = endIdx + len(allData) # avoid 0
sys.stderr.write("Debugger: Clipping %s to %d:%d\n" % (wavFile,startIdx,endIdx))
allData = allData[startIdx:endIdx]
# Write back the file, and convert it back to wav
o=open(rawFile,"wb")
o.write(allData)
o.close()
convertToWav(soxParams,rawFile,wavFile)
# Clean up
os.unlink(rawFile)
all:
echo "Please run 'make' in the directory above, not here."
exit 1
# This file is part of the source code of
program_name = "gradint v0.9927 (c) 2002-2009 Silas S. Brown. GPL v3+."
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This is the start of defaults.py - configuration defaults, automatically extracted from default settings.txt and advanced.txt, so user customisations don't have to be complete (helps with upgrades)
firstLanguage = "en"
secondLanguage = "zh"
outputFile = ""
compress_SH = False
outputFile_appendSilence = 0
if outputFile.endswith("cdr"): outputFile_appendSilence = 5
beepThreshold = 20
startAnnouncement = None
endAnnouncement = None
commentsToAdd = None
orderlessCommentsToAdd = None
otherLanguages = ["cant","ko","jp"]
possible_otherLanguages = ["cant","ko","jp","en","zh"]
maxLenOfLesson = 30*60
saveProgress = 1
ask_teacherMode = 0
maxNewWords = 5
maxReviseBeforeNewWords = 3
newInitialNumToTry = 5
recentInitialNumToTry = 3
newWordsTryAtLeast = 3
knownThreshold = 5
reallyKnownThreshold = 10
meaningTestThreshold = 20
randomDropThreshold = 14
randomDropLevel = 0.67
randomDropThreshold2 = 35
randomDropLevel2 = 0.97
shuffleConstant = 2.0
transitionPromptThreshold = 10
advancedPromptThreshold = 20
transitionPromptThreshold2 = 2
advancedPromptThreshold2 = 5
limit_words = max(1,int(maxNewWords * 0.4))
logFile = "log.txt"
briefInterruptLength = 10
synth_priorities = "eSpeak MacOS SAPI"
extra_speech = []
extra_speech_tofile = []
sapiVoices = {
}
synthCache = ""
synthCache_test_mode = 0
justSynthesize = ""
lily_file = "C:\\Program Files\\NeoSpeech\\Lily16\\data-common\\userdict\\userdict_chi.csv"
ptts_program = None
partialsDirectory = "partials"
betweenPhrasePause = 0.3
partials_are_sporadic = 0
partials_cache_file = ""
vocabFile = "vocab.txt"
samplesDirectory = "samples"
promptsDirectory = "samples"+os.sep+"prompts"
progressFile = "progress.txt"
progressFileBackup = "progress.bak"
pickledProgressFile = "progress.bin"
gui_output_directory = "output"
limit_filename = "!limit"
intro_filename = "_intro"
poetry_filename = "!poetry"
exclude_from_scan = "_disabled"
exclude_from_coverage = "z_try_again"
userNameFile="username.txt"
import_recordings_from = r"\My Documents"
max_extra_buttons = 12
GUI_translations={
"@variants-zh":[u"简体字",u"繁體字"],
"Word in %s":{"zh":u"%s词语","zh2":u"%s詞語"},
"Meaning in %s":{"zh":u"%s意思"},
"en":{"zh":u"英文"},
"zh":{"zh":u"中文"},
"press Control-V to paste":{"zh":u"剪贴: 打Ctrl+V","zh2":u"剪貼: 打Ctrl+V"},
"press Apple-V to paste":{"zh":u"剪贴: 打苹果+V","zh2":u"剪貼: 打蘋果+V"},
"Your first language":{"zh":u"你的语言","zh2":u"你的語言"},
"second":{"zh":u"学习","zh2":u"學習"},
"Change languages":{"zh":u"改变语言选择","zh2":u"改變語言選擇"},
"Cancel lesson":{"zh":u"退出课","zh2":u"退出課"},
"Manage word list":{"zh":u"管理词汇","zh2":u"管理詞匯"},
"words in":{"zh":u"词, 用","zh2":u"詞, 用"},
"new words in":{"zh":u"新词, 用","zh2":u"新詞, 用"},
"mins":{"zh":u"分钟","zh2":u"分鐘"},
"Start lesson":{"zh":u"开始课","zh2":u"開始課"},
"Clear test boxes":{"zh":u"扫清输入地方","zh2":u"掃清輸入地方"},
"Quit":{"zh":u"放弃","zh2":u"放棄"},
"Back to main menu":{"zh":u"回去主要项目表","zh2":u"回去主要項目表"},
"Delete non-hanzi":{"zh":u"除字非汉字","zh2":u"除字非漢字"},
"Speak":{"zh":u"发音","zh2":u"發音"},
"Add to %s":{"zh":u"加到词汇(%s)","zh2":u"加到詞匯(%s)"},
"Recorded words":{"zh":u"录音词语","zh2":u"錄音詞語"},
"To":{"zh":u""},
"Make":{"zh":u""},
"Speaker":{"zh":u"扬声器","zh2":u"揚聲器"},
"Change or delete item":{"zh":u"更换/删除","zh2":u"更換/刪除"},
"You have not changed the test boxes. Do you want to delete %s?":{"zh":u"你还没编辑了。你想删除%s吗?","zh2":u"你還沒編輯了。你想刪除%s嗎?"},
"Restore":{"zh":u"归还","zh2":u"歸還"},
"Hear this lesson again?":{"zh":u"再次听那个课吗?","zh2":u"再次聽那個課嗎?"},
"Start this lesson again?":{"zh":u"再次开始这个课吗?","zh2":u"再次開始這個課嗎?"},
"You have %d words in your collection":{"zh":u"你的汇编有%d词","zh2":u"你的彙編有%d詞"},
"%d new words + %d old words":{"zh":u"%d新词而%d旧词","zh2":u"%d新詞而%d舊詞"},
"minutes":{"zh":u"分钟","zh2":u"分鐘"},
"seconds":{"zh":u""},
"Today's lesson teaches %d new words\nand revises %d old words\n\nPlaying time: %d %s %d %s":{"zh":u"今天我们学%d新词而复习%d旧词\n需要%d%s%d%s","zh2":u"今天我們學%d新詞而複習%d舊詞\n需要%d%s%d%s"},
"Today we will learn %d words\nThis will require %d %s %d %s\nFollow the spoken instructions carefully":{"zh":u"今天我们学%d新词, 需要%d%s%d%s\n请仔细听从口头指示","zh2":u"今天我們學%d新詞, 需要%d%s%d%s\n請仔細聽從口頭指示"},
"Family mode (multiple user)":{"zh":u"加别的学生(家人等)","zh2":u"加別的學生(家人等)"},
"Add new name":{"zh":u"加名字"},
"Students":{"zh":u"学生","zh2":u"學生"},
"Brief interrupt":{"zh":u"短打岔"},
"Resume":{"zh":u"恢复","zh2":u"恢復"},
"Emergency brief interrupt":{"zh":u"紧急的短打岔","zh2":u"緊急的短打岔"},
"Resuming...":{"zh":u"正在恢复...","zh2":u"正在恢復..."},
"Big print":{"zh":u"大号字体","zh2":u"大號字體"},
"Compressing, please wait":{"zh":u"正在压缩...","zh2":u"正在壓縮..."},
"All recordings have been compressed to MP3. Do you also want to make a ZIP file for sending as email?":{"zh":u"所有录音都压缩成为MP3了。 你也想做一个ZIP文件所以能随email附上吗?","zh2":u"所有錄音都壓縮成為MP3了。 你也想做一個ZIP文件所以能隨email附上嗎?"},
"Compress all recordings":{"zh":u"压缩一切录音","zh2":u"壓縮一切錄音"},
"Play":{"zh":u""},
"Re-record":{"zh":u"从新录音","zh2":u"從新錄音"},
"(empty)":{"zh":u"(空虚)","zh2":u"(空虛)"},
"Record":{"zh":u"录音","zh2":u"錄音"},
"Add more words":{"zh":u"加多词","zh2":u"加多詞"},
"New folder":{"zh":u"新卷宗"},
"Stop":{"zh":u"停止"},
"Action of spacebar during recording:":{"zh":u"空格键在录音的时候的功能:","zh2":u"空格鍵在錄音的時候的功能:"},
"move down":{"zh":u"进步下面"},
"move along":{"zh":u"进步右边","zh2":u"進步右邊"},
"stop":{"zh":u"停止"},
"(Up)":{"zh":u"(上面)"},
"Record from %s":{"zh":u"从%s做录音","zh2":u"從%s做錄音"},
"Record from file":{"zh":u"从文件做录音","zh2":u"從文件做錄音"},
"Manage recorded words using Gradint":{"zh":u"用这个软件管理录音","zh2":u"用這個軟件管理錄音"},
"Open the recorded words folder":{"zh":u"打开录音的卷宗","zh2":u"打開錄音的卷宗"},
}
scriptVariants = {}
GUI_for_editing_only = 0
GUI_omit_settings = 0
GUI_omit_statusline = 0
recorderMode = 0
runInBackground = 0
useTK = 1
waitBeforeStart = 1
startFunction = None
oss_sound_device = ""
soundVolume = 1
saveLesson = ""
loadLesson = 0
justSaveLesson = 0
compress_progress_file = 0
paranoid_file_management = 0
once_per_day = 0
File deleted
#!/bin/bash
if test -e /usr/lib/tkConfig.sh || test -e /usr/local/lib/tkConfig.sh; then
# run using only the Tk windows:
cd "$(echo $0 | sed -e 's|start-gradint.app/Contents/MacOS/start-gradint.*$||')"
exec pythonw gradint.py
else
# run in Terminal:
open -a Terminal.app "$(echo $0 | sed -e 's|start-gradint.app/Contents/MacOS/start-gradint.*$|gradint.py|')"
fi
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
開頭
开端
今日個堂上完啦
今天的课结束了
而家我哋要等一陣,然後翻溫。喺第一課我哋仲未學習好多嘅詞語,所以停頓會比較長,但係喺未來嘅課程,我哋唔會有咁長嘅停頓
现在我们要等, 然后复习。 在第一课我们还没有学习很多词语所以停顿比较长。 但是在未来的课我们没有这样长的停顿。
意思係