summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2005-12-16 14:17:39 +0000
committerbringert <bringert@cs.chalmers.se>2005-12-16 14:17:39 +0000
commit068180ecc07c4d197d607d3397847a21fe980f1f (patch)
treef312f8fab5cd84f4abaab98219d3bc8e2bd792a3 /src
parent9ebdba894bc6d3e13e9af3d7f9c0558efaeae6d2 (diff)
Include atk config file in GF. Use environment variable to find the file.
Diffstat (limited to 'src')
-rw-r--r--src/GF/System/ATKSpeechInput.hs28
-rw-r--r--src/gf_atk.cfg102
2 files changed, 124 insertions, 6 deletions
diff --git a/src/GF/System/ATKSpeechInput.hs b/src/GF/System/ATKSpeechInput.hs
index 20909d591..47b3b6216 100644
--- a/src/GF/System/ATKSpeechInput.hs
+++ b/src/GF/System/ATKSpeechInput.hs
@@ -27,10 +27,6 @@ import System.Environment
import System.IO
import System.IO.Unsafe
--- FIXME: get these from somewhere else
-
-config = "/home/aarne/atk/atkrec/atkrec.cfg"
-
data ATKLang = ATKLang {
hmmlist :: FilePath,
mmf0 :: FilePath,
@@ -38,18 +34,26 @@ data ATKLang = ATKLang {
dict :: FilePath
}
+atk_home_error = "The environment variable ATK_HOME is not set. "
+ ++ "It should contain the path to your copy of ATK."
+
+gf_atk_cfg_error = "The environment variable GF_ATK_CFG is not set. "
+ ++ "It should contain the path to your GF ATK configuration"
+ ++ " file. A default version of this file can be found"
+ ++ " in GF/src/gf_atk.cfg"
+
getLanguage :: String -> IO ATKLang
getLanguage l =
case l of
"en_UK" -> do
- atk_home <- getEnv "ATK_HOME"
+ atk_home <- getEnv_ "ATK_HOME" atk_home_error
let res = atk_home ++ "/Resources"
return $ ATKLang {
hmmlist = res ++ "/UK_SI_ZMFCC/hmmlistbg",
mmf0 = res ++ "/UK_SI_ZMFCC/WI4",
mmf1 = res ++ "/UK_SI_ZMFCC/BGHMM2",
dict = res ++ "/beep.dct" }
- _ -> fail $ "AKTSpeechInput: language " ++ l ++ " not supported"
+ _ -> fail $ "ATKSpeechInput: language " ++ l ++ " not supported"
-- | List of the languages for which we have already loaded the HMM
-- and dictionary.
@@ -62,6 +66,7 @@ initATK language =
do
ls <- readIORef languages
when (null ls) $ do
+ config <- getEnv_ "GF_ATK_CFG" gf_atk_cfg_error
hPutStrLn stderr $ "Initializing ATK..."
initialize config
when (language `notElem` ls) $
@@ -91,3 +96,14 @@ recognizeSpeech name opts cfg =
hPutStrLn stderr "Listening..."
s <- recognize recName
return s
+
+
+getEnv_ :: String -- ^ Name of environment variable
+ -> String -- ^ Message to fail with if the variable is not set.
+ -> IO String
+getEnv_ e err =
+ do
+ env <- getEnvironment
+ case lookup e env of
+ Just v -> return v
+ Nothing -> fail err \ No newline at end of file
diff --git a/src/gf_atk.cfg b/src/gf_atk.cfg
new file mode 100644
index 000000000..097406b2b
--- /dev/null
+++ b/src/gf_atk.cfg
@@ -0,0 +1,102 @@
+# GF ATK configuration file
+# ------------------------
+
+# -- Basic audio signal processing --
+
+SOURCEFORMAT = HAUDIO
+SOURCERATE = 625
+TARGETKIND = MFCC_0_D_A_Z
+TARGETRATE = 100000.0
+WINDOWSIZE = 250000.0
+ENORMALISE = F
+ZMEANSOURCE = F
+USEHAMMING = T
+PREEMCOEF = 0.97
+USEPOWER = T
+NUMCHANS = 26
+CEPLIFTER = 22
+NUMCEPS = 12
+SILFLOOR = 50.0
+USESILDET = T
+MEASURESIL = F
+OUTSILWARN = T
+
+# -- Silence detection ---
+
+HPARM: CALWINDOW = 40
+HPARM: SPEECHTHRESH = 9.0
+HPARM: SILDISCARD = 10.0
+HPARM: SILENERGY = 0.0
+HPARM: SPCSEQCOUNT = 10
+HPARM: SPCGLCHCOUNT = 0
+HPARM: SILGLCHCOUNT = 2
+HPARM: SILSEQCOUNT = 50
+
+# -- Cepstral mean ---
+
+HPARM: CMNTCONST = 0.995
+HPARM: CMNRESETONSTOP = F
+HPARM: CMNMINFRAMES = 12
+
+# -- Define HMM Resources --
+
+# FIXME: make this configurable at run-time
+HPARM: CMNDEFAULT = "/home/bjorn/src/atk/Resources/UK_SI_ZMFCC/cepmean"
+
+
+
+# -- Recogniser --
+
+AREC: TRBAKFREQ = 1
+
+# hands free, don't return results until end
+AREC: RUNMODE = 01441
+
+AREC: GENBEAM = 200.0
+AREC: WORDBEAM = 175.0
+AREC: WORDPEN = -10.0
+
+HNET: FORCECXTEXP = T
+HNET: ALLOWXWRDEXP = F
+HNET: MARKSUBLAT = T
+ARMAN: AUTOSIL = F
+
+HREC: CONFSCALE = 0.15
+HREC: CONFOFFSET = 0.0
+HREC: CONFBGHMM = bghmm
+
+# -- Set visibility and positions of ATK controls --
+
+AIN: DISPSHOW = T
+AIN: DISPXORIGIN = 440
+AIN: DISPYORIGIN = 220
+AIN: DISPHEIGHT = 40
+AIN: DISPWIDTH = 160
+
+ACODE: DISPSHOW = F
+ACODE: DISPXORIGIN = 40
+ACODE: DISPYORIGIN = 220
+ACODE: DISPHEIGHT = 220
+ACODE: DISPWIDTH = 380
+ACODE: MAXFGFEATS = 13
+ACODE: NUMSTREAMS = 1
+
+AREC: DISPSHOW = T
+AREC: DISPXORIGIN = 40
+AREC: DISPYORIGIN = 20
+AREC: DISPHEIGHT = 160
+AREC: DISPWIDTH = 560
+
+
+# -- Debugging --
+
+HMMSET: TRACE = 0
+ADICT: TRACE = 0
+AGRAM: TRACE = 0
+GGRAM: TRACE = 0
+AREC: TRACE = 0
+ARMAN: TRACE = 0
+HPARM: TRACE = 0
+HNET: TRACE = 0
+HREC: TRACE = 0
+