diff --git a/gradint-build/Makefile b/gradint-build/Makefile index b50f4348d5802dc3822f085f79c0c4c673a59e52..8311d3d2c0a936b0c0cc2869bebce30cecffe13f 100644 --- a/gradint-build/Makefile +++ b/gradint-build/Makefile @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/advanced.txt b/gradint-build/advanced.txt index 6dc3197e76566047574330d54a11f100cfdcb163..59ecd15e11a7be624c1997ee572b8351ccee3ab9 100644 --- a/gradint-build/advanced.txt +++ b/gradint-build/advanced.txt @@ -271,7 +271,7 @@ sapiVoices = { # Here you can set extra SAPI 5 voices. The default voice # will be used for English unless overridden here. If you # have Neospeech Lily then that will be used for Chinese unless -# overridden here. (Although Lily is not always accurate.) +# overridden here (although Lily is not always accurate). # Add them in this format but without the # at the beginning: # "language abbrev" : ("full voice name", rate), # For example, if you have "ScanSoft Mei-Ling_Full_22kHz" @@ -292,6 +292,13 @@ sapiVoices = { # in synth_priorities above. } +sapiSpeeds = { +# Here you can change the speeds of SAPI voices. Speed ranges from +# -10 (slowest) to +10 (fastest). For example, to slow down the +# English SAPI voice and speed up the Chinese, you can have +# "en": -5, "zh": +3 (but without the # at the beginning) +} + # Another thing you can do is to selectively override the # speech synthesis of certain words. To do this, set # synthCache (below) to a directory, and in that directory diff --git a/gradint-build/src/booktime.py b/gradint-build/src/booktime.py index c206d76d89bfac7eac3b3e5ba4ba47ad9cac26b1..b247f1bb80e2e3f4d73250cc89e3f93a9f0c8ce7 100644 --- a/gradint-build/src/booktime.py +++ b/gradint-build/src/booktime.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/filescan.py b/gradint-build/src/filescan.py index 815f52cec288e28a1f9389b9f44cf9649ff5d5ae..956e2a347c5102deef4a5e1f4e4fdd90614fd2a1 100644 --- a/gradint-build/src/filescan.py +++ b/gradint-build/src/filescan.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/frontend.py b/gradint-build/src/frontend.py index 1de2f884a1828eeee0e50771fcb2298782e924ce..f939019046a275fa48b9331f869dba55c9289d19 100644 --- a/gradint-build/src/frontend.py +++ b/gradint-build/src/frontend.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/lessonplan.py b/gradint-build/src/lessonplan.py index 3edcaa33b85d78064fbe3236367680af7eaee55d..e59caf17a83f922a62ed7227b2bece36cc07b678 100644 --- a/gradint-build/src/lessonplan.py +++ b/gradint-build/src/lessonplan.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/loop.py b/gradint-build/src/loop.py index 666e74033053d8d576f5e05017212c238bbe07e6..4230a25a97bcef35e1bfa40a72405945f74ceff4 100644 --- a/gradint-build/src/loop.py +++ b/gradint-build/src/loop.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/makeevent.py b/gradint-build/src/makeevent.py index a4f8e5c69924357bf6ba6bc42852bb0f24b6c796..b7491b2f5c0cb8e57928800f5c579d8521bc13c6 100644 --- a/gradint-build/src/makeevent.py +++ b/gradint-build/src/makeevent.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/play.py b/gradint-build/src/play.py index 2dd90f1f4681e6920a227b19d76b56b0ce2f22f7..421e6c3f163b878edcc0108e2327c751832b7b38 100644 --- a/gradint-build/src/play.py +++ b/gradint-build/src/play.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/recording.py b/gradint-build/src/recording.py index dd08d666e475c3a4c86e9b321f16f7cc748799a6..9a3512b92d3db089b1aafd75dd991f29be5f7447 100644 --- a/gradint-build/src/recording.py +++ b/gradint-build/src/recording.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/sequence.py b/gradint-build/src/sequence.py index 6043bfadc641a80360aa7fcecb539908ca8d00fc..5a722184f6980c0e1957a72e76f2864c0ec91593 100644 --- a/gradint-build/src/sequence.py +++ b/gradint-build/src/sequence.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 @@ -14,8 +14,9 @@ def randomInstruction(numTimesBefore,promptsData,language): if not numTimesBefore: return (availablePrompts.getPromptList("repeatAfterMe",promptsData,language),0) if numTimesBefore==1: return (availablePrompts.getPromptList("sayAgain",promptsData,language),1) - if language==secondLanguage and ((dbase.veryExperienced() and numTimesBefore>=reallyKnownThreshold) or (meaningTestThreshold and numTimesBefore>meaningTestThreshold and not random.choice([1,2,3])==1)): - return (None,1) # no instruction needed + if (dbase.veryExperienced() and numTimesBefore>=reallyKnownThreshold) or (meaningTestThreshold and numTimesBefore>meaningTestThreshold and not random.choice([1,2,3])==1): + if language==secondLanguage: return (None,1) # no instruction needed + else: return (availablePrompts.getPromptList(language,promptsData,language),1) # just need the language name r = availablePrompts.getRandomPromptList(promptsData,language) # horrible hack: whatSay goes after the 1st-language # word; others go before diff --git a/gradint-build/src/synth.py b/gradint-build/src/synth.py index 0e49b8cd07a4e775116f710daaa1903fbe52e404..5b6212a6f12f634c4989fb70e28684f24f9f3afd 100644 --- a/gradint-build/src/synth.py +++ b/gradint-build/src/synth.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 @@ -148,33 +148,36 @@ class PttsSynth(Synth): if self.offlineOnly: return SampleEvent(self.makefile_cached(lang,text)).play() if lang in sapiVoices: d=os.getcwd() - ret=self.sapi_unicode(sapiVoices[lang][0],ensure_unicode(text)) + ret=self.sapi_unicode(sapiVoices[lang][0],ensure_unicode(text),speed=sapiSpeeds.get(lang,None)) os.chdir(d) ; return ret elif lang=='en': - p=os.popen(self.program+toNull,"w") + p=os.popen(self.program+self.speedParam(sapiSpeeds.get(lang,None))+toNull,"w") p.write(text+"\n") return p.close() elif lang=='zh': d=os.getcwd() - ret=self.sapi_unicode("VW Lily",self.preparePinyinPhrase(text)) + ret=self.sapi_unicode("VW Lily",self.preparePinyinPhrase(text),speed=sapiSpeeds.get(lang,None)) self.restore_lily_dict() os.chdir(d) ; return ret - def sapi_unicode(self,voice,unicode_string,toFile=None,rate=None): + def sapi_unicode(self,voice,unicode_string,toFile=None,sampleRate=None,speed=None): # Speaks unicode_string in 'voice'. toFile (if present) must be something that was returned by tempnam. May change the current directory. unifile=os.tempnam() ; open(unifile,"wb").write(codecs.utf_16_encode(unicode_string)[0]) if not toFile: extra="" else: extra=' -w '+changeToDirOf(toFile,1)+' -c 1' - if rate: extra += (' -s '+str(rate)) - ret=system(self.program+' -u '+changeToDirOf(unifile,1)+' -voice "'+voice+'"'+extra+toNull) # (both changeToDirOf will give same directory because both from tempnam) + if sampleRate: extra += (' -s '+str(sampleRate)) + ret=system(self.program+' -u '+changeToDirOf(unifile,1)+' -voice "'+voice+'"'+extra+self.speedParam(speed)+toNull) # (both changeToDirOf will give same directory because both from tempnam) os.unlink(unifile) ; return ret + def speedParam(self,speed): + if speed: return " -r "+str(speed) + else: return "" def makefile(self,lang,text): fname = os.tempnam()+dotwav oldcwd=os.getcwd() - if lang in sapiVoices: self.sapi_unicode(sapiVoices[lang][0],ensure_unicode(text),fname,sapiVoices[lang][1]) - elif lang=="en": os.popen(self.program+' -c 1 -w '+changeToDirOf(fname,1)+toNull,"w").write(text+"\n") # (can specify mono but can't specify sample rate if it wasn't mentioned in sapiVoices - might make en synth-cache bigger than necessary but otherwise no great problem) + if lang in sapiVoices: self.sapi_unicode(sapiVoices[lang][0],ensure_unicode(text),fname,sapiVoices[lang][1],speed=sapiSpeeds.get(lang,None)) + elif lang=="en": os.popen(self.program+speed+' -c 1 -w '+changeToDirOf(fname,1)+self.speedParam(sapiSpeeds.get(lang,None))+toNull,"w").write(text+"\n") # (can specify mono but can't specify sample rate if it wasn't mentioned in sapiVoices - might make en synth-cache bigger than necessary but otherwise no great problem) elif lang=='zh': - self.sapi_unicode("VW Lily",self.preparePinyinPhrase(text),fname,16000) + self.sapi_unicode("VW Lily",self.preparePinyinPhrase(text),fname,16000,speed=sapiSpeeds.get(lang,None)) self.restore_lily_dict() os.chdir(oldcwd) d = sapi_sox_bug_workaround(open(fname,"rb").read()); open(fname,"wb").write(d) diff --git a/gradint-build/src/system.py b/gradint-build/src/system.py index 511dbd012adc1088a4ad12cbd9ce49f110cb79fb..056a5b3158d93804d6460278c113d548624be71b 100644 --- a/gradint-build/src/system.py +++ b/gradint-build/src/system.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/top.py b/gradint-build/src/top.py index a6e810debedf6d7f1f019bc78da2d64aec15dddc..e4791c1ec5db28e7f0d1cb1e1d705e0b48b760e8 100644 --- a/gradint-build/src/top.py +++ b/gradint-build/src/top.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -program_name = "gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+." +program_name = "gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/src/users.py b/gradint-build/src/users.py index b017500577b2077a0f08e20a7f3d237d2892d708..b50df01540305656fbc40759365a5d47957b9cf6 100644 --- a/gradint-build/src/users.py +++ b/gradint-build/src/users.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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 diff --git a/gradint-build/thindown.py b/gradint-build/thindown.py index 0e072beac6248b732fed650fffb27ca89579d0a0..c60fe4a52a76599aca68dd17bf97779b7871da06 100644 --- a/gradint-build/thindown.py +++ b/gradint-build/thindown.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v0.9957 (c) 2002-2010 Silas S. Brown. GPL v3+. +# gradint v0.9958 (c) 2002-2010 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