Skip to content

Commit

Permalink
Merge branch 'i5651' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelDCurran committed Jan 6, 2016
2 parents a74f6c2 + 9df271b commit be8f9c3
Show file tree
Hide file tree
Showing 39 changed files with 183 additions and 803 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
url = https://bitbucket.org/nvaccess/nvda-misc-deps.git
[submodule "include/espeak"]
path = include/espeak
url = https://bitbucket.org/nvaccess/espeak.git
url=https://github.com/espeak-ng/espeak-ng
[submodule "include/sonic"]
path = include/sonic
url = https://github.com/waywardgeek/sonic.git
2 changes: 1 addition & 1 deletion include/espeak
1 change: 1 addition & 0 deletions include/sonic
Submodule sonic added at 4f8c1d
7 changes: 7 additions & 0 deletions nvdaHelper/espeak/access.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <io.h>
#include <windows.h>

int access(const char* path, int mode) {
return GetFileAttributes(path);
}

7 changes: 7 additions & 0 deletions nvdaHelper/espeak/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// general headers and types
#define HAVE_STDINT_H 1
#define __WIN32__ 1

// Espeak features
#define INCLUDE_KLATT 1
#define HAVE_SONIC_H 1
174 changes: 87 additions & 87 deletions nvdaHelper/espeak/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,15 @@ import os
import ctypes
from glob import glob

env=env.Clone()
env.Append(CPPDEFINES='/DLIBRARY')
#Whole-program optimization causes eSpeak to distort and worble with its Klatt4 voice
#Therefore specifically force it off
env.Append(CCFLAGS='/GL-')

def _compilePhonemeAndDictData_buildEmitter(target,source,env):
dictSources=env.Flatten([env.Glob(source[0].abspath+'\\*_%s'%ext) for ext in ('rules','list','listx','extra')])
phSourceIgnores=['error_log','error_intonation','compile_prog_log','compile_report','envelopes.png']
phSources=env.Flatten([[Dir(topDir).File(f) for f in files if f not in phSourceIgnores] for topDir,subdirs,files in os.walk(source[1].abspath)])
sources=env.Flatten([phSources])
targets=[target[0].File(f) for f in ['intonations','phondata','phondata-manifest','phonindex','phontab']]
dictSideEffects=[target[0].File('%s_dict'%dictName) for dictName in set(f.name.split('_')[0] for f in dictSources)]
dictSideEffects.extend([source[0].File(x) for x in ('dict_log','dict_phonemes')])
env.SideEffect(dictSideEffects,targets)
phSideEffects=[source[1].File(x) for x in phSourceIgnores]
env.SideEffect(phSideEffects,targets)
return targets,sources
class AutoFreeCDLL(ctypes.CDLL):
def __del__(self):
ctypes.windll.kernel32.FreeLibrary(self._handle)

synthDriversDir=sourceDir.Dir('synthDrivers')
espeakRepo=Dir("#include/espeak")

env['BUILDERS']['compileEspeakPhonemeAndDictData']=Builder(
action=[
[espeakRepo.File("espeakedit.exe"),"--compile"]
],
emitter=_compilePhonemeAndDictData_buildEmitter,
)
espeakSrcDir=espeakRepo.Dir('src')
espeakIncludeDir=espeakSrcDir.Dir('include/espeak-ng')
sonicSrcDir=Dir("#include/sonic")

class espeak_VOICE(ctypes.Structure):
_fields_=[
Expand All @@ -48,97 +30,115 @@ class espeak_VOICE(ctypes.Structure):
('spare',ctypes.c_void_p),
]



env=env.Clone()
#Whole-program optimization causes eSpeak to distort and worble with its Klatt4 voice
#Therefore specifically force it off
env.Append(CCFLAGS='/GL-')

env.Append(CCFLAGS='/W0')
env.Append(CPPDEFINES=[('BUILDING_DLL',1)])
env.Prepend(CPPPATH=espeakRepo.Dir('platforms/windows/windows_dll/src'))
env.Append(CPPPATH=['#nvdaHelper/espeak',espeakIncludeDir,sonicSrcDir])

def espeak_compileDict_action(target,source,env):
def espeak_compilePhonemeData_buildEmitter(target,source,env):
phSourceIgnores=['error_log','error_intonation','compile_prog_log','compile_report','envelopes.png']
phSources=env.Flatten([[Dir(topDir).File(f) for f in files if f not in phSourceIgnores] for topDir,subdirs,files in os.walk(source[0].abspath)])
sources=env.Flatten([phSources])
targets=[target[0].File(f) for f in ['intonations','phondata','phondata-manifest','phonindex','phontab']]
phSideEffects=[source[0].File(x) for x in phSourceIgnores]
env.SideEffect(phSideEffects,targets)
return targets,sources

def espeak_compilePhonemeData_buildAction(target,source,env):
# We want the eSpeak dll to be freed after each dictionary.
# This is because it writes to stderr but doesn't flush it.
# Unfortunately, there's no way we can flush it or use a different stream
# because our eSpeak statically links the CRT.
espeak=ctypes.cdll.LoadLibrary(espeakLib[0].abspath)
espeak.espeak_Initialize(0,0,synthDriversDir.abspath,0x8000)
espeak=AutoFreeCDLL(espeakLib[0].abspath)
espeak.espeak_ng_InitializePath(espeakRepo.abspath)
espeak.espeak_ng_CompileIntonation(None)
espeak.espeak_ng_CompilePhonemeData(22050,None)
espeak.espeak_Terminate()

env['BUILDERS']['espeak_compilePhonemeData']=Builder(action=env.Action(espeak_compilePhonemeData_buildAction,"Compiling phoneme data"),emitter=espeak_compilePhonemeData_buildEmitter)

def espeak_compileDict_buildAction(target,source,env):
# We want the eSpeak dll to be freed after each dictionary.
# This is because it writes to stderr but doesn't flush it.
# Unfortunately, there's no way we can flush it or use a different stream
# because our eSpeak statically links the CRT.
espeak=AutoFreeCDLL(espeakLib[0].abspath)
espeak.espeak_Initialize(0,0,target[0].Dir('..').abspath,0x8000)
try:
lang=source[0].name.split('_')[0]
v=espeak_VOICE(languages=lang+'\x00')
if espeak.espeak_SetVoiceByProperties(ctypes.byref(v))!=0:
print "espeak_compileDict_action: failed to switch to language %s, skipping compilation"%lang
return
print "espeak_compileDict_action: failed to switch to language %s"%lang
return 1
dictPath=os.path.split(source[0].abspath)[0]+'/'
if espeak.espeak_CompileDictionary(dictPath,None,0)!=0:
return 1
print "espeak_compileDict_action: failed to compile dictionary for language %s"%lang
return
finally:
espeak.espeak_Terminate()
# ctypes doesn't ever unload dlls.
ctypes.windll.kernel32.FreeLibrary(espeak._handle)

synthDriversDir=sourceDir.Dir('synthDrivers')
espeakDataDir=synthDriversDir.Dir('espeak-data')
tempSrcDir=Dir('src')
# Add some compatibility files specific to windows builds
env.Install(espeakRepo.Dir('src/libespeak-ng'),'access.c')
env.Install(espeakRepo.Dir('src'),'config.h')

#make a temp copy of src, but using the windows dll version of speech.h
winFiles=['speech.h','stdafx.h']
for f in env.Glob(espeakRepo.abspath+'/src/*'):
if f.name.lower() in winFiles: continue
env.Command(tempSrcDir.File(f.name),f,Copy('$TARGET','$SOURCE'))
for f in winFiles:
env.Command(tempSrcDir.File(f),espeakRepo.File('platforms/windows/windows_dll/src/%s'%f),Copy('$TARGET','$SOURCE'))
sonicLib=env.StaticLibrary(
target='sonic',
srcdir=sonicSrcDir.abspath,
source='sonic.c',
)

espeakLib=env.SharedLibrary(
target='espeak',
srcdir=tempSrcDir.name,
srcdir=espeakSrcDir.Dir('libespeak-ng').abspath,
source=[
"speak_lib.cpp",
"readclause.cpp",
"compiledict.cpp",
"dictionary.cpp",
"intonation.cpp",
"setlengths.cpp",
"numbers.cpp",
"synth_mbrola.cpp",
"synthdata.cpp",
"synthesize.cpp",
"translate.cpp",
"tr_languages.cpp",
"voices.cpp",
"wavegen.cpp",
"espeak_command.cpp",
"event.cpp",
"fifo.cpp",
"wave.cpp", "debug.cpp",
"phonemelist.cpp",
"klatt.cpp",
"sonic.cpp",
"access.c",
"speak_lib.c",
"readclause.c",
"compiledict.c",
"dictionary.c",
"intonation.c",
"setlengths.c",
"numbers.c",
"synth_mbrola.c",
"synthdata.c",
"synthesize.c",
"translate.c",
"tr_languages.c",
"voices.c",
"wavegen.c",
"phonemelist.c",
"klatt.c",
"compiledata.c",
"compilembrola.c",
"ieee80.c",
"spect.c",
sonicLib,
],
LIBS=['advapi32'],
)

#Compile phoneme data
tempPhonemeAndDictDataFiles=env.compileEspeakPhonemeAndDictData(espeakRepo.Dir('espeak-data'),[espeakRepo.Dir('dictsource'),espeakRepo.Dir('phsource')],ENV={'ESPEAK_DATA_PATH':espeakRepo.abspath})
phonemeAndDictDataFiles=[env.Command(espeakDataDir.File(f.name),f,Copy('$TARGET','$SOURCE')) for f in tempPhonemeAndDictDataFiles]
#Ensure these don't try to get built in paralell
for f in phonemeAndDictDataFiles:
env.SideEffect('_espeak_compileDict',f)

# copy voices from espeak repository to synthDrivers
env.recursiveCopy(espeakDataDir.Dir('voices'),espeakRepo.Dir('espeak-data\\voices'))
phonemeData=env.espeak_compilePhonemeData(espeakRepo.Dir('espeak-data'),espeakRepo.Dir('phsource'))
env.Depends(phonemeData,espeakLib)

#Copy in the extra variants
for f in env.Glob(Dir('variants').abspath+'/*'):
env.Command(espeakDataDir.File('voices\\!v\\%s'%f.name),f,Copy("$TARGET","$SOURCE"))
# Move any extra dictionaries into dictsource for compilation
env.Install(espeakRepo.Dir('dictsource'),env.Glob(os.path.join(espeakRepo.abspath,'dictsource','extra','*_*')))

#Compile all dictionaries
for f in env.Glob(espeakRepo.abspath+'/dictsource/*_rules'):
extraSources=[f.File(f.name.split('_')[0]+x) for x in '_list','_listx','_extra']
dictFile=env.Command(espeakDataDir.File(f.name.split('_')[0]+'_dict'),[f,[x for x in extraSources if os.path.isfile(x.abspath)]],espeak_compileDict_action)
env.Depends(dictFile,[espeakLib,espeakDataDir.Dir('voices'),phonemeAndDictDataFiles])
missingDicts=['mt','tn','tt']
dictSourcePath=espeakRepo.Dir('dictsource').abspath
for f in env.Glob(os.path.join(dictSourcePath,'*_rules')):
lang=f.name.split('_')[0]
if lang in missingDicts: continue
dictFile=env.Command(espeakRepo.Dir('espeak-data').File(lang+'_dict'),f,espeak_compileDict_buildAction)
dictDeps=env.Glob(os.path.join(espeakRepo.abspath,'dictsource',lang+'_*'))
dictDeps.remove(f)
env.Depends(dictFile,dictDeps)
env.Depends(dictFile,[espeakLib,phonemeData])
#Dictionaries can not be compiled in parallel, force SCons not to do this
env.SideEffect('_espeak_compileDict',dictFile)

env.Requires(synthDriversDir,espeakDataDir)
env.Install(synthDriversDir,espeakLib)
env.Clean(espeakDataDir,espeakDataDir)
env.RecursiveInstall(synthDriversDir.Dir('espeak-data'),espeakRepo.Dir('espeak-data').abspath)
35 changes: 0 additions & 35 deletions nvdaHelper/espeak/variants/Andy

This file was deleted.

17 changes: 0 additions & 17 deletions nvdaHelper/espeak/variants/Annie

This file was deleted.

34 changes: 0 additions & 34 deletions nvdaHelper/espeak/variants/AnxiousAndy

This file was deleted.

19 changes: 0 additions & 19 deletions nvdaHelper/espeak/variants/Denis

This file was deleted.

17 changes: 0 additions & 17 deletions nvdaHelper/espeak/variants/Gene

This file was deleted.

17 changes: 0 additions & 17 deletions nvdaHelper/espeak/variants/Gene2

This file was deleted.

Loading

0 comments on commit be8f9c3

Please sign in to comment.