summaryrefslogtreecommitdiff
path: root/speech_utils
diff options
context:
space:
mode:
Diffstat (limited to 'speech_utils')
-rw-r--r--speech_utils/Makefile30
-rw-r--r--speech_utils/init.lua23
-rw-r--r--speech_utils/speech_utils-scm-1.rockspec36
3 files changed, 89 insertions, 0 deletions
diff --git a/speech_utils/Makefile b/speech_utils/Makefile
new file mode 100644
index 0000000..b288322
--- /dev/null
+++ b/speech_utils/Makefile
@@ -0,0 +1,30 @@
+SHELL := /bin/bash
+BUILD_DIR := $(CURDIR)/build
+INC_PATH := $(LUA_BINDIR)/../include/
+OBJS :=
+LIBS :=
+LUA_LIBS := init.lua
+INCLUDE := -I $(LUA_INCDIR) -I $(INC_PATH) -DLUA_USE_APICHECK
+
+SUBDIR := src
+OBJ_DIR := $(BUILD_DIR)/objs
+LUA_DIR = $(INST_LUADIR)/speech_utils
+
+OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS))
+LIBS := $(addprefix $(INST_LIBDIR)/,$(LIBS))
+OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR))
+LUA_SUBDIR := $(addprefix $(LUA_DIR)/,$(SUBDIR))
+LUA_LIBS := $(addprefix $(LUA_DIR)/,$(LUA_LIBS))
+LIB_PATH := $(LUA_BINDIR)/../lib
+
+build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS)
+install: $(LUA_DIR) $(LUA_SUBDIR) $(LUA_LIBS) $(LIBS)
+
+$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR):
+ -mkdir -p $@
+$(LUA_DIR)/%.lua: %.lua
+ cp $< $@
+$(OBJ_DIR)/%.o: %.c
+ gcc -o $@ -c $< -g $(INCLUDE) -fPIC
+clean:
+ -rm $(OBJ_DIR)/src/*.o
diff --git a/speech_utils/init.lua b/speech_utils/init.lua
new file mode 100644
index 0000000..5148664
--- /dev/null
+++ b/speech_utils/init.lua
@@ -0,0 +1,23 @@
+nerv.speech_utils = {}
+
+function nerv.speech_utils.global_transf(feat_utter, global_transf, frm_ext, gconf)
+ local res = {}
+ local step = frm_ext * 2 + 1
+ -- expand the feature
+ local expanded = gconf.cumat_type(feat_utter:nrow(), feat_utter:ncol() * step)
+ expanded:expand_frm(gconf.cumat_type.new_from_host(feat_utter), frm_ext)
+ -- rearrange the feature (``transpose'' operation in TNet)
+ local rearranged = expanded:create()
+ rearranged:rearrange_frm(expanded, step)
+ -- prepare for transf
+ local input = {rearranged}
+ local output = {rearranged:create()}
+ -- do transf
+ global_transf:init(input[1]:nrow())
+ global_transf:propagate(input, output)
+ -- trim frames
+ expanded = gconf.mmat_type(output[1]:nrow() - frm_ext * 2, output[1]:ncol())
+ output[1]:copy_toh(expanded, frm_ext, feat_utter:nrow() - frm_ext)
+ collectgarbage("collect")
+ return expanded
+end
diff --git a/speech_utils/speech_utils-scm-1.rockspec b/speech_utils/speech_utils-scm-1.rockspec
new file mode 100644
index 0000000..6477822
--- /dev/null
+++ b/speech_utils/speech_utils-scm-1.rockspec
@@ -0,0 +1,36 @@
+package = "speech_utils"
+version = "scm-1"
+source = {
+ url = "https://github.com/Determinant/nerv-speech.git"
+}
+description = {
+ summary = "Speech Recognition Utilities for Nerv",
+ detailed = [[
+ ]],
+ homepage = "https://github.com/Determinant/nerv-speech",
+ license = "BSD"
+}
+dependencies = {
+ "nerv >= scm-1",
+ "lua >= 5.1"
+}
+build = {
+ type = "make",
+ build_variables = {
+ CFLAGS="$(CFLAGS)",
+ LIBFLAG="$(LIBFLAG)",
+ LUA_LIBDIR="$(LUA_LIBDIR)",
+ LUA_BINDIR="$(LUA_BINDIR)",
+ LUA_INCDIR="$(LUA_INCDIR)",
+ INST_PREFIX="$(PREFIX)",
+ LUA="$(LUA)",
+ },
+ install_variables = {
+ LUA_BINDIR="$(LUA_BINDIR)",
+ INST_PREFIX="$(PREFIX)",
+ INST_BINDIR="$(BINDIR)",
+ INST_LIBDIR="$(LIBDIR)",
+ INST_LUADIR="$(LUADIR)",
+ INST_CONFDIR="$(CONFDIR)",
+ },
+}