├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── FindAtlas.cmake ├── FindGraphviz.cmake ├── FindKaldi.cmake ├── FindLibCPPA.cmake ├── cmake_uninstall.cmake.in └── get_compiler_version.cpp ├── configure ├── egs ├── README.md ├── case1 │ ├── baseline │ │ ├── baseline.log │ │ ├── baseline.sh │ │ ├── int2sym.pl │ │ ├── mfcc.conf │ │ ├── run.sh │ │ ├── test.hyp │ │ ├── test.ref │ │ ├── test.scp │ │ ├── test.tra │ │ └── test.wer │ └── benchmark │ │ ├── benchmark.log │ │ ├── benchmark.sh │ │ ├── conf │ │ ├── actors.ini │ │ └── graph.dot │ │ ├── int2sym.pl │ │ ├── pcm.list │ │ ├── run.sh │ │ ├── test.hyp │ │ ├── test.ref │ │ ├── test.tra │ │ └── test.wer ├── case2 │ ├── conf │ │ ├── actors.ini │ │ └── graph.dot │ ├── int2sym.pl │ ├── pcm.list │ └── run.sh ├── data │ ├── README.md │ └── sample │ │ ├── 440c0401.pcm │ │ ├── 440c0401.wav │ │ └── README.md ├── demo │ ├── README.md │ ├── conf │ │ ├── actors.ini │ │ └── graph.dot │ ├── filter1.txt │ ├── filter2.txt │ ├── pcm.list │ ├── pcm.txt │ └── run.sh ├── feat │ ├── README.md │ ├── cmvn.txt │ ├── conf │ │ ├── actors.ini │ │ └── graph.dot │ ├── delta.txt │ ├── log │ ├── mfcc.txt │ ├── pcm.list │ ├── pcm.txt │ └── run.sh ├── live │ ├── README.md │ ├── conf │ │ ├── actors.ini │ │ └── graph.dot │ ├── int2sym.pl │ └── run.sh └── models │ └── README.md ├── src ├── base │ ├── common.h │ ├── kaldi-type-info.h │ ├── module-base.cc │ └── module-base.h ├── bin │ └── barista.cc ├── decoder │ ├── faster-online-decoder.cc │ └── faster-online-decoder.h ├── feat │ ├── add-deltas.cc │ ├── add-deltas.h │ ├── apply-cmvn.cc │ ├── apply-cmvn.h │ ├── compute-mfcc-feats.cc │ ├── compute-mfcc-feats.h │ ├── filter.cc │ └── filter.h ├── gmm │ ├── gmm-decode-faster-online.cc │ └── gmm-decode-faster-online.h └── io │ ├── command-line-interface.cc │ ├── command-line-interface.h │ ├── file-list-reader.cc │ ├── file-list-reader.h │ ├── matrix-writer.cc │ ├── matrix-writer.h │ ├── pcm-reader.cc │ ├── pcm-reader.h │ ├── portaudio-reader.cc │ ├── portaudio-reader.h │ ├── vector-writer.cc │ └── vector-writer.h └── tools └── Makefile /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | TODO.md 16 | HOWTO.md 17 | Makefile 18 | 19 | build*/ 20 | bin/ 21 | lib/ 22 | include/ 23 | 24 | tools/kaldi 25 | tools/libcppa 26 | tools/graphviz 27 | 28 | egs/data/aurora4 29 | egs/models/wsj 30 | egs/models/hub4 31 | egs/models/icsi 32 | egs/case1/baseline/*.hyp 33 | egs/case1/baseline/*.tra 34 | egs/case1/baseline/*.wer 35 | egs/case1/baseline/*.log 36 | egs/case1/benchmark/*.hyp 37 | egs/case1/benchmark/*.tra 38 | egs/case1/benchmark/*.wer 39 | egs/case1/benchmark/*.log 40 | egs/case2/*.hyp 41 | egs/case2/*.tra 42 | egs/case2/log 43 | egs/demo/*.txt 44 | egs/demo/log 45 | egs/feat/*.txt 46 | egs/feat/log 47 | egs/live/*.hyp 48 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This script is partly based on libcppa cmake script. 2 | 3 | ############################################################################### 4 | # Setup cmake and check compiler # 5 | ############################################################################### 6 | 7 | cmake_minimum_required (VERSION 2.8) 8 | set(CMAKE_VERBOSE_MAKEFILE 0) 9 | project (Barista CXX) 10 | 11 | # prohibit in-source builds 12 | if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") 13 | message(FATAL_ERROR "In-source builds are not allowed. Please use " 14 | "./configure to choose a build directory and " 15 | "initialize the build configuration.") 16 | endif () 17 | 18 | # Additional files used by cmake 19 | set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) 20 | 21 | # check for g++ >= 4.7 22 | try_run(ProgramResult 23 | CompilationSucceeded 24 | ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH}/get_compiler_version.cpp 25 | RUN_OUTPUT_VARIABLE CompilerVersion) 26 | if (NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0) 27 | message(FATAL_ERROR "Cannot determine compiler version") 28 | elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND 29 | CompilerVersion VERSION_GREATER 4.6) 30 | else () 31 | message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} ${CompilerVersion}" 32 | " is not supported. g++ >= 4.7 required.") 33 | endif () 34 | 35 | 36 | ############################################################################### 37 | # Set paths # 38 | ############################################################################### 39 | 40 | set(BARISTA_ROOT ${CMAKE_SOURCE_DIR}) 41 | set(BARISTA_SRC_DIR ${BARISTA_ROOT}/src) 42 | set(BARISTA_TOOLS_DIR ${BARISTA_ROOT}/tools) 43 | 44 | #-----------------------------------------------------------------------------# 45 | 46 | # Find Kaldi and its dependencies (Atlas, OpenFst, portaudio) 47 | 48 | if (NOT KALDI_ROOT) 49 | set(KALDI_ROOT ${BARISTA_TOOLS_DIR}/kaldi) 50 | endif() 51 | if (VERBOSE) 52 | find_package(Kaldi REQUIRED) 53 | else () 54 | find_package(Kaldi QUIET REQUIRED) 55 | endif () 56 | if (KALDI_VERSION) 57 | if (${KALDI_VERSION} VERSION_LESS "3755") 58 | message(FATAL_ERROR "Kaldi revision >= 3755 is required.") 59 | endif() 60 | endif() 61 | 62 | # TODO: we should maybe look into kaldi/src/kaldi.mk to figure out ATLAS paths. 63 | if (NOT ATLAS_ROOT) 64 | set(ATLAS_ROOT ${KALDI_TOOLS_DIR}/ATLAS) 65 | endif() 66 | 67 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 68 | set(ENV{ATLAS_DIR} ${ATLAS_ROOT}) 69 | if (VERBOSE) 70 | find_package(Atlas REQUIRED) 71 | else () 72 | find_package(Atlas QUIET REQUIRED) 73 | endif () 74 | else() 75 | set(ATLAS_INCLUDE_DIR ${ATLAS_ROOT}/include) 76 | endif() 77 | 78 | #-----------------------------------------------------------------------------# 79 | 80 | # Find libcppa 81 | if (NOT CPPA_ROOT) 82 | set(CPPA_ROOT ${BARISTA_TOOLS_DIR}/libcppa) 83 | endif () 84 | if (VERBOSE) 85 | find_package(LibCPPA REQUIRED) 86 | else () 87 | find_package(LibCPPA QUIET REQUIRED) 88 | endif () 89 | if (NOT ${CPPA_VERSION} VERSION_EQUAL "0.8.1") 90 | message(FATAL_ERROR "libcppa version 0.8.1 is required.") 91 | endif() 92 | 93 | #-----------------------------------------------------------------------------# 94 | 95 | # Find GraphViz 96 | if (NOT GRAPHVIZ_ROOT) 97 | set(GRAPHVIZ_ROOT ${BARISTA_TOOLS_DIR}/graphviz) 98 | endif() 99 | set(ENV{GRAPHVIZ_ROOT} ${GRAPHVIZ_ROOT}) 100 | if (VERBOSE) 101 | find_package(Graphviz REQUIRED) 102 | else () 103 | find_package(Graphviz QUIET REQUIRED) 104 | endif () 105 | if (NOT ${GRAPHVIZ_VERSION} VERSION_GREATER "2.29") 106 | message(FATAL_ERROR "GraphViz version >= 2.30 is required.") 107 | endif() 108 | 109 | #-----------------------------------------------------------------------------# 110 | 111 | # Find Boost 112 | if (BOOST_ROOT) 113 | set(Boost_NO_SYSTEM_PATHS true) 114 | endif () 115 | find_package(Boost REQUIRED) 116 | if (NOT Boost_FOUND) 117 | message(FATAL_ERROR "Boost not found.") 118 | endif () 119 | 120 | 121 | ############################################################################### 122 | # Set compiler and linker flags # 123 | ############################################################################### 124 | # # 125 | # How to set compiler flags: # 126 | # 1. Copy the flags set by CXXFLAGS in KALDI_ROOT/src/kaldi.mk # 127 | # 2. Add "-std=c++11 -fpermissive" # 128 | # 3. Add "-Wno-unused-local-typedefs" to silence the warnings about OpenFst. # 129 | # # 130 | # How to set linker flags: # 131 | # 1. Copy the flags set by LDFLAGS and LDLIBS in KALDI_ROOT/src/kaldi.mk # 132 | # 2. Copy the frameworks set by SHARED_FLAGS in # 133 | # KALDI_ROOT/tools/portaudio/Makefile # 134 | # # 135 | # How to set portaudio dependencies for Linux systems: # 136 | # 1. Copy the libs listed under LIBS and DLL_LIBS in # 137 | # KALDI_ROOT/tools/portaudio/Makefile # 138 | ############################################################################### 139 | 140 | # Extract platform dependent portaudio dependencies from the libtool library 141 | execute_process(COMMAND grep "^dependency_libs" ${PORTAUDIO_LIBTOOL_FILE} 142 | COMMAND sed "s/.*=//; s/'//g; s/^ *//; s/ *$//;" 143 | COMMAND tr -d "\n" 144 | OUTPUT_VARIABLE DEPENDENCY_LIBS) 145 | 146 | execute_process(COMMAND grep "^inherited" ${PORTAUDIO_LIBTOOL_FILE} 147 | COMMAND sed "s/.*=//; s/'//g; s/^ *//; s/ *$//;" 148 | COMMAND tr -d "\n" 149 | OUTPUT_VARIABLE DEPENDENCY_FLAGS) 150 | 151 | set (CMAKE_CXX_FLAGS 152 | "${CMAKE_CXX_FLAGS} -msse -msse2 -fPIC -Wall -DKALDI_DOUBLEPRECISION=0 -DHAVE_POSIX_MEMALIGN -DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -Winit-self -Wno-unused-local-typedefs -Wno-sign-compare -flax-vector-conversions -fpermissive -g -std=c++11") 153 | 154 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DEPENDENCY_FLAGS}") 155 | 156 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 157 | # Typical flags for Linux 158 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_ATLAS") 159 | 160 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") 161 | 162 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 163 | # Typical flags for Mac OS X 164 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_CLAPACK") 165 | 166 | set (CMAKE_EXE_LINKER_FLAGS 167 | "${CMAKE_EXE_LINKER_FLAGS} -framework Accelerate") 168 | 169 | else () 170 | message(FATAL_ERROR "Barista does not support ${CMAKE_SYSTEM_NAME}.") 171 | endif() 172 | 173 | set_source_files_properties(src/decoder/faster-online-decoder.cc PROPERTIES COMPILE_FLAGS -O3) 174 | 175 | 176 | ############################################################################### 177 | # Add targets (You probably don't need to change anything beyond this point) # 178 | ############################################################################### 179 | 180 | # link_directories(${OPENFST_LIB_DIR} ${CPPA_LIB_DIR}) 181 | 182 | include_directories( 183 | ${BARISTA_SRC_DIR} 184 | ${Boost_INCLUDE_DIRS} 185 | ${GRAPHVIZ_INCLUDE_DIRS} 186 | ${CPPA_INCLUDE_DIR} 187 | ${KALDI_SRC_DIR} 188 | ${OPENFST_INCLUDE_DIR} 189 | ${ATLAS_INCLUDE_DIR} 190 | ${PORTAUDIO_INCLUDE_DIR} 191 | ) 192 | 193 | add_library(barista-base STATIC 194 | src/base/module-base.cc 195 | ) 196 | 197 | add_library(barista-io STATIC 198 | src/io/file-list-reader.cc src/io/pcm-reader.cc 199 | src/io/command-line-interface.cc src/io/portaudio-reader.cc 200 | src/io/vector-writer.cc src/io/matrix-writer.cc 201 | ) 202 | 203 | add_library(barista-feat STATIC 204 | src/feat/compute-mfcc-feats.cc src/feat/apply-cmvn.cc src/feat/add-deltas.cc 205 | src/feat/filter.cc 206 | ) 207 | 208 | add_library(barista-decoder STATIC 209 | src/decoder/faster-online-decoder.cc 210 | ) 211 | 212 | add_library(barista-gmm STATIC 213 | src/gmm/gmm-decode-faster-online.cc 214 | ) 215 | 216 | add_executable(barista src/bin/barista.cc) 217 | 218 | target_link_libraries(barista 219 | barista-base barista-io barista-feat barista-decoder barista-gmm 220 | ${CPPA_LIBRARY} 221 | ${GRAPHVIZ_GVC_LIBRARY} ${GRAPHVIZ_CGRAPH_LIBRARY} 222 | ${KALDI_LIBRARIES} 223 | ${ATLAS_LIBRARIES} # empty on mac os x 224 | ${OPENFST_LIBRARY} 225 | ${PORTAUDIO_LIBRARY} 226 | dl m pthread 227 | ${DEPENDENCY_LIBS} # empty on mac os x 228 | ) 229 | 230 | 231 | ############################################################################### 232 | # Installation Setup # 233 | ############################################################################### 234 | 235 | # install executables and libraries 236 | install(TARGETS 237 | barista 238 | barista-base barista-io barista-feat barista-decoder barista-gmm 239 | RUNTIME DESTINATION bin 240 | LIBRARY DESTINATION lib 241 | ARCHIVE DESTINATION lib 242 | ) 243 | 244 | # install header files 245 | install(DIRECTORY src/ DESTINATION include FILES_MATCHING PATTERN "*.h") 246 | 247 | # process cmake_uninstall.cmake.in 248 | configure_file("${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in" 249 | "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" 250 | IMMEDIATE @ONLY) 251 | 252 | # add uninstall target 253 | add_custom_target(uninstall 254 | COMMAND ${CMAKE_COMMAND} -P 255 | ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 256 | 257 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "[]" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright [yyyy] [name of copyright owner] 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # barista 2 | 3 | Barista is an open-source framework for concurrent speech processing 4 | developed and maintained by the 5 | [Signal Analysis and Interpretation Lab](http://sail.usc.edu) (SAIL) at USC. 6 | 7 | ## Supported Operating Systems 8 | 9 | * Linux 10 | * Mac OS X 11 | 12 | ## Supported Compilers 13 | 14 | * g++ >= 4.7 [g++-4.8 recommended] 15 | 16 | We need a recent C++ compiler since barista relies on C++11 features. When 17 | C++11 support is activated, clang does not support linking with libstdc++. The 18 | only option is to link with libc++ which moves the stuff under `std::tr1` 19 | namespace to `std` namespace. Since Kaldi and OpenFst use some stuff from 20 | `std::tr1` namespace, they have to be linked with libstdc++. Hence, barista 21 | can not link against Kaldi and OpenFst using clang with C++11 support. Support 22 | for clang will be added if/when this issue is resolved. 23 | 24 | Installing g++-4.8 on Ubuntu 12.04 LTS using apt-get: 25 | 26 | add-apt-repository ppa:ubuntu-toolchain-r/test 27 | apt-get update 28 | apt-get install g++-4.8 29 | 30 | Installing g++-4.8 on Mac OS X using Homebrew: 31 | 32 | brew tap homebrew/versions 33 | brew update 34 | brew install gcc48 35 | 36 | ## Dependencies 37 | 38 | Barista depends on [Kaldi](http://kaldi.sourceforge.net) (and its dependencies 39 | including portaudio), [libcppa](https://github.com/Neverlord/libcppa), 40 | [GraphViz](http://www.graphviz.org) and [Boost](http://www.boost.org). 41 | 42 | Before installing barista, make sure you have CMake, git, svn, aclocal, 43 | libtoolize (or glibtoolize), zlib, libatlas, Boost and GraphViz (>= 2.30) 44 | installed on your system. If you are missing any of these tools, you can use a 45 | package manager to install them. 46 | 47 | Installing missing packages on Ubuntu 12.04 LTS using apt-get: 48 | 49 | apt-get install build-essential git subversion cmake automake libtool 50 | apt-get install zlib1g-dev libatlas-dev libatlas-base-dev libboost-all-dev 51 | 52 | # This PPA has a recent GraphViz package (>=2.30) for Ubuntu 12.04 53 | sudo add-apt-repository ppa:xba/graphviz 54 | apt-get update 55 | # If you have problems installing GraphViz, see below 56 | apt-get install libgraphviz4 graphviz libgraphviz-dev graphviz-dev 57 | 58 | Installing missing packages on Mac OS X using Homebrew: 59 | 60 | brew install cmake automake libtool boost graphviz 61 | 62 | We provide a Makefile for installing Kaldi, libcppa and GraphViz under 63 | `barista/tools` directory. We recommend installing Kaldi and libcppa using 64 | this makefile. If for some reason you cannot install GraphViz (>=2.30) using 65 | the system package manager, you can install it using this Makefile. 66 | 67 | If you already have a recent version of Kaldi trunk (revision >= 3755) 68 | installed at another location, you may skip installing Kaldi and provide this 69 | location to barista configure script using `--with-kaldi` option. Barista 70 | links against the static versions of standard Kaldi libraries, the optional 71 | `kaldi-online` library and the portaudio library installed by Kaldi. If you 72 | choose to use an existing Kaldi installation, make sure you have the static 73 | versions of those libraries installed. 74 | 75 | Similarly, if you already have a libcppa V0.8.1 installation that was compiled 76 | with g++ >= 4.7 (clang is not supported) with `--disable-context-switching` 77 | and `--build-static` flags, you may skip installing libcppa and provide this 78 | location to barista configure script using `--with-libcppa` option. Barista 79 | links against the libcppa_static library. If you choose to use an existing 80 | libcppa installation, make sure you have the static version of the library 81 | installed. 82 | 83 | cd barista 84 | make -C tools -j 4 kaldi # 4 jobs will be run in parallel 85 | make -C tools -j 4 libcppa CXX=g++-4.8 # g++ >= 4.7 required for libcppa 86 | make -C tools -j 4 graphviz # if not already installed 87 | 88 | We use checkmarks to avoid reinstalling things that were already successfully 89 | installed in case one of the later installation steps fails. If you want to 90 | rerun earlier steps, say for reinstalling with a different compiler, don't 91 | forget to call the relevant clean target first. For instance, for rebuilding 92 | Kaldi: 93 | 94 | make -C tools kaldi/clean 95 | make -C tools -j 4 kaldi 96 | 97 | ## Installation 98 | 99 | ./configure --prefix=`pwd` --with-compiler=g++-4.8 100 | make -j 4 101 | make install 102 | 103 | Above given configuration will build barista under `barista/build/g++-4.8` and 104 | install everything under `barista` root directory. If you omit the `--prefix` 105 | option, barista will be installed under `/usr/local/`. If the default compiler 106 | on your system is g++ >= 4.7, `--with-compiler` flag is not needed. If you 107 | want to build with a Kaldi or libcppa installation that is not under 108 | `barista/tools`, you can use `--with-kaldi` and `--with-libcppa` options to 109 | specify custom paths. Similarly, if you have Boost or GraphViz installed at a 110 | non-standard location, you can use `--with-boost` and `--with-graphviz` 111 | options to specify those. By default configure will search standard system 112 | folders for Boost and GraphViz. Finally, if you have ATLAS installed at a 113 | non-standard location, you can use `--with-atlas` option (Linux only). See 114 | `./configure --help` for a list of supported command line options. 115 | 116 | If above given instructions fail for some reason, you might need to edit 117 | `barista/CMakeLists.txt` to match your setup. You will likely need to copy 118 | some flags from Kaldi Makefiles. See `barista/CMakeLists.txt` for details. 119 | 120 | ## Upgrade 121 | 122 | To upgrade your barista installation: 123 | 124 | git pull # stop here if already up-to-date 125 | make -C tools -j 4 kaldi # upgrades Kaldi if necessary 126 | make -C tools -j 4 libcppa CXX=g++-4.8 # upgrades libcppa if necessary 127 | ./configure --prefix=`pwd` --with-compiler=g++-4.8 128 | make -j 4 129 | make install 130 | 131 | The calls for upgrading Kaldi and libcppa will not do anything unless they 132 | need to be upgraded to a newer version to support new barista functionality. 133 | -------------------------------------------------------------------------------- /cmake/FindAtlas.cmake: -------------------------------------------------------------------------------- 1 | # Copyright: (C) 2010 RobotCub Consortium 2 | # Authors: Arjan Gijsberts 3 | # CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT 4 | 5 | # 6 | # Find the Atlas (and Lapack) libraries 7 | # 8 | 9 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a" ".so.3gf") 10 | 11 | SET(ATLAS_POSSIBLE_INCLUDE_PATHS 12 | /usr/include 13 | /usr/include/atlas 14 | /usr/local/include 15 | $ENV{ATLAS_DIR} 16 | $ENV{ATLAS_DIR}/include 17 | ) 18 | 19 | # Ubuntu's package management does not handle blas elegantly, causing 20 | # many possible locations here. 21 | SET(ATLAS_POSSIBLE_LIBRARY_PATHS 22 | /usr/lib/libatlas-corei7sse3 23 | /usr/lib/atlas-amd64sse3 24 | /usr/lib/atlas-base 25 | /usr/lib/sse2 26 | /usr/lib/sse 27 | /usr/local/lib/sse2 28 | /usr/local/lib/sse 29 | /usr/lib 30 | /usr/local/lib 31 | $ENV{ATLAS_DIR} 32 | $ENV{ATLAS_DIR}/lib 33 | ) 34 | 35 | FIND_PATH(ATLAS_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${ATLAS_POSSIBLE_INCLUDE_PATHS}) 36 | FIND_PATH(ATLAS_CLAPACK_INCLUDE_DIR NAMES clapack.h PATHS ${ATLAS_POSSIBLE_INCLUDE_PATHS}) 37 | FIND_LIBRARY(ATLAS_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${ATLAS_POSSIBLE_LIBRARY_PATHS}) 38 | FIND_LIBRARY(ATLAS_F77BLAS_LIBRARY NAMES f77blas PATHS ${ATLAS_POSSIBLE_LIBRARY_PATHS}) 39 | FIND_LIBRARY(ATLAS_ATLAS_LIBRARY NAMES atlas_r atlas PATHS ${ATLAS_POSSIBLE_LIBRARY_PATHS}) 40 | FIND_LIBRARY(ATLAS_LAPACK_ATLAS_LIBRARY NAMES alapack_r alapack lapack_atlas PATHS ${ATLAS_POSSIBLE_LIBRARY_PATHS}) 41 | 42 | SET(ATLAS_FOUND ON) 43 | 44 | FOREACH(INCDIR ATLAS_CBLAS_INCLUDE_DIR ATLAS_CLAPACK_INCLUDE_DIR) 45 | IF(${INCDIR}) 46 | SET(ATLAS_INCLUDE_DIR ${ATLAS_INCLUDE_DIR} ${${INCDIR}} ) 47 | ELSE(${INCDIR}) 48 | MESSAGE("${INCDIR} not found turning off ATLAS_FOUND") 49 | SET(ATLAS_FOUND OFF) 50 | ENDIF (${INCDIR}) 51 | ENDFOREACH(INCDIR) 52 | 53 | # could make LAPACK_ATLAS optional 54 | FOREACH(LIBNAME ATLAS_LAPACK_ATLAS_LIBRARY ATLAS_CBLAS_LIBRARY ATLAS_F77BLAS_LIBRARY ATLAS_ATLAS_LIBRARY) 55 | IF(${LIBNAME}) 56 | SET(ATLAS_LIBRARIES ${ATLAS_LIBRARIES} ${${LIBNAME}} ) 57 | ELSE(${LIBNAME}) 58 | MESSAGE("${LIBNAME} not found turning off ATLAS_FOUND") 59 | SET(ATLAS_FOUND OFF) 60 | ENDIF (${LIBNAME}) 61 | ENDFOREACH(LIBNAME) 62 | 63 | 64 | IF (ATLAS_FOUND) 65 | IF (NOT Atlas_FIND_QUIETLY) 66 | MESSAGE(STATUS "Found Atlas libraries: ${ATLAS_LIBRARIES}") 67 | MESSAGE(STATUS "Found Atlas include: ${ATLAS_INCLUDE_DIR}") 68 | ENDIF (NOT Atlas_FIND_QUIETLY) 69 | ELSE (ATLAS_FOUND) 70 | IF (Atlas_FIND_REQUIRED) 71 | MESSAGE(FATAL_ERROR "Could not find Atlas") 72 | ENDIF (Atlas_FIND_REQUIRED) 73 | ENDIF (ATLAS_FOUND) 74 | 75 | MARK_AS_ADVANCED( 76 | ATLAS_INCLUDE_DIR 77 | ATLAS_CBLAS_INCLUDE_DIR 78 | ATLAS_CLAPACK_INCLUDE_DIR 79 | ATLAS_LIBRARIES 80 | ATLAS_CBLAS_LIBRARY 81 | ATLAS_F77BLAS_LIBRARY 82 | ATLAS_ATLAS_LIBRARY 83 | ATLAS_LAPACK_ATLAS_LIBRARY 84 | ) 85 | 86 | set(Atlas_FOUND ${ATLAS_FOUND}) -------------------------------------------------------------------------------- /cmake/FindGraphviz.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Graphviz 2 | # Once done this will define 3 | # 4 | # GRAPHVIZ_FOUND - system has Graphviz 5 | # GRAPHVIZ_INCLUDE_DIRS - Graphviz include directories 6 | # GRAPHVIZ_CDT_LIBRARY - Graphviz CDT library 7 | # GRAPHVIZ_GVC_LIBRARY - Graphviz GVC library 8 | # GRAPHVIZ_CGRAPH_LIBRARY - Graphviz CGRAPH library 9 | # GRAPHVIZ_PATHPLAN_LIBRARY - Graphviz PATHPLAN library 10 | # GRAPHVIZ_VERSION - Graphviz version 11 | # 12 | # This module reads hints about search locations from the following cmake variables: 13 | # GRAPHVIZ_ROOT - Graphviz installation prefix 14 | # (containing bin/, include/, etc.) 15 | 16 | # Copyright (c) 2009, Adrien Bustany, 17 | # Copyright (c) 2013-2014 Kevin Funk 18 | 19 | # Version computation and some cleanups by Allen Winter 20 | # Copyright (c) 2012-2014 Klarälvdalens Datakonsult AB, a KDAB Group company 21 | 22 | # Simplified script by Dogan Can 23 | # Copyright (c) 2014 University of Southern California 24 | 25 | # Redistribution and use is allowed according to the terms of the GPLv3+ license. 26 | 27 | 28 | if(GRAPHVIZ_ROOT) 29 | set(_GRAPHVIZ_INCLUDE_DIR ${GRAPHVIZ_ROOT}/include) 30 | set(_GRAPHVIZ_LIBRARY_DIR ${GRAPHVIZ_ROOT}/lib) 31 | endif() 32 | 33 | find_path(GRAPHVIZ_INCLUDE_DIR NAMES graphviz/cgraph.h 34 | HINTS ${_GRAPHVIZ_INCLUDE_DIR}) 35 | find_library(GRAPHVIZ_CDT_LIBRARY NAMES cdt 36 | HINTS ${_GRAPHVIZ_LIBRARY_DIR}) 37 | find_library(GRAPHVIZ_GVC_LIBRARY NAMES gvc 38 | HINTS ${_GRAPHVIZ_LIBRARY_DIR}) 39 | find_library(GRAPHVIZ_CGRAPH_LIBRARY NAMES cgraph 40 | HINTS ${_GRAPHVIZ_LIBRARY_DIR}) 41 | find_library(GRAPHVIZ_PATHPLAN_LIBRARY NAMES pathplan 42 | HINTS ${_GRAPHVIZ_LIBRARY_DIR}) 43 | 44 | if(GRAPHVIZ_INCLUDE_DIR AND GRAPHVIZ_CDT_LIBRARY AND GRAPHVIZ_GVC_LIBRARY 45 | AND GRAPHVIZ_CGRAPH_LIBRARY AND GRAPHVIZ_PATHPLAN_LIBRARY) 46 | set(GRAPHVIZ_FOUND TRUE) 47 | else() 48 | set(GRAPHVIZ_FOUND FALSE) 49 | endif() 50 | 51 | # Ok, now compute the version 52 | if(GRAPHVIZ_FOUND) 53 | set(FIND_GRAPHVIZ_VERSION_SOURCE 54 | "#include \n#include \n int main()\n {\n printf(\"%s\",PACKAGE_VERSION);return 1;\n }\n") 55 | set(FIND_GRAPHVIZ_VERSION_SOURCE_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/FindGRAPHVIZ.cxx) 56 | file(WRITE "${FIND_GRAPHVIZ_VERSION_SOURCE_FILE}" "${FIND_GRAPHVIZ_VERSION_SOURCE}") 57 | 58 | set(FIND_GRAPHVIZ_VERSION_ADD_INCLUDES 59 | "-DINCLUDE_DIRECTORIES:STRING=${GRAPHVIZ_INCLUDE_DIR}") 60 | 61 | try_run(RUN_RESULT COMPILE_RESULT 62 | ${CMAKE_BINARY_DIR} 63 | ${FIND_GRAPHVIZ_VERSION_SOURCE_FILE} 64 | CMAKE_FLAGS "${FIND_GRAPHVIZ_VERSION_ADD_INCLUDES}" 65 | RUN_OUTPUT_VARIABLE GRAPHVIZ_VERSION) 66 | 67 | if(COMPILE_RESULT AND RUN_RESULT EQUAL 1) 68 | message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION}") 69 | else() 70 | message(FATAL_ERROR "Unable to compile or run the graphviz version detection program.") 71 | endif() 72 | 73 | set(GRAPHVIZ_INCLUDE_DIRS ${GRAPHVIZ_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIR}/graphviz) 74 | 75 | if(NOT Graphviz_FIND_QUIETLY) 76 | message(STATUS "Graphviz include: ${GRAPHVIZ_INCLUDE_DIRS}") 77 | message(STATUS "Graphviz libraries: ${GRAPHVIZ_CDT_LIBRARY} ${GRAPHVIZ_GVC_LIBRARY} ${GRAPHVIZ_CGRAPH_LIBRARY} ${GRAPHVIZ_PATHPLAN_LIBRARY}") 78 | endif() 79 | endif() 80 | 81 | if(Graphviz_FIND_REQUIRED AND NOT GRAPHVIZ_FOUND) 82 | message(FATAL_ERROR "Could not find GraphViz.") 83 | endif() 84 | -------------------------------------------------------------------------------- /cmake/FindKaldi.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Kaldi 2 | # Once done this will define 3 | # 4 | # KALDI_FOUND - system has Kaldi 5 | # KALDI_SRC_DIR - Kaldi src directory 6 | # KALDI_TOOLS_DIR - Kaldi tools directory 7 | # KALDI_LIBRARIES - link these to use Kaldi 8 | # KALDI_VERSION - Kaldi revision number 9 | 10 | if (KALDI_SRC_DIR AND KALDI_TOOLS_DIR AND KALDI_LIBRARIES) 11 | set(KALDI_FOUND TRUE) 12 | else (KALDI_SRC_DIR AND KALDI_TOOLS_DIR AND KALDI_LIBRARIES) 13 | 14 | find_path(KALDI_SRC_DIR NAMES base/kaldi-common.h 15 | PATHS ${KALDI_ROOT}/src NO_DEFAULT_PATH) 16 | find_path(KALDI_TOOLS_DIR NAMES install_portaudio.sh 17 | PATHS ${KALDI_ROOT}/tools NO_DEFAULT_PATH) 18 | 19 | if (KALDI_SRC_DIR AND KALDI_TOOLS_DIR) 20 | if (NOT Kaldi_FIND_QUIETLY) 21 | message (STATUS "Kaldi root: ${KALDI_ROOT}") 22 | endif (NOT Kaldi_FIND_QUIETLY) 23 | 24 | if(IS_DIRECTORY ${KALDI_ROOT}/.svn) 25 | execute_process(COMMAND svnversion -n ${KALDI_ROOT} 26 | OUTPUT_VARIABLE KALDI_VERSION) 27 | message(STATUS "Kaldi revision: ${KALDI_VERSION}") 28 | else () 29 | message("Kaldi root is not an svn checkout. Kaldi revision unknown.") 30 | endif () 31 | 32 | else (KALDI_SRC_DIR AND KALDI_TOOLS_DIR) 33 | message ("Could not find Kaldi root at ${KALDI_ROOT}") 34 | endif (KALDI_SRC_DIR AND KALDI_TOOLS_DIR) 35 | 36 | if (KALDI_SRC_DIR) 37 | 38 | find_library(KALDI_BASE_LIBRARY NAMES base/kaldi-base.a 39 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 40 | find_library(KALDI_DECODER_LIBRARY NAMES decoder/kaldi-decoder.a 41 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 42 | find_library(KALDI_FEAT_LIBRARY NAMES feat/kaldi-feat.a 43 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 44 | find_library(KALDI_GMM_LIBRARY NAMES gmm/kaldi-gmm.a 45 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 46 | find_library(KALDI_HMM_LIBRARY NAMES hmm/kaldi-hmm.a 47 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 48 | find_library(KALDI_LAT_LIBRARY NAMES lat/kaldi-lat.a 49 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 50 | find_library(KALDI_MATRIX_LIBRARY NAMES matrix/kaldi-matrix.a 51 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 52 | find_library(KALDI_ONLINE_LIBRARY NAMES online/kaldi-online.a 53 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 54 | find_library(KALDI_TRANSFORM_LIBRARY NAMES transform/kaldi-transform.a 55 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 56 | find_library(KALDI_TREE_LIBRARY NAMES tree/kaldi-tree.a 57 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 58 | find_library(KALDI_UTIL_LIBRARY NAMES util/kaldi-util.a 59 | PATHS ${KALDI_SRC_DIR} NO_DEFAULT_PATH) 60 | 61 | foreach(LIBNAME KALDI_ONLINE_LIBRARY KALDI_DECODER_LIBRARY KALDI_FEAT_LIBRARY KALDI_GMM_LIBRARY KALDI_HMM_LIBRARY KALDI_LAT_LIBRARY KALDI_MATRIX_LIBRARY KALDI_TRANSFORM_LIBRARY KALDI_TREE_LIBRARY KALDI_UTIL_LIBRARY KALDI_BASE_LIBRARY) 62 | if(${LIBNAME}) 63 | SET(KALDI_LIBRARIES ${KALDI_LIBRARIES} ${${LIBNAME}} ) 64 | else(${LIBNAME}) 65 | message("${LIBNAME} not found.") 66 | set(KALDI_MISSING_LIBRARY TRUE) 67 | endif (${LIBNAME}) 68 | endforeach(LIBNAME) 69 | 70 | if (KALDI_LIBRARIES) 71 | if (NOT Kaldi_FIND_QUIETLY) 72 | message (STATUS "Kaldi libraries: ${KALDI_LIBRARIES}") 73 | endif (NOT Kaldi_FIND_QUIETLY) 74 | endif (KALDI_LIBRARIES) 75 | 76 | endif(KALDI_SRC_DIR) 77 | 78 | if (KALDI_TOOLS_DIR) 79 | 80 | find_path(OPENFST_INCLUDE_DIR NAMES fst/fstlib.h 81 | PATHS ${KALDI_TOOLS_DIR}/openfst/include NO_DEFAULT_PATH) 82 | if (OPENFST_INCLUDE_DIR) 83 | if (NOT Kaldi_FIND_QUIETLY) 84 | message(STATUS "OpenFst include: ${OPENFST_INCLUDE_DIR}") 85 | endif (NOT Kaldi_FIND_QUIETLY) 86 | else (OPENFST_INCLUDE_DIR) 87 | message ("Openfst header files not found at ${KALDI_TOOLS_DIR}/openfst/include") 88 | endif (OPENFST_INCLUDE_DIR) 89 | 90 | find_library(OPENFST_LIBRARY NAMES libfst.a 91 | PATHS ${KALDI_TOOLS_DIR}/openfst/lib NO_DEFAULT_PATH) 92 | if (OPENFST_LIBRARY) 93 | if (NOT Kaldi_FIND_QUIETLY) 94 | message(STATUS "OpenFst library: ${OPENFST_LIBRARY}") 95 | endif (NOT Kaldi_FIND_QUIETLY) 96 | else (OPENFST_LIBRARY) 97 | message ("Openfst library not found at ${KALDI_TOOLS_DIR}/openfst/lib") 98 | endif (OPENFST_LIBRARY) 99 | 100 | find_path(PORTAUDIO_INCLUDE_DIR NAMES portaudio.h PATHS 101 | ${KALDI_TOOLS_DIR}/portaudio/install/include NO_DEFAULT_PATH) 102 | if (PORTAUDIO_INCLUDE_DIR) 103 | if (NOT Kaldi_FIND_QUIETLY) 104 | message(STATUS "PortAudio include: ${PORTAUDIO_INCLUDE_DIR}") 105 | endif (NOT Kaldi_FIND_QUIETLY) 106 | else (PORTAUDIO_INCLUDE_DIR) 107 | message ("Portaudio header files not found at ${KALDI_TOOLS_DIR}/portaudio/install/include") 108 | endif (PORTAUDIO_INCLUDE_DIR) 109 | 110 | find_library(PORTAUDIO_LIBRARY NAMES libportaudio.a PATHS 111 | ${KALDI_TOOLS_DIR}/portaudio/install/lib NO_DEFAULT_PATH) 112 | if (PORTAUDIO_LIBRARY) 113 | if (NOT Kaldi_FIND_QUIETLY) 114 | message(STATUS "PortAudio library: ${PORTAUDIO_LIBRARY}") 115 | endif (NOT Kaldi_FIND_QUIETLY) 116 | else (PORTAUDIO_LIBRARY) 117 | message ("PortAudio library not found at ${KALDI_TOOLS_DIR}/portaudio/install/lib") 118 | endif (PORTAUDIO_LIBRARY) 119 | 120 | find_file(PORTAUDIO_LIBTOOL_FILE NAMES libportaudio.la PATHS 121 | ${KALDI_TOOLS_DIR}/portaudio/install/lib NO_DEFAULT_PATH) 122 | if (PORTAUDIO_LIBTOOL_FILE) 123 | if (NOT Kaldi_FIND_QUIETLY) 124 | message(STATUS "PortAudio libtool file: ${PORTAUDIO_LIBTOOL_FILE}") 125 | endif (NOT Kaldi_FIND_QUIETLY) 126 | else (PORTAUDIO_LIBTOOL_FILE) 127 | message ("PortAudio libtool (.la) file not found at ${KALDI_TOOLS_DIR}/portaudio/install/lib") 128 | endif (PORTAUDIO_LIBTOOL_FILE) 129 | 130 | if (OPENFST_INCLUDE_DIR AND OPENFST_LIBRARY AND 131 | PORTAUDIO_INCLUDE_DIR AND PORTAUDIO_LIBRARY AND PORTAUDIO_LIBTOOL_FILE) 132 | set(KALDI_DEPENDENCIES_FOUND TRUE) 133 | endif() 134 | 135 | endif (KALDI_TOOLS_DIR) 136 | 137 | if (KALDI_SRC_DIR AND KALDI_TOOLS_DIR AND NOT KALDI_MISSING_LIBRARY 138 | AND KALDI_DEPENDENCIES_FOUND) 139 | set(KALDI_FOUND TRUE) 140 | endif () 141 | 142 | endif (KALDI_SRC_DIR AND KALDI_TOOLS_DIR AND KALDI_LIBRARIES) 143 | 144 | if(Kaldi_FIND_REQUIRED AND NOT KALDI_SRC_DIR AND NOT KALDI_TOOLS_DIR) 145 | message(FATAL_ERROR "Could not find Kaldi.") 146 | endif() 147 | 148 | if(Kaldi_FIND_REQUIRED AND KALDI_MISSING_LIBRARY) 149 | message(FATAL_ERROR "Could not find some of the required Kaldi libraries.") 150 | endif() 151 | 152 | if(Kaldi_FIND_REQUIRED AND NOT KALDI_DEPENDENCIES_FOUND) 153 | message(FATAL_ERROR "Could not find some of the required Kaldi dependencies.") 154 | endif() 155 | -------------------------------------------------------------------------------- /cmake/FindLibCPPA.cmake: -------------------------------------------------------------------------------- 1 | # This file was adapted from the cppa find_package script in cppa-benchmarks. 2 | # - Try to find libcppa 3 | # Once done this will define 4 | # 5 | # CPPA_FOUND - system has libcppa 6 | # CPPA_INCLUDE_DIR - libcppa include dir 7 | # CPPA_LIBRARY - link againgst libcppa 8 | # CPPA_VERSION - version in {major}.{minor}.{patch} format 9 | 10 | if (CPPA_LIBRARY AND CPPA_INCLUDE_DIR) 11 | set(CPPA_FOUND TRUE) 12 | else (CPPA_LIBRARY AND CPPA_INCLUDE_DIR) 13 | 14 | find_path(CPPA_INCLUDE_DIR 15 | NAMES 16 | cppa/cppa.hpp 17 | PATHS 18 | ${CPPA_ROOT}/include 19 | ${CPPA_ROOT}/libcppa 20 | /usr/include 21 | /usr/local/include 22 | /opt/local/include 23 | /sw/include 24 | ${CPPA_INCLUDE_PATH} 25 | ${CPPA_LIBRARY_PATH} 26 | ${CMAKE_INCLUDE_PATH} 27 | ${CMAKE_INSTALL_PREFIX}/include 28 | ../libcppa 29 | ../../libcppa 30 | ../../../libcppa 31 | ) 32 | 33 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") 34 | set(CPPA_BUILD_DIR build-gcc) 35 | elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") 36 | set(CPPA_BUILD_DIR build-clang) 37 | endif () 38 | 39 | find_library(CPPA_LIBRARY 40 | NAMES 41 | libcppa_static 42 | cppa_static 43 | PATHS 44 | ${CPPA_ROOT}/lib 45 | ${CPPA_ROOT}/build/lib 46 | ${CPPA_ROOT}/libcppa/build/lib 47 | ${CPPA_ROOT}/${CPPA_BUILD_DIR}/lib 48 | ${CPPA_ROOT}/libcppa/${CPPA_BUILD_DIR}/lib 49 | /usr/lib 50 | /usr/local/lib 51 | /opt/local/lib 52 | /sw/lib 53 | ${CPPA_INCLUDE_PATH} 54 | ${CPPA_LIBRARY_PATH} 55 | ${CMAKE_LIBRARY_PATH} 56 | ${CMAKE_INSTALL_PREFIX}/lib 57 | ${LIBRARY_OUTPUT_PATH} 58 | ../libcppa/build/lib 59 | ../../libcppa/build/lib 60 | ../../../libcppa/build/lib 61 | ../libcppa/${CPPA_BUILD_DIR}/lib 62 | ../../libcppa/${CPPA_BUILD_DIR}/lib 63 | ../../../libcppa/${CPPA_BUILD_DIR}/lib 64 | ) 65 | 66 | # extract CPPA_VERSION from config.hpp 67 | if (CPPA_INCLUDE_DIR) 68 | # we assume version 0.8.1 if CPPA_VERSION is not defined config.hpp 69 | set(CPPA_VERSION 801) 70 | file(READ "${CPPA_INCLUDE_DIR}/cppa/config.hpp" CPPA_CONFIG_HPP_CONTENT) 71 | string(REGEX REPLACE ".*#define CPPA_VERSION ([0-9]+).*" "\\1" CPPA_VERSION "${CPPA_CONFIG_HPP_CONTENT}") 72 | if ("${CPPA_VERSION}" MATCHES "^[0-9]+$") 73 | math(EXPR CPPA_VERSION_MAJOR "${CPPA_VERSION} / 100000") 74 | math(EXPR CPPA_VERSION_MINOR "${CPPA_VERSION} / 100 % 1000") 75 | math(EXPR CPPA_VERSION_PATCH "${CPPA_VERSION} % 100") 76 | set(CPPA_VERSION "${CPPA_VERSION_MAJOR}.${CPPA_VERSION_MINOR}.${CPPA_VERSION_PATCH}") 77 | else () 78 | set(CPPA_VERSION "0.8.1") 79 | endif () 80 | message (STATUS "libcppa version: ${CPPA_VERSION}") 81 | endif (CPPA_INCLUDE_DIR) 82 | 83 | 84 | if (CPPA_INCLUDE_DIR) 85 | if (NOT LibCPPA_FIND_QUIETLY) 86 | message (STATUS "libcppa include: ${CPPA_INCLUDE_DIR}") 87 | endif (NOT LibCPPA_FIND_QUIETLY) 88 | else (CPPA_INCLUDE_DIR) 89 | message (SEND_ERROR "libcppa header files NOT found.") 90 | endif (CPPA_INCLUDE_DIR) 91 | 92 | if (CPPA_LIBRARY) 93 | if (NOT LibCPPA_FIND_QUIETLY) 94 | message (STATUS "libcppa library: ${CPPA_LIBRARY}") 95 | endif (NOT LibCPPA_FIND_QUIETLY) 96 | else (CPPA_LIBRARY) 97 | message (SEND_ERROR "libcppa static library not found. Make sure libcppa was configured with --build-static option.") 98 | endif (CPPA_LIBRARY) 99 | 100 | if (CPPA_INCLUDE_DIR AND CPPA_LIBRARY) 101 | set(CPPA_FOUND TRUE) 102 | set(CPPA_INCLUDE_DIR ${CPPA_INCLUDE_DIR}) 103 | set(CPPA_LIBRARY ${CPPA_LIBRARY}) 104 | endif (CPPA_INCLUDE_DIR AND CPPA_LIBRARY) 105 | 106 | endif (CPPA_LIBRARY AND CPPA_INCLUDE_DIR) 107 | 108 | if(LibCPPA_FIND_REQUIRED AND NOT CPPA_FOUND) 109 | message(FATAL_ERROR "Could not find libcppa.") 110 | endif() 111 | -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # This is a copy of libcppa uninstall script. 2 | 3 | if(POLICY CMP0007) 4 | cmake_policy(PUSH) 5 | cmake_policy(SET CMP0007 NEW) 6 | endif() 7 | 8 | if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 9 | message(FATAL_ERROR "Cannot find install manifest: 10 | \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 11 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 12 | 13 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 14 | string(REGEX REPLACE "\n" ";" files "${files}") 15 | list(REVERSE files) 16 | foreach (file ${files}) 17 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 18 | if (EXISTS "$ENV{DESTDIR}${file}") 19 | execute_process( 20 | COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" 21 | OUTPUT_VARIABLE rm_out 22 | RESULT_VARIABLE rm_retval 23 | ) 24 | if(NOT ${rm_retval} EQUAL 0) 25 | message(FATAL_ERROR "Problem when removing 26 | \"$ENV{DESTDIR}${file}\"") 27 | endif (NOT ${rm_retval} EQUAL 0) 28 | else (EXISTS "$ENV{DESTDIR}${file}") 29 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 30 | endif (EXISTS "$ENV{DESTDIR}${file}") 31 | endforeach(file) 32 | 33 | if(POLICY CMP0007) 34 | cmake_policy(POP) 35 | endif() 36 | -------------------------------------------------------------------------------- /cmake/get_compiler_version.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | # ifdef __clang__ 6 | cout << __clang_major__ 7 | << "." 8 | << __clang_minor__; 9 | # elif defined(__GNUC__) 10 | cout << __GNUC__ 11 | << "." 12 | << __GNUC_MINOR__; 13 | # else 14 | cout << "0.0"; 15 | # endif 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Convenience wrapper for easily viewing/setting options that 3 | # the project's CMake scripts will recognize. 4 | # This script is based on libcppa configure script. 5 | 6 | # check for `cmake` command 7 | type cmake > /dev/null 2>&1 || { 8 | echo "\ 9 | This package requires CMake, please install it first, then you may 10 | use this configure script to access CMake equivalent functionality.\ 11 | " >&2; 12 | exit 1; 13 | } 14 | 15 | command="$0 $*" 16 | sourcedir="$( cd "$( dirname "$0" )" && pwd )" 17 | usage="\ 18 | Usage: $0 [OPTION]... 19 | 20 | Build Options: 21 | --build-dir=DIR build directory [build] 22 | --verbose verbose configuration [false] 23 | --with-compiler=FILE compiler name (or path) 24 | 25 | Installation Directories: 26 | --prefix=PREFIX installation directory [/usr/local] 27 | 28 | Required Packages in Non-Standard Locations: 29 | --with-atlas=PATH path to ATLAS install root 30 | --with-boost=PATH path to Boost install root 31 | --with-graphviz=PATH path to GraphViz install root [tools/graphviz] 32 | --with-kaldi=PATH path to Kaldi install root [tools/kaldi] 33 | --with-libcppa=PATH path to libcppa install root [tools/libcppa] 34 | " 35 | 36 | 37 | # Appends a CMake cache entry definition to the CMakeCacheEntries variable. 38 | # $1 is the cache entry variable name 39 | # $2 is the cache entry variable type 40 | # $3 is the cache entry variable value 41 | append_cache_entry () 42 | { 43 | CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3" 44 | } 45 | 46 | # Creates a build directory via CMake. 47 | # $1 is the build directory. 48 | # $2 is the path to a compiler executable. 49 | configure () 50 | { 51 | builddir=$1 52 | compiler=$2 53 | 54 | if [[ "$builddir" != /* ]]; then 55 | # relative path given; convert to absolute path 56 | builddir="$(pwd)/$builddir" 57 | fi 58 | 59 | if [ -n "$compiler" ]; then 60 | append_cache_entry CMAKE_CXX_COMPILER FILEPATH `which $compiler` 61 | compilername=`basename $compiler` 62 | workdir="$builddir/$compilername" 63 | else 64 | workdir="$builddir/c++" 65 | fi 66 | 67 | append_cache_entry EXECUTABLE_OUTPUT_PATH PATH "$workdir/bin" 68 | append_cache_entry LIBRARY_OUTPUT_PATH PATH "$workdir/lib" 69 | workdirs="$workdirs $workdir" 70 | 71 | mkdir -p $workdir 72 | cd $workdir 73 | rm -f CMakeCache.txt 74 | cmake $CMakeCacheEntries $sourcedir 75 | echo "# This is the command used to configure this build" > config.status 76 | echo $command >> config.status 77 | chmod u+x config.status 78 | } 79 | 80 | # Set defaults. 81 | builddir="$sourcedir/build" 82 | CMakeCacheEntries="" 83 | append_cache_entry CMAKE_INSTALL_PREFIX PATH /usr/local 84 | append_cache_entry GRAPHVIZ_ROOT PATH $sourcedir/tools/graphviz 85 | append_cache_entry KALDI_ROOT PATH $sourcedir/tools/kaldi 86 | append_cache_entry CPPA_ROOT PATH $sourcedir/tools/libcppa 87 | 88 | # Parse arguments. 89 | while [ $# -ne 0 ]; do 90 | case "$1" in 91 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 92 | *) optarg= ;; 93 | esac 94 | 95 | case "$1" in 96 | --help|-h) 97 | echo "${usage}" 1>&2 98 | exit 1 99 | ;; 100 | --build-dir=*) 101 | builddir=$optarg 102 | ;; 103 | --verbose) 104 | append_cache_entry VERBOSE BOOL true 105 | ;; 106 | --with-compiler=*) 107 | compiler=$optarg 108 | ;; 109 | --prefix=*) 110 | append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg 111 | ;; 112 | --with-atlas=*) 113 | append_cache_entry ATLAS_ROOT PATH $optarg 114 | ;; 115 | --with-boost=*) 116 | append_cache_entry BOOST_ROOT PATH $optarg 117 | ;; 118 | --with-graphviz=*) 119 | append_cache_entry GRAPHVIZ_ROOT PATH $optarg 120 | ;; 121 | --with-kaldi=*) 122 | append_cache_entry KALDI_ROOT PATH $optarg 123 | ;; 124 | --with-libcppa=*) 125 | append_cache_entry CPPA_ROOT PATH $optarg 126 | ;; 127 | *) 128 | echo "Invalid option '$1'. Try $0 --help to see available options." 129 | exit 1 130 | ;; 131 | esac 132 | shift 133 | done 134 | 135 | configure $builddir $compiler 136 | 137 | printf "DIRS := %s\n\n" "$workdirs" > $sourcedir/Makefile 138 | makefile=$(cat <<'EOT' 139 | all: 140 | @for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done 141 | 142 | test: 143 | @for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done 144 | 145 | install: 146 | @for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done 147 | 148 | uninstall: 149 | @for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done 150 | 151 | clean: 152 | @for i in $(DIRS); do $(MAKE) -C $$i $@; done 153 | 154 | distclean: 155 | rm -rf $(DIRS) Makefile 156 | 157 | doc: 158 | $(MAKE) -C $(firstword $(DIRS)) $@ 159 | 160 | .PHONY: all test install uninstall clean distclean 161 | EOT 162 | ) 163 | 164 | echo "$makefile" >> $sourcedir/Makefile 165 | -------------------------------------------------------------------------------- /egs/README.md: -------------------------------------------------------------------------------- 1 | Example setups. 2 | 3 | 1. case1: comparison of online decoding setup with Kaldi decoding pipeline 4 | 2. case2: 3 decoders run in parallel with 3 different acoustic models: wsj, 5 | hub4, icsi 6 | 3. feat: feature extraction demo 7 | 4. demo: dummy filter demo 8 | 5. live: live real-time speech recognition demo 9 | -------------------------------------------------------------------------------- /egs/case1/baseline/baseline.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | KALDISRC=../../../tools/kaldi/src 4 | export PATH=$KALDISRC/bin:$KALDISRC/featbin:$KALDISRC/gmmbin:$PATH 5 | 6 | modeldir=../../models/wsj 7 | 8 | mkfifo feats 9 | 10 | feats="ark:compute-mfcc-feats --config=mfcc.conf scp:test.scp ark:- | \ 11 | tee feats | compute-cmvn-stats ark:- ark:- | \ 12 | apply-cmvn --norm-vars=false ark:- ark:feats ark:- | \ 13 | add-deltas ark:- ark:- |" 14 | 15 | gmm-decode-faster --max-active=7000 --beam=13.0 --acoustic-scale=0.083333 \ 16 | --allow-partial=true --word-symbol-table=$modeldir/words.txt \ 17 | $modeldir/final.mdl $modeldir/HCLG.fst "$feats" ark,t:test.tra || exit 1; 18 | 19 | rm feats 20 | 21 | perl int2sym.pl --ignore-first-field $modeldir/words.txt test.tra > test.hyp 22 | 23 | compute-wer --text --mode=present ark:test.ref ark:test.hyp > test.wer 24 | -------------------------------------------------------------------------------- /egs/case1/baseline/int2sym.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Copyright 2010-2011 Microsoft Corporation 3 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 | # KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 12 | # WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 13 | # MERCHANTABLITY OR NON-INFRINGEMENT. 14 | # See the Apache 2 License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | $ignore_noninteger = 0; 19 | $ignore_first_field = 0; 20 | $field = -1; 21 | for($x = 0; $x < 2; $x++) { 22 | if($ARGV[0] eq "--ignore-noninteger") { $ignore_noninteger = 1; shift @ARGV; } 23 | if($ARGV[0] eq "--ignore-first-field") { $ignore_first_field = 1; shift @ARGV; } 24 | if($ARGV[0] eq "--field") { 25 | shift @ARGV; $field = $ARGV[0]+0; shift @ARGV; 26 | if ($field < 1) { die "Bad argument to --field option: $field"; } 27 | } 28 | } 29 | 30 | if ($ignore_first_field && $field > 0) { die "Incompatible options ignore-first-field and field"; } 31 | $zfield = $field-1; # Change to zero-based indexing. 32 | 33 | $symtab = shift @ARGV; 34 | if(!defined $symtab) { 35 | die "Usage: sym2int.pl symtab [input] > output\n"; 36 | } 37 | open(F, "<$symtab") || die "Error opening symbol table file $symtab"; 38 | while() { 39 | @A = split(" ", $_); 40 | @A == 2 || die "bad line in symbol table file: $_"; 41 | $int2sym{$A[1]} = $A[0]; 42 | } 43 | 44 | sub int2sym { 45 | my $a = shift @_; 46 | my $pos = shift @_; 47 | if($a !~ m:^\d+$:) { # not all digits.. 48 | if($ignore_noninteger) { 49 | print $a . " "; 50 | next; 51 | } else { 52 | if($pos == 0) { 53 | die "int2sym.pl: found noninteger token $a (try --ignore-first-field)\n"; 54 | } else { 55 | die "int2sym.pl: found noninteger token $a (try --ignore-noninteger if valid input)\n"; 56 | } 57 | } 58 | } 59 | $s = $int2sym{$a}; 60 | if(!defined ($s)) { 61 | die "int2sym.pl: integer $a not in symbol table $symtab."; 62 | } 63 | return $s; 64 | } 65 | 66 | $error = 0; 67 | while(<>) { 68 | @A = split(" ", $_); 69 | if($ignore_first_field) { 70 | $key = shift @A; 71 | print $key . " "; 72 | } 73 | if ($field != -1) { 74 | if ($zfield <= $#A && $zfield >= 0) { 75 | $a = $A[$zfield]; 76 | $A[$zfield] = int2sym($a, $zfield); 77 | } 78 | print join(" ", @A); 79 | } else { 80 | for ($pos = 0; $pos <= $#A; $pos++) { 81 | $a = $A[$pos]; 82 | $s = int2sym($a, $pos); 83 | print $s . " "; 84 | } 85 | } 86 | print "\n"; 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /egs/case1/baseline/mfcc.conf: -------------------------------------------------------------------------------- 1 | --use-energy=false 2 | --vtln-warp=1 3 | -------------------------------------------------------------------------------- /egs/case1/baseline/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | { time ./baseline.sh ; } &> baseline.log 4 | -------------------------------------------------------------------------------- /egs/case1/baseline/test.scp: -------------------------------------------------------------------------------- 1 | 440c0201 ../../data/aurora4/test_clean_wv1/440/440c0201.wav 2 | 440c0202 ../../data/aurora4/test_clean_wv1/440/440c0202.wav 3 | 440c0203 ../../data/aurora4/test_clean_wv1/440/440c0203.wav 4 | 440c0204 ../../data/aurora4/test_clean_wv1/440/440c0204.wav 5 | 440c0205 ../../data/aurora4/test_clean_wv1/440/440c0205.wav 6 | 440c0206 ../../data/aurora4/test_clean_wv1/440/440c0206.wav 7 | 440c0207 ../../data/aurora4/test_clean_wv1/440/440c0207.wav 8 | 440c0208 ../../data/aurora4/test_clean_wv1/440/440c0208.wav 9 | 440c0209 ../../data/aurora4/test_clean_wv1/440/440c0209.wav 10 | 440c020a ../../data/aurora4/test_clean_wv1/440/440c020a.wav 11 | 440c020b ../../data/aurora4/test_clean_wv1/440/440c020b.wav 12 | 440c020c ../../data/aurora4/test_clean_wv1/440/440c020c.wav 13 | 440c020d ../../data/aurora4/test_clean_wv1/440/440c020d.wav 14 | 440c020e ../../data/aurora4/test_clean_wv1/440/440c020e.wav 15 | 440c020f ../../data/aurora4/test_clean_wv1/440/440c020f.wav 16 | 440c020g ../../data/aurora4/test_clean_wv1/440/440c020g.wav 17 | 440c020h ../../data/aurora4/test_clean_wv1/440/440c020h.wav 18 | 440c020i ../../data/aurora4/test_clean_wv1/440/440c020i.wav 19 | 440c020j ../../data/aurora4/test_clean_wv1/440/440c020j.wav 20 | 440c020k ../../data/aurora4/test_clean_wv1/440/440c020k.wav 21 | 440c020l ../../data/aurora4/test_clean_wv1/440/440c020l.wav 22 | 440c020m ../../data/aurora4/test_clean_wv1/440/440c020m.wav 23 | 440c020n ../../data/aurora4/test_clean_wv1/440/440c020n.wav 24 | 440c020o ../../data/aurora4/test_clean_wv1/440/440c020o.wav 25 | 440c020p ../../data/aurora4/test_clean_wv1/440/440c020p.wav 26 | 440c020q ../../data/aurora4/test_clean_wv1/440/440c020q.wav 27 | 440c020r ../../data/aurora4/test_clean_wv1/440/440c020r.wav 28 | 440c020s ../../data/aurora4/test_clean_wv1/440/440c020s.wav 29 | 440c020t ../../data/aurora4/test_clean_wv1/440/440c020t.wav 30 | 440c020u ../../data/aurora4/test_clean_wv1/440/440c020u.wav 31 | 440c020v ../../data/aurora4/test_clean_wv1/440/440c020v.wav 32 | 440c020w ../../data/aurora4/test_clean_wv1/440/440c020w.wav 33 | 440c020x ../../data/aurora4/test_clean_wv1/440/440c020x.wav 34 | 440c020y ../../data/aurora4/test_clean_wv1/440/440c020y.wav 35 | 440c020z ../../data/aurora4/test_clean_wv1/440/440c020z.wav 36 | 440c0210 ../../data/aurora4/test_clean_wv1/440/440c0210.wav 37 | 440c0211 ../../data/aurora4/test_clean_wv1/440/440c0211.wav 38 | 440c0212 ../../data/aurora4/test_clean_wv1/440/440c0212.wav 39 | 440c0213 ../../data/aurora4/test_clean_wv1/440/440c0213.wav 40 | 440c0214 ../../data/aurora4/test_clean_wv1/440/440c0214.wav 41 | 441c0201 ../../data/aurora4/test_clean_wv1/441/441c0201.wav 42 | 441c0202 ../../data/aurora4/test_clean_wv1/441/441c0202.wav 43 | 441c0203 ../../data/aurora4/test_clean_wv1/441/441c0203.wav 44 | 441c0204 ../../data/aurora4/test_clean_wv1/441/441c0204.wav 45 | 441c0205 ../../data/aurora4/test_clean_wv1/441/441c0205.wav 46 | 441c0206 ../../data/aurora4/test_clean_wv1/441/441c0206.wav 47 | 441c0207 ../../data/aurora4/test_clean_wv1/441/441c0207.wav 48 | 441c0208 ../../data/aurora4/test_clean_wv1/441/441c0208.wav 49 | 441c0209 ../../data/aurora4/test_clean_wv1/441/441c0209.wav 50 | 441c020a ../../data/aurora4/test_clean_wv1/441/441c020a.wav 51 | 441c020b ../../data/aurora4/test_clean_wv1/441/441c020b.wav 52 | 441c020c ../../data/aurora4/test_clean_wv1/441/441c020c.wav 53 | 441c020d ../../data/aurora4/test_clean_wv1/441/441c020d.wav 54 | 441c020e ../../data/aurora4/test_clean_wv1/441/441c020e.wav 55 | 441c020f ../../data/aurora4/test_clean_wv1/441/441c020f.wav 56 | 441c020g ../../data/aurora4/test_clean_wv1/441/441c020g.wav 57 | 441c020h ../../data/aurora4/test_clean_wv1/441/441c020h.wav 58 | 441c020i ../../data/aurora4/test_clean_wv1/441/441c020i.wav 59 | 441c020j ../../data/aurora4/test_clean_wv1/441/441c020j.wav 60 | 441c020k ../../data/aurora4/test_clean_wv1/441/441c020k.wav 61 | 441c020l ../../data/aurora4/test_clean_wv1/441/441c020l.wav 62 | 441c020m ../../data/aurora4/test_clean_wv1/441/441c020m.wav 63 | 441c020n ../../data/aurora4/test_clean_wv1/441/441c020n.wav 64 | 441c020o ../../data/aurora4/test_clean_wv1/441/441c020o.wav 65 | 441c020p ../../data/aurora4/test_clean_wv1/441/441c020p.wav 66 | 441c020q ../../data/aurora4/test_clean_wv1/441/441c020q.wav 67 | 441c020r ../../data/aurora4/test_clean_wv1/441/441c020r.wav 68 | 441c020s ../../data/aurora4/test_clean_wv1/441/441c020s.wav 69 | 441c020t ../../data/aurora4/test_clean_wv1/441/441c020t.wav 70 | 441c020u ../../data/aurora4/test_clean_wv1/441/441c020u.wav 71 | 441c020v ../../data/aurora4/test_clean_wv1/441/441c020v.wav 72 | 441c020w ../../data/aurora4/test_clean_wv1/441/441c020w.wav 73 | 441c020x ../../data/aurora4/test_clean_wv1/441/441c020x.wav 74 | 441c020y ../../data/aurora4/test_clean_wv1/441/441c020y.wav 75 | 441c020z ../../data/aurora4/test_clean_wv1/441/441c020z.wav 76 | 441c0210 ../../data/aurora4/test_clean_wv1/441/441c0210.wav 77 | 441c0211 ../../data/aurora4/test_clean_wv1/441/441c0211.wav 78 | 441c0212 ../../data/aurora4/test_clean_wv1/441/441c0212.wav 79 | 441c0213 ../../data/aurora4/test_clean_wv1/441/441c0213.wav 80 | 441c0214 ../../data/aurora4/test_clean_wv1/441/441c0214.wav 81 | 441c0215 ../../data/aurora4/test_clean_wv1/441/441c0215.wav 82 | 441c0216 ../../data/aurora4/test_clean_wv1/441/441c0216.wav 83 | 442c0201 ../../data/aurora4/test_clean_wv1/442/442c0201.wav 84 | 442c0202 ../../data/aurora4/test_clean_wv1/442/442c0202.wav 85 | 442c0203 ../../data/aurora4/test_clean_wv1/442/442c0203.wav 86 | 442c0204 ../../data/aurora4/test_clean_wv1/442/442c0204.wav 87 | 442c0205 ../../data/aurora4/test_clean_wv1/442/442c0205.wav 88 | 442c0206 ../../data/aurora4/test_clean_wv1/442/442c0206.wav 89 | 442c0207 ../../data/aurora4/test_clean_wv1/442/442c0207.wav 90 | 442c0208 ../../data/aurora4/test_clean_wv1/442/442c0208.wav 91 | 442c0209 ../../data/aurora4/test_clean_wv1/442/442c0209.wav 92 | 442c020a ../../data/aurora4/test_clean_wv1/442/442c020a.wav 93 | 442c020b ../../data/aurora4/test_clean_wv1/442/442c020b.wav 94 | 442c020c ../../data/aurora4/test_clean_wv1/442/442c020c.wav 95 | 442c020d ../../data/aurora4/test_clean_wv1/442/442c020d.wav 96 | 442c020e ../../data/aurora4/test_clean_wv1/442/442c020e.wav 97 | 442c020f ../../data/aurora4/test_clean_wv1/442/442c020f.wav 98 | 442c020g ../../data/aurora4/test_clean_wv1/442/442c020g.wav 99 | 442c020h ../../data/aurora4/test_clean_wv1/442/442c020h.wav 100 | 442c020i ../../data/aurora4/test_clean_wv1/442/442c020i.wav 101 | 442c020j ../../data/aurora4/test_clean_wv1/442/442c020j.wav 102 | 442c020k ../../data/aurora4/test_clean_wv1/442/442c020k.wav 103 | 442c020l ../../data/aurora4/test_clean_wv1/442/442c020l.wav 104 | 442c020m ../../data/aurora4/test_clean_wv1/442/442c020m.wav 105 | 442c020n ../../data/aurora4/test_clean_wv1/442/442c020n.wav 106 | 442c020o ../../data/aurora4/test_clean_wv1/442/442c020o.wav 107 | 442c020p ../../data/aurora4/test_clean_wv1/442/442c020p.wav 108 | 442c020q ../../data/aurora4/test_clean_wv1/442/442c020q.wav 109 | 442c020r ../../data/aurora4/test_clean_wv1/442/442c020r.wav 110 | 442c020s ../../data/aurora4/test_clean_wv1/442/442c020s.wav 111 | 442c020t ../../data/aurora4/test_clean_wv1/442/442c020t.wav 112 | 442c020u ../../data/aurora4/test_clean_wv1/442/442c020u.wav 113 | 442c020v ../../data/aurora4/test_clean_wv1/442/442c020v.wav 114 | 442c020w ../../data/aurora4/test_clean_wv1/442/442c020w.wav 115 | 442c020x ../../data/aurora4/test_clean_wv1/442/442c020x.wav 116 | 442c020y ../../data/aurora4/test_clean_wv1/442/442c020y.wav 117 | 442c020z ../../data/aurora4/test_clean_wv1/442/442c020z.wav 118 | 442c0210 ../../data/aurora4/test_clean_wv1/442/442c0210.wav 119 | 442c0211 ../../data/aurora4/test_clean_wv1/442/442c0211.wav 120 | 442c0212 ../../data/aurora4/test_clean_wv1/442/442c0212.wav 121 | 442c0213 ../../data/aurora4/test_clean_wv1/442/442c0213.wav 122 | 442c0214 ../../data/aurora4/test_clean_wv1/442/442c0214.wav 123 | 442c0215 ../../data/aurora4/test_clean_wv1/442/442c0215.wav 124 | 442c0216 ../../data/aurora4/test_clean_wv1/442/442c0216.wav 125 | 443c0201 ../../data/aurora4/test_clean_wv1/443/443c0201.wav 126 | 443c0202 ../../data/aurora4/test_clean_wv1/443/443c0202.wav 127 | 443c0203 ../../data/aurora4/test_clean_wv1/443/443c0203.wav 128 | 443c0204 ../../data/aurora4/test_clean_wv1/443/443c0204.wav 129 | 443c0205 ../../data/aurora4/test_clean_wv1/443/443c0205.wav 130 | 443c0206 ../../data/aurora4/test_clean_wv1/443/443c0206.wav 131 | 443c0207 ../../data/aurora4/test_clean_wv1/443/443c0207.wav 132 | 443c0208 ../../data/aurora4/test_clean_wv1/443/443c0208.wav 133 | 443c0209 ../../data/aurora4/test_clean_wv1/443/443c0209.wav 134 | 443c020a ../../data/aurora4/test_clean_wv1/443/443c020a.wav 135 | 443c020b ../../data/aurora4/test_clean_wv1/443/443c020b.wav 136 | 443c020c ../../data/aurora4/test_clean_wv1/443/443c020c.wav 137 | 443c020d ../../data/aurora4/test_clean_wv1/443/443c020d.wav 138 | 443c020e ../../data/aurora4/test_clean_wv1/443/443c020e.wav 139 | 443c020f ../../data/aurora4/test_clean_wv1/443/443c020f.wav 140 | 443c020g ../../data/aurora4/test_clean_wv1/443/443c020g.wav 141 | 443c020h ../../data/aurora4/test_clean_wv1/443/443c020h.wav 142 | 443c020i ../../data/aurora4/test_clean_wv1/443/443c020i.wav 143 | 443c020j ../../data/aurora4/test_clean_wv1/443/443c020j.wav 144 | 443c020k ../../data/aurora4/test_clean_wv1/443/443c020k.wav 145 | 443c020l ../../data/aurora4/test_clean_wv1/443/443c020l.wav 146 | 443c020m ../../data/aurora4/test_clean_wv1/443/443c020m.wav 147 | 443c020n ../../data/aurora4/test_clean_wv1/443/443c020n.wav 148 | 443c020o ../../data/aurora4/test_clean_wv1/443/443c020o.wav 149 | 443c020p ../../data/aurora4/test_clean_wv1/443/443c020p.wav 150 | 443c020q ../../data/aurora4/test_clean_wv1/443/443c020q.wav 151 | 443c020r ../../data/aurora4/test_clean_wv1/443/443c020r.wav 152 | 443c020s ../../data/aurora4/test_clean_wv1/443/443c020s.wav 153 | 443c020t ../../data/aurora4/test_clean_wv1/443/443c020t.wav 154 | 443c020u ../../data/aurora4/test_clean_wv1/443/443c020u.wav 155 | 443c020v ../../data/aurora4/test_clean_wv1/443/443c020v.wav 156 | 443c020w ../../data/aurora4/test_clean_wv1/443/443c020w.wav 157 | 443c020x ../../data/aurora4/test_clean_wv1/443/443c020x.wav 158 | 443c020y ../../data/aurora4/test_clean_wv1/443/443c020y.wav 159 | 443c020z ../../data/aurora4/test_clean_wv1/443/443c020z.wav 160 | 443c0210 ../../data/aurora4/test_clean_wv1/443/443c0210.wav 161 | 443c0211 ../../data/aurora4/test_clean_wv1/443/443c0211.wav 162 | 443c0212 ../../data/aurora4/test_clean_wv1/443/443c0212.wav 163 | 443c0213 ../../data/aurora4/test_clean_wv1/443/443c0213.wav 164 | 443c0214 ../../data/aurora4/test_clean_wv1/443/443c0214.wav 165 | 444c0201 ../../data/aurora4/test_clean_wv1/444/444c0201.wav 166 | 444c0202 ../../data/aurora4/test_clean_wv1/444/444c0202.wav 167 | 444c0203 ../../data/aurora4/test_clean_wv1/444/444c0203.wav 168 | 444c0204 ../../data/aurora4/test_clean_wv1/444/444c0204.wav 169 | 444c0205 ../../data/aurora4/test_clean_wv1/444/444c0205.wav 170 | 444c0206 ../../data/aurora4/test_clean_wv1/444/444c0206.wav 171 | 444c0207 ../../data/aurora4/test_clean_wv1/444/444c0207.wav 172 | 444c0208 ../../data/aurora4/test_clean_wv1/444/444c0208.wav 173 | 444c0209 ../../data/aurora4/test_clean_wv1/444/444c0209.wav 174 | 444c020a ../../data/aurora4/test_clean_wv1/444/444c020a.wav 175 | 444c020b ../../data/aurora4/test_clean_wv1/444/444c020b.wav 176 | 444c020c ../../data/aurora4/test_clean_wv1/444/444c020c.wav 177 | 444c020d ../../data/aurora4/test_clean_wv1/444/444c020d.wav 178 | 444c020e ../../data/aurora4/test_clean_wv1/444/444c020e.wav 179 | 444c020f ../../data/aurora4/test_clean_wv1/444/444c020f.wav 180 | 444c020g ../../data/aurora4/test_clean_wv1/444/444c020g.wav 181 | 444c020h ../../data/aurora4/test_clean_wv1/444/444c020h.wav 182 | 444c020i ../../data/aurora4/test_clean_wv1/444/444c020i.wav 183 | 444c020j ../../data/aurora4/test_clean_wv1/444/444c020j.wav 184 | 444c020k ../../data/aurora4/test_clean_wv1/444/444c020k.wav 185 | 444c020l ../../data/aurora4/test_clean_wv1/444/444c020l.wav 186 | 444c020m ../../data/aurora4/test_clean_wv1/444/444c020m.wav 187 | 444c020n ../../data/aurora4/test_clean_wv1/444/444c020n.wav 188 | 444c020o ../../data/aurora4/test_clean_wv1/444/444c020o.wav 189 | 444c020p ../../data/aurora4/test_clean_wv1/444/444c020p.wav 190 | 444c020q ../../data/aurora4/test_clean_wv1/444/444c020q.wav 191 | 444c020r ../../data/aurora4/test_clean_wv1/444/444c020r.wav 192 | 444c020s ../../data/aurora4/test_clean_wv1/444/444c020s.wav 193 | 444c020t ../../data/aurora4/test_clean_wv1/444/444c020t.wav 194 | 444c020u ../../data/aurora4/test_clean_wv1/444/444c020u.wav 195 | 444c020v ../../data/aurora4/test_clean_wv1/444/444c020v.wav 196 | 444c020w ../../data/aurora4/test_clean_wv1/444/444c020w.wav 197 | 444c020x ../../data/aurora4/test_clean_wv1/444/444c020x.wav 198 | 444c020y ../../data/aurora4/test_clean_wv1/444/444c020y.wav 199 | 444c020z ../../data/aurora4/test_clean_wv1/444/444c020z.wav 200 | 444c0210 ../../data/aurora4/test_clean_wv1/444/444c0210.wav 201 | 444c0211 ../../data/aurora4/test_clean_wv1/444/444c0211.wav 202 | 444c0212 ../../data/aurora4/test_clean_wv1/444/444c0212.wav 203 | 444c0213 ../../data/aurora4/test_clean_wv1/444/444c0213.wav 204 | 444c0214 ../../data/aurora4/test_clean_wv1/444/444c0214.wav 205 | 444c0215 ../../data/aurora4/test_clean_wv1/444/444c0215.wav 206 | 445c0201 ../../data/aurora4/test_clean_wv1/445/445c0201.wav 207 | 445c0202 ../../data/aurora4/test_clean_wv1/445/445c0202.wav 208 | 445c0203 ../../data/aurora4/test_clean_wv1/445/445c0203.wav 209 | 445c0204 ../../data/aurora4/test_clean_wv1/445/445c0204.wav 210 | 445c0205 ../../data/aurora4/test_clean_wv1/445/445c0205.wav 211 | 445c0206 ../../data/aurora4/test_clean_wv1/445/445c0206.wav 212 | 445c0207 ../../data/aurora4/test_clean_wv1/445/445c0207.wav 213 | 445c0208 ../../data/aurora4/test_clean_wv1/445/445c0208.wav 214 | 445c0209 ../../data/aurora4/test_clean_wv1/445/445c0209.wav 215 | 445c020a ../../data/aurora4/test_clean_wv1/445/445c020a.wav 216 | 445c020b ../../data/aurora4/test_clean_wv1/445/445c020b.wav 217 | 445c020c ../../data/aurora4/test_clean_wv1/445/445c020c.wav 218 | 445c020d ../../data/aurora4/test_clean_wv1/445/445c020d.wav 219 | 445c020e ../../data/aurora4/test_clean_wv1/445/445c020e.wav 220 | 445c020f ../../data/aurora4/test_clean_wv1/445/445c020f.wav 221 | 445c020g ../../data/aurora4/test_clean_wv1/445/445c020g.wav 222 | 445c020h ../../data/aurora4/test_clean_wv1/445/445c020h.wav 223 | 445c020i ../../data/aurora4/test_clean_wv1/445/445c020i.wav 224 | 445c020j ../../data/aurora4/test_clean_wv1/445/445c020j.wav 225 | 445c020k ../../data/aurora4/test_clean_wv1/445/445c020k.wav 226 | 445c020l ../../data/aurora4/test_clean_wv1/445/445c020l.wav 227 | 445c020m ../../data/aurora4/test_clean_wv1/445/445c020m.wav 228 | 445c020n ../../data/aurora4/test_clean_wv1/445/445c020n.wav 229 | 445c020o ../../data/aurora4/test_clean_wv1/445/445c020o.wav 230 | 445c020p ../../data/aurora4/test_clean_wv1/445/445c020p.wav 231 | 445c020q ../../data/aurora4/test_clean_wv1/445/445c020q.wav 232 | 445c020r ../../data/aurora4/test_clean_wv1/445/445c020r.wav 233 | 445c020s ../../data/aurora4/test_clean_wv1/445/445c020s.wav 234 | 445c020t ../../data/aurora4/test_clean_wv1/445/445c020t.wav 235 | 445c020u ../../data/aurora4/test_clean_wv1/445/445c020u.wav 236 | 445c020v ../../data/aurora4/test_clean_wv1/445/445c020v.wav 237 | 445c020w ../../data/aurora4/test_clean_wv1/445/445c020w.wav 238 | 445c020x ../../data/aurora4/test_clean_wv1/445/445c020x.wav 239 | 445c020y ../../data/aurora4/test_clean_wv1/445/445c020y.wav 240 | 445c020z ../../data/aurora4/test_clean_wv1/445/445c020z.wav 241 | 445c0210 ../../data/aurora4/test_clean_wv1/445/445c0210.wav 242 | 445c0211 ../../data/aurora4/test_clean_wv1/445/445c0211.wav 243 | 445c0212 ../../data/aurora4/test_clean_wv1/445/445c0212.wav 244 | 445c0213 ../../data/aurora4/test_clean_wv1/445/445c0213.wav 245 | 445c0214 ../../data/aurora4/test_clean_wv1/445/445c0214.wav 246 | 445c0215 ../../data/aurora4/test_clean_wv1/445/445c0215.wav 247 | 445c0216 ../../data/aurora4/test_clean_wv1/445/445c0216.wav 248 | 446c0201 ../../data/aurora4/test_clean_wv1/446/446c0201.wav 249 | 446c0202 ../../data/aurora4/test_clean_wv1/446/446c0202.wav 250 | 446c0203 ../../data/aurora4/test_clean_wv1/446/446c0203.wav 251 | 446c0204 ../../data/aurora4/test_clean_wv1/446/446c0204.wav 252 | 446c0205 ../../data/aurora4/test_clean_wv1/446/446c0205.wav 253 | 446c0206 ../../data/aurora4/test_clean_wv1/446/446c0206.wav 254 | 446c0207 ../../data/aurora4/test_clean_wv1/446/446c0207.wav 255 | 446c0208 ../../data/aurora4/test_clean_wv1/446/446c0208.wav 256 | 446c0209 ../../data/aurora4/test_clean_wv1/446/446c0209.wav 257 | 446c020a ../../data/aurora4/test_clean_wv1/446/446c020a.wav 258 | 446c020b ../../data/aurora4/test_clean_wv1/446/446c020b.wav 259 | 446c020c ../../data/aurora4/test_clean_wv1/446/446c020c.wav 260 | 446c020d ../../data/aurora4/test_clean_wv1/446/446c020d.wav 261 | 446c020e ../../data/aurora4/test_clean_wv1/446/446c020e.wav 262 | 446c020f ../../data/aurora4/test_clean_wv1/446/446c020f.wav 263 | 446c020g ../../data/aurora4/test_clean_wv1/446/446c020g.wav 264 | 446c020h ../../data/aurora4/test_clean_wv1/446/446c020h.wav 265 | 446c020i ../../data/aurora4/test_clean_wv1/446/446c020i.wav 266 | 446c020j ../../data/aurora4/test_clean_wv1/446/446c020j.wav 267 | 446c020k ../../data/aurora4/test_clean_wv1/446/446c020k.wav 268 | 446c020l ../../data/aurora4/test_clean_wv1/446/446c020l.wav 269 | 446c020m ../../data/aurora4/test_clean_wv1/446/446c020m.wav 270 | 446c020n ../../data/aurora4/test_clean_wv1/446/446c020n.wav 271 | 446c020o ../../data/aurora4/test_clean_wv1/446/446c020o.wav 272 | 446c020p ../../data/aurora4/test_clean_wv1/446/446c020p.wav 273 | 446c020q ../../data/aurora4/test_clean_wv1/446/446c020q.wav 274 | 446c020r ../../data/aurora4/test_clean_wv1/446/446c020r.wav 275 | 446c020s ../../data/aurora4/test_clean_wv1/446/446c020s.wav 276 | 446c020t ../../data/aurora4/test_clean_wv1/446/446c020t.wav 277 | 446c020u ../../data/aurora4/test_clean_wv1/446/446c020u.wav 278 | 446c020v ../../data/aurora4/test_clean_wv1/446/446c020v.wav 279 | 446c020w ../../data/aurora4/test_clean_wv1/446/446c020w.wav 280 | 446c020x ../../data/aurora4/test_clean_wv1/446/446c020x.wav 281 | 446c020y ../../data/aurora4/test_clean_wv1/446/446c020y.wav 282 | 446c020z ../../data/aurora4/test_clean_wv1/446/446c020z.wav 283 | 446c0210 ../../data/aurora4/test_clean_wv1/446/446c0210.wav 284 | 446c0211 ../../data/aurora4/test_clean_wv1/446/446c0211.wav 285 | 446c0212 ../../data/aurora4/test_clean_wv1/446/446c0212.wav 286 | 446c0213 ../../data/aurora4/test_clean_wv1/446/446c0213.wav 287 | 446c0214 ../../data/aurora4/test_clean_wv1/446/446c0214.wav 288 | 447c0201 ../../data/aurora4/test_clean_wv1/447/447c0201.wav 289 | 447c0202 ../../data/aurora4/test_clean_wv1/447/447c0202.wav 290 | 447c0203 ../../data/aurora4/test_clean_wv1/447/447c0203.wav 291 | 447c0204 ../../data/aurora4/test_clean_wv1/447/447c0204.wav 292 | 447c0205 ../../data/aurora4/test_clean_wv1/447/447c0205.wav 293 | 447c0206 ../../data/aurora4/test_clean_wv1/447/447c0206.wav 294 | 447c0207 ../../data/aurora4/test_clean_wv1/447/447c0207.wav 295 | 447c0208 ../../data/aurora4/test_clean_wv1/447/447c0208.wav 296 | 447c0209 ../../data/aurora4/test_clean_wv1/447/447c0209.wav 297 | 447c020a ../../data/aurora4/test_clean_wv1/447/447c020a.wav 298 | 447c020b ../../data/aurora4/test_clean_wv1/447/447c020b.wav 299 | 447c020c ../../data/aurora4/test_clean_wv1/447/447c020c.wav 300 | 447c020d ../../data/aurora4/test_clean_wv1/447/447c020d.wav 301 | 447c020e ../../data/aurora4/test_clean_wv1/447/447c020e.wav 302 | 447c020f ../../data/aurora4/test_clean_wv1/447/447c020f.wav 303 | 447c020g ../../data/aurora4/test_clean_wv1/447/447c020g.wav 304 | 447c020h ../../data/aurora4/test_clean_wv1/447/447c020h.wav 305 | 447c020i ../../data/aurora4/test_clean_wv1/447/447c020i.wav 306 | 447c020j ../../data/aurora4/test_clean_wv1/447/447c020j.wav 307 | 447c020k ../../data/aurora4/test_clean_wv1/447/447c020k.wav 308 | 447c020l ../../data/aurora4/test_clean_wv1/447/447c020l.wav 309 | 447c020m ../../data/aurora4/test_clean_wv1/447/447c020m.wav 310 | 447c020n ../../data/aurora4/test_clean_wv1/447/447c020n.wav 311 | 447c020o ../../data/aurora4/test_clean_wv1/447/447c020o.wav 312 | 447c020p ../../data/aurora4/test_clean_wv1/447/447c020p.wav 313 | 447c020q ../../data/aurora4/test_clean_wv1/447/447c020q.wav 314 | 447c020r ../../data/aurora4/test_clean_wv1/447/447c020r.wav 315 | 447c020s ../../data/aurora4/test_clean_wv1/447/447c020s.wav 316 | 447c020t ../../data/aurora4/test_clean_wv1/447/447c020t.wav 317 | 447c020u ../../data/aurora4/test_clean_wv1/447/447c020u.wav 318 | 447c020v ../../data/aurora4/test_clean_wv1/447/447c020v.wav 319 | 447c020w ../../data/aurora4/test_clean_wv1/447/447c020w.wav 320 | 447c020x ../../data/aurora4/test_clean_wv1/447/447c020x.wav 321 | 447c020y ../../data/aurora4/test_clean_wv1/447/447c020y.wav 322 | 447c020z ../../data/aurora4/test_clean_wv1/447/447c020z.wav 323 | 447c0210 ../../data/aurora4/test_clean_wv1/447/447c0210.wav 324 | 447c0211 ../../data/aurora4/test_clean_wv1/447/447c0211.wav 325 | 447c0212 ../../data/aurora4/test_clean_wv1/447/447c0212.wav 326 | 447c0213 ../../data/aurora4/test_clean_wv1/447/447c0213.wav 327 | 447c0214 ../../data/aurora4/test_clean_wv1/447/447c0214.wav 328 | 447c0215 ../../data/aurora4/test_clean_wv1/447/447c0215.wav 329 | 447c0216 ../../data/aurora4/test_clean_wv1/447/447c0216.wav 330 | 447c0217 ../../data/aurora4/test_clean_wv1/447/447c0217.wav 331 | -------------------------------------------------------------------------------- /egs/case1/baseline/test.wer: -------------------------------------------------------------------------------- 1 | %WER 14.46 [ 774 / 5353, 76 ins, 144 del, 554 sub ] 2 | %SER 67.88 [ 224 / 330 ] 3 | Scored 330 sentences, 0 not present in hyp. 4 | -------------------------------------------------------------------------------- /egs/case1/benchmark/benchmark.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BARISTAROOT=../../.. 4 | KALDISRC=$BARISTAROOT/tools/kaldi/src 5 | export PATH=$BARISTAROOT/bin:$KALDISRC/bin:$PATH 6 | 7 | modeldir=../../models/wsj 8 | 9 | barista conf/actors.ini conf/graph.dot 10 | 11 | perl int2sym.pl --ignore-first-field $modeldir/words.txt test.tra > test.hyp 12 | 13 | compute-wer --text --mode=present ark:test.ref ark:test.hyp > test.wer 14 | -------------------------------------------------------------------------------- /egs/case1/benchmark/conf/actors.ini: -------------------------------------------------------------------------------- 1 | ; Readers 2 | [m_file_list_reader] 3 | actor_type = FileListReader 4 | file_list = pcm.list 5 | 6 | [m_pcm_reader] 7 | actor_type = PCMReader 8 | samples_per_chunk = 2000 9 | bits_per_sample = 16 10 | 11 | ; Feature extraction / transformation modules 12 | [m_mfcc_extractor] 13 | actor_type = ComputeMFCCFeats 14 | use_energy = false 15 | vtln_warp_local = 1 16 | 17 | [m_cmvn_applier] 18 | actor_type = ApplyCMVN 19 | norm_vars = false 20 | context_size = 1000 21 | 22 | [m_delta_adder] 23 | actor_type = AddDeltas 24 | 25 | ; Decoders 26 | [m_gmm_decoder] 27 | actor_type = GMMDecodeFasterOnline 28 | max_active = 7000 29 | beam = 13.0 30 | acoustic_scale = 0.083333 31 | allow_partial = true 32 | model_rxfilename = ../../models/wsj/final.mdl 33 | fst_rxfilename = ../../models/wsj/HCLG.fst 34 | word_syms_filename = ../../models/wsj/words.txt 35 | words_wspecifier = ark,t:test.tra 36 | alignment_wspecifier = 37 | lattice_wspecifier = 38 | -------------------------------------------------------------------------------- /egs/case1/benchmark/conf/graph.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | m_file_list_reader -> m_pcm_reader; 3 | m_pcm_reader -> m_mfcc_extractor; 4 | m_mfcc_extractor -> m_cmvn_applier; 5 | m_cmvn_applier -> m_delta_adder; 6 | m_delta_adder -> m_gmm_decoder; 7 | } 8 | -------------------------------------------------------------------------------- /egs/case1/benchmark/int2sym.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Copyright 2010-2011 Microsoft Corporation 3 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 | # KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 12 | # WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 13 | # MERCHANTABLITY OR NON-INFRINGEMENT. 14 | # See the Apache 2 License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | $ignore_noninteger = 0; 19 | $ignore_first_field = 0; 20 | $field = -1; 21 | for($x = 0; $x < 2; $x++) { 22 | if($ARGV[0] eq "--ignore-noninteger") { $ignore_noninteger = 1; shift @ARGV; } 23 | if($ARGV[0] eq "--ignore-first-field") { $ignore_first_field = 1; shift @ARGV; } 24 | if($ARGV[0] eq "--field") { 25 | shift @ARGV; $field = $ARGV[0]+0; shift @ARGV; 26 | if ($field < 1) { die "Bad argument to --field option: $field"; } 27 | } 28 | } 29 | 30 | if ($ignore_first_field && $field > 0) { die "Incompatible options ignore-first-field and field"; } 31 | $zfield = $field-1; # Change to zero-based indexing. 32 | 33 | $symtab = shift @ARGV; 34 | if(!defined $symtab) { 35 | die "Usage: sym2int.pl symtab [input] > output\n"; 36 | } 37 | open(F, "<$symtab") || die "Error opening symbol table file $symtab"; 38 | while() { 39 | @A = split(" ", $_); 40 | @A == 2 || die "bad line in symbol table file: $_"; 41 | $int2sym{$A[1]} = $A[0]; 42 | } 43 | 44 | sub int2sym { 45 | my $a = shift @_; 46 | my $pos = shift @_; 47 | if($a !~ m:^\d+$:) { # not all digits.. 48 | if($ignore_noninteger) { 49 | print $a . " "; 50 | next; 51 | } else { 52 | if($pos == 0) { 53 | die "int2sym.pl: found noninteger token $a (try --ignore-first-field)\n"; 54 | } else { 55 | die "int2sym.pl: found noninteger token $a (try --ignore-noninteger if valid input)\n"; 56 | } 57 | } 58 | } 59 | $s = $int2sym{$a}; 60 | if(!defined ($s)) { 61 | die "int2sym.pl: integer $a not in symbol table $symtab."; 62 | } 63 | return $s; 64 | } 65 | 66 | $error = 0; 67 | while(<>) { 68 | @A = split(" ", $_); 69 | if($ignore_first_field) { 70 | $key = shift @A; 71 | print $key . " "; 72 | } 73 | if ($field != -1) { 74 | if ($zfield <= $#A && $zfield >= 0) { 75 | $a = $A[$zfield]; 76 | $A[$zfield] = int2sym($a, $zfield); 77 | } 78 | print join(" ", @A); 79 | } else { 80 | for ($pos = 0; $pos <= $#A; $pos++) { 81 | $a = $A[$pos]; 82 | $s = int2sym($a, $pos); 83 | print $s . " "; 84 | } 85 | } 86 | print "\n"; 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /egs/case1/benchmark/pcm.list: -------------------------------------------------------------------------------- 1 | ../../data/aurora4/test_clean_wv1/440/440c0201.pcm 2 | ../../data/aurora4/test_clean_wv1/440/440c0202.pcm 3 | ../../data/aurora4/test_clean_wv1/440/440c0203.pcm 4 | ../../data/aurora4/test_clean_wv1/440/440c0204.pcm 5 | ../../data/aurora4/test_clean_wv1/440/440c0205.pcm 6 | ../../data/aurora4/test_clean_wv1/440/440c0206.pcm 7 | ../../data/aurora4/test_clean_wv1/440/440c0207.pcm 8 | ../../data/aurora4/test_clean_wv1/440/440c0208.pcm 9 | ../../data/aurora4/test_clean_wv1/440/440c0209.pcm 10 | ../../data/aurora4/test_clean_wv1/440/440c020a.pcm 11 | ../../data/aurora4/test_clean_wv1/440/440c020b.pcm 12 | ../../data/aurora4/test_clean_wv1/440/440c020c.pcm 13 | ../../data/aurora4/test_clean_wv1/440/440c020d.pcm 14 | ../../data/aurora4/test_clean_wv1/440/440c020e.pcm 15 | ../../data/aurora4/test_clean_wv1/440/440c020f.pcm 16 | ../../data/aurora4/test_clean_wv1/440/440c020g.pcm 17 | ../../data/aurora4/test_clean_wv1/440/440c020h.pcm 18 | ../../data/aurora4/test_clean_wv1/440/440c020i.pcm 19 | ../../data/aurora4/test_clean_wv1/440/440c020j.pcm 20 | ../../data/aurora4/test_clean_wv1/440/440c020k.pcm 21 | ../../data/aurora4/test_clean_wv1/440/440c020l.pcm 22 | ../../data/aurora4/test_clean_wv1/440/440c020m.pcm 23 | ../../data/aurora4/test_clean_wv1/440/440c020n.pcm 24 | ../../data/aurora4/test_clean_wv1/440/440c020o.pcm 25 | ../../data/aurora4/test_clean_wv1/440/440c020p.pcm 26 | ../../data/aurora4/test_clean_wv1/440/440c020q.pcm 27 | ../../data/aurora4/test_clean_wv1/440/440c020r.pcm 28 | ../../data/aurora4/test_clean_wv1/440/440c020s.pcm 29 | ../../data/aurora4/test_clean_wv1/440/440c020t.pcm 30 | ../../data/aurora4/test_clean_wv1/440/440c020u.pcm 31 | ../../data/aurora4/test_clean_wv1/440/440c020v.pcm 32 | ../../data/aurora4/test_clean_wv1/440/440c020w.pcm 33 | ../../data/aurora4/test_clean_wv1/440/440c020x.pcm 34 | ../../data/aurora4/test_clean_wv1/440/440c020y.pcm 35 | ../../data/aurora4/test_clean_wv1/440/440c020z.pcm 36 | ../../data/aurora4/test_clean_wv1/440/440c0210.pcm 37 | ../../data/aurora4/test_clean_wv1/440/440c0211.pcm 38 | ../../data/aurora4/test_clean_wv1/440/440c0212.pcm 39 | ../../data/aurora4/test_clean_wv1/440/440c0213.pcm 40 | ../../data/aurora4/test_clean_wv1/440/440c0214.pcm 41 | ../../data/aurora4/test_clean_wv1/441/441c0201.pcm 42 | ../../data/aurora4/test_clean_wv1/441/441c0202.pcm 43 | ../../data/aurora4/test_clean_wv1/441/441c0203.pcm 44 | ../../data/aurora4/test_clean_wv1/441/441c0204.pcm 45 | ../../data/aurora4/test_clean_wv1/441/441c0205.pcm 46 | ../../data/aurora4/test_clean_wv1/441/441c0206.pcm 47 | ../../data/aurora4/test_clean_wv1/441/441c0207.pcm 48 | ../../data/aurora4/test_clean_wv1/441/441c0208.pcm 49 | ../../data/aurora4/test_clean_wv1/441/441c0209.pcm 50 | ../../data/aurora4/test_clean_wv1/441/441c020a.pcm 51 | ../../data/aurora4/test_clean_wv1/441/441c020b.pcm 52 | ../../data/aurora4/test_clean_wv1/441/441c020c.pcm 53 | ../../data/aurora4/test_clean_wv1/441/441c020d.pcm 54 | ../../data/aurora4/test_clean_wv1/441/441c020e.pcm 55 | ../../data/aurora4/test_clean_wv1/441/441c020f.pcm 56 | ../../data/aurora4/test_clean_wv1/441/441c020g.pcm 57 | ../../data/aurora4/test_clean_wv1/441/441c020h.pcm 58 | ../../data/aurora4/test_clean_wv1/441/441c020i.pcm 59 | ../../data/aurora4/test_clean_wv1/441/441c020j.pcm 60 | ../../data/aurora4/test_clean_wv1/441/441c020k.pcm 61 | ../../data/aurora4/test_clean_wv1/441/441c020l.pcm 62 | ../../data/aurora4/test_clean_wv1/441/441c020m.pcm 63 | ../../data/aurora4/test_clean_wv1/441/441c020n.pcm 64 | ../../data/aurora4/test_clean_wv1/441/441c020o.pcm 65 | ../../data/aurora4/test_clean_wv1/441/441c020p.pcm 66 | ../../data/aurora4/test_clean_wv1/441/441c020q.pcm 67 | ../../data/aurora4/test_clean_wv1/441/441c020r.pcm 68 | ../../data/aurora4/test_clean_wv1/441/441c020s.pcm 69 | ../../data/aurora4/test_clean_wv1/441/441c020t.pcm 70 | ../../data/aurora4/test_clean_wv1/441/441c020u.pcm 71 | ../../data/aurora4/test_clean_wv1/441/441c020v.pcm 72 | ../../data/aurora4/test_clean_wv1/441/441c020w.pcm 73 | ../../data/aurora4/test_clean_wv1/441/441c020x.pcm 74 | ../../data/aurora4/test_clean_wv1/441/441c020y.pcm 75 | ../../data/aurora4/test_clean_wv1/441/441c020z.pcm 76 | ../../data/aurora4/test_clean_wv1/441/441c0210.pcm 77 | ../../data/aurora4/test_clean_wv1/441/441c0211.pcm 78 | ../../data/aurora4/test_clean_wv1/441/441c0212.pcm 79 | ../../data/aurora4/test_clean_wv1/441/441c0213.pcm 80 | ../../data/aurora4/test_clean_wv1/441/441c0214.pcm 81 | ../../data/aurora4/test_clean_wv1/441/441c0215.pcm 82 | ../../data/aurora4/test_clean_wv1/441/441c0216.pcm 83 | ../../data/aurora4/test_clean_wv1/442/442c0201.pcm 84 | ../../data/aurora4/test_clean_wv1/442/442c0202.pcm 85 | ../../data/aurora4/test_clean_wv1/442/442c0203.pcm 86 | ../../data/aurora4/test_clean_wv1/442/442c0204.pcm 87 | ../../data/aurora4/test_clean_wv1/442/442c0205.pcm 88 | ../../data/aurora4/test_clean_wv1/442/442c0206.pcm 89 | ../../data/aurora4/test_clean_wv1/442/442c0207.pcm 90 | ../../data/aurora4/test_clean_wv1/442/442c0208.pcm 91 | ../../data/aurora4/test_clean_wv1/442/442c0209.pcm 92 | ../../data/aurora4/test_clean_wv1/442/442c020a.pcm 93 | ../../data/aurora4/test_clean_wv1/442/442c020b.pcm 94 | ../../data/aurora4/test_clean_wv1/442/442c020c.pcm 95 | ../../data/aurora4/test_clean_wv1/442/442c020d.pcm 96 | ../../data/aurora4/test_clean_wv1/442/442c020e.pcm 97 | ../../data/aurora4/test_clean_wv1/442/442c020f.pcm 98 | ../../data/aurora4/test_clean_wv1/442/442c020g.pcm 99 | ../../data/aurora4/test_clean_wv1/442/442c020h.pcm 100 | ../../data/aurora4/test_clean_wv1/442/442c020i.pcm 101 | ../../data/aurora4/test_clean_wv1/442/442c020j.pcm 102 | ../../data/aurora4/test_clean_wv1/442/442c020k.pcm 103 | ../../data/aurora4/test_clean_wv1/442/442c020l.pcm 104 | ../../data/aurora4/test_clean_wv1/442/442c020m.pcm 105 | ../../data/aurora4/test_clean_wv1/442/442c020n.pcm 106 | ../../data/aurora4/test_clean_wv1/442/442c020o.pcm 107 | ../../data/aurora4/test_clean_wv1/442/442c020p.pcm 108 | ../../data/aurora4/test_clean_wv1/442/442c020q.pcm 109 | ../../data/aurora4/test_clean_wv1/442/442c020r.pcm 110 | ../../data/aurora4/test_clean_wv1/442/442c020s.pcm 111 | ../../data/aurora4/test_clean_wv1/442/442c020t.pcm 112 | ../../data/aurora4/test_clean_wv1/442/442c020u.pcm 113 | ../../data/aurora4/test_clean_wv1/442/442c020v.pcm 114 | ../../data/aurora4/test_clean_wv1/442/442c020w.pcm 115 | ../../data/aurora4/test_clean_wv1/442/442c020x.pcm 116 | ../../data/aurora4/test_clean_wv1/442/442c020y.pcm 117 | ../../data/aurora4/test_clean_wv1/442/442c020z.pcm 118 | ../../data/aurora4/test_clean_wv1/442/442c0210.pcm 119 | ../../data/aurora4/test_clean_wv1/442/442c0211.pcm 120 | ../../data/aurora4/test_clean_wv1/442/442c0212.pcm 121 | ../../data/aurora4/test_clean_wv1/442/442c0213.pcm 122 | ../../data/aurora4/test_clean_wv1/442/442c0214.pcm 123 | ../../data/aurora4/test_clean_wv1/442/442c0215.pcm 124 | ../../data/aurora4/test_clean_wv1/442/442c0216.pcm 125 | ../../data/aurora4/test_clean_wv1/443/443c0201.pcm 126 | ../../data/aurora4/test_clean_wv1/443/443c0202.pcm 127 | ../../data/aurora4/test_clean_wv1/443/443c0203.pcm 128 | ../../data/aurora4/test_clean_wv1/443/443c0204.pcm 129 | ../../data/aurora4/test_clean_wv1/443/443c0205.pcm 130 | ../../data/aurora4/test_clean_wv1/443/443c0206.pcm 131 | ../../data/aurora4/test_clean_wv1/443/443c0207.pcm 132 | ../../data/aurora4/test_clean_wv1/443/443c0208.pcm 133 | ../../data/aurora4/test_clean_wv1/443/443c0209.pcm 134 | ../../data/aurora4/test_clean_wv1/443/443c020a.pcm 135 | ../../data/aurora4/test_clean_wv1/443/443c020b.pcm 136 | ../../data/aurora4/test_clean_wv1/443/443c020c.pcm 137 | ../../data/aurora4/test_clean_wv1/443/443c020d.pcm 138 | ../../data/aurora4/test_clean_wv1/443/443c020e.pcm 139 | ../../data/aurora4/test_clean_wv1/443/443c020f.pcm 140 | ../../data/aurora4/test_clean_wv1/443/443c020g.pcm 141 | ../../data/aurora4/test_clean_wv1/443/443c020h.pcm 142 | ../../data/aurora4/test_clean_wv1/443/443c020i.pcm 143 | ../../data/aurora4/test_clean_wv1/443/443c020j.pcm 144 | ../../data/aurora4/test_clean_wv1/443/443c020k.pcm 145 | ../../data/aurora4/test_clean_wv1/443/443c020l.pcm 146 | ../../data/aurora4/test_clean_wv1/443/443c020m.pcm 147 | ../../data/aurora4/test_clean_wv1/443/443c020n.pcm 148 | ../../data/aurora4/test_clean_wv1/443/443c020o.pcm 149 | ../../data/aurora4/test_clean_wv1/443/443c020p.pcm 150 | ../../data/aurora4/test_clean_wv1/443/443c020q.pcm 151 | ../../data/aurora4/test_clean_wv1/443/443c020r.pcm 152 | ../../data/aurora4/test_clean_wv1/443/443c020s.pcm 153 | ../../data/aurora4/test_clean_wv1/443/443c020t.pcm 154 | ../../data/aurora4/test_clean_wv1/443/443c020u.pcm 155 | ../../data/aurora4/test_clean_wv1/443/443c020v.pcm 156 | ../../data/aurora4/test_clean_wv1/443/443c020w.pcm 157 | ../../data/aurora4/test_clean_wv1/443/443c020x.pcm 158 | ../../data/aurora4/test_clean_wv1/443/443c020y.pcm 159 | ../../data/aurora4/test_clean_wv1/443/443c020z.pcm 160 | ../../data/aurora4/test_clean_wv1/443/443c0210.pcm 161 | ../../data/aurora4/test_clean_wv1/443/443c0211.pcm 162 | ../../data/aurora4/test_clean_wv1/443/443c0212.pcm 163 | ../../data/aurora4/test_clean_wv1/443/443c0213.pcm 164 | ../../data/aurora4/test_clean_wv1/443/443c0214.pcm 165 | ../../data/aurora4/test_clean_wv1/444/444c0201.pcm 166 | ../../data/aurora4/test_clean_wv1/444/444c0202.pcm 167 | ../../data/aurora4/test_clean_wv1/444/444c0203.pcm 168 | ../../data/aurora4/test_clean_wv1/444/444c0204.pcm 169 | ../../data/aurora4/test_clean_wv1/444/444c0205.pcm 170 | ../../data/aurora4/test_clean_wv1/444/444c0206.pcm 171 | ../../data/aurora4/test_clean_wv1/444/444c0207.pcm 172 | ../../data/aurora4/test_clean_wv1/444/444c0208.pcm 173 | ../../data/aurora4/test_clean_wv1/444/444c0209.pcm 174 | ../../data/aurora4/test_clean_wv1/444/444c020a.pcm 175 | ../../data/aurora4/test_clean_wv1/444/444c020b.pcm 176 | ../../data/aurora4/test_clean_wv1/444/444c020c.pcm 177 | ../../data/aurora4/test_clean_wv1/444/444c020d.pcm 178 | ../../data/aurora4/test_clean_wv1/444/444c020e.pcm 179 | ../../data/aurora4/test_clean_wv1/444/444c020f.pcm 180 | ../../data/aurora4/test_clean_wv1/444/444c020g.pcm 181 | ../../data/aurora4/test_clean_wv1/444/444c020h.pcm 182 | ../../data/aurora4/test_clean_wv1/444/444c020i.pcm 183 | ../../data/aurora4/test_clean_wv1/444/444c020j.pcm 184 | ../../data/aurora4/test_clean_wv1/444/444c020k.pcm 185 | ../../data/aurora4/test_clean_wv1/444/444c020l.pcm 186 | ../../data/aurora4/test_clean_wv1/444/444c020m.pcm 187 | ../../data/aurora4/test_clean_wv1/444/444c020n.pcm 188 | ../../data/aurora4/test_clean_wv1/444/444c020o.pcm 189 | ../../data/aurora4/test_clean_wv1/444/444c020p.pcm 190 | ../../data/aurora4/test_clean_wv1/444/444c020q.pcm 191 | ../../data/aurora4/test_clean_wv1/444/444c020r.pcm 192 | ../../data/aurora4/test_clean_wv1/444/444c020s.pcm 193 | ../../data/aurora4/test_clean_wv1/444/444c020t.pcm 194 | ../../data/aurora4/test_clean_wv1/444/444c020u.pcm 195 | ../../data/aurora4/test_clean_wv1/444/444c020v.pcm 196 | ../../data/aurora4/test_clean_wv1/444/444c020w.pcm 197 | ../../data/aurora4/test_clean_wv1/444/444c020x.pcm 198 | ../../data/aurora4/test_clean_wv1/444/444c020y.pcm 199 | ../../data/aurora4/test_clean_wv1/444/444c020z.pcm 200 | ../../data/aurora4/test_clean_wv1/444/444c0210.pcm 201 | ../../data/aurora4/test_clean_wv1/444/444c0211.pcm 202 | ../../data/aurora4/test_clean_wv1/444/444c0212.pcm 203 | ../../data/aurora4/test_clean_wv1/444/444c0213.pcm 204 | ../../data/aurora4/test_clean_wv1/444/444c0214.pcm 205 | ../../data/aurora4/test_clean_wv1/444/444c0215.pcm 206 | ../../data/aurora4/test_clean_wv1/445/445c0201.pcm 207 | ../../data/aurora4/test_clean_wv1/445/445c0202.pcm 208 | ../../data/aurora4/test_clean_wv1/445/445c0203.pcm 209 | ../../data/aurora4/test_clean_wv1/445/445c0204.pcm 210 | ../../data/aurora4/test_clean_wv1/445/445c0205.pcm 211 | ../../data/aurora4/test_clean_wv1/445/445c0206.pcm 212 | ../../data/aurora4/test_clean_wv1/445/445c0207.pcm 213 | ../../data/aurora4/test_clean_wv1/445/445c0208.pcm 214 | ../../data/aurora4/test_clean_wv1/445/445c0209.pcm 215 | ../../data/aurora4/test_clean_wv1/445/445c020a.pcm 216 | ../../data/aurora4/test_clean_wv1/445/445c020b.pcm 217 | ../../data/aurora4/test_clean_wv1/445/445c020c.pcm 218 | ../../data/aurora4/test_clean_wv1/445/445c020d.pcm 219 | ../../data/aurora4/test_clean_wv1/445/445c020e.pcm 220 | ../../data/aurora4/test_clean_wv1/445/445c020f.pcm 221 | ../../data/aurora4/test_clean_wv1/445/445c020g.pcm 222 | ../../data/aurora4/test_clean_wv1/445/445c020h.pcm 223 | ../../data/aurora4/test_clean_wv1/445/445c020i.pcm 224 | ../../data/aurora4/test_clean_wv1/445/445c020j.pcm 225 | ../../data/aurora4/test_clean_wv1/445/445c020k.pcm 226 | ../../data/aurora4/test_clean_wv1/445/445c020l.pcm 227 | ../../data/aurora4/test_clean_wv1/445/445c020m.pcm 228 | ../../data/aurora4/test_clean_wv1/445/445c020n.pcm 229 | ../../data/aurora4/test_clean_wv1/445/445c020o.pcm 230 | ../../data/aurora4/test_clean_wv1/445/445c020p.pcm 231 | ../../data/aurora4/test_clean_wv1/445/445c020q.pcm 232 | ../../data/aurora4/test_clean_wv1/445/445c020r.pcm 233 | ../../data/aurora4/test_clean_wv1/445/445c020s.pcm 234 | ../../data/aurora4/test_clean_wv1/445/445c020t.pcm 235 | ../../data/aurora4/test_clean_wv1/445/445c020u.pcm 236 | ../../data/aurora4/test_clean_wv1/445/445c020v.pcm 237 | ../../data/aurora4/test_clean_wv1/445/445c020w.pcm 238 | ../../data/aurora4/test_clean_wv1/445/445c020x.pcm 239 | ../../data/aurora4/test_clean_wv1/445/445c020y.pcm 240 | ../../data/aurora4/test_clean_wv1/445/445c020z.pcm 241 | ../../data/aurora4/test_clean_wv1/445/445c0210.pcm 242 | ../../data/aurora4/test_clean_wv1/445/445c0211.pcm 243 | ../../data/aurora4/test_clean_wv1/445/445c0212.pcm 244 | ../../data/aurora4/test_clean_wv1/445/445c0213.pcm 245 | ../../data/aurora4/test_clean_wv1/445/445c0214.pcm 246 | ../../data/aurora4/test_clean_wv1/445/445c0215.pcm 247 | ../../data/aurora4/test_clean_wv1/445/445c0216.pcm 248 | ../../data/aurora4/test_clean_wv1/446/446c0201.pcm 249 | ../../data/aurora4/test_clean_wv1/446/446c0202.pcm 250 | ../../data/aurora4/test_clean_wv1/446/446c0203.pcm 251 | ../../data/aurora4/test_clean_wv1/446/446c0204.pcm 252 | ../../data/aurora4/test_clean_wv1/446/446c0205.pcm 253 | ../../data/aurora4/test_clean_wv1/446/446c0206.pcm 254 | ../../data/aurora4/test_clean_wv1/446/446c0207.pcm 255 | ../../data/aurora4/test_clean_wv1/446/446c0208.pcm 256 | ../../data/aurora4/test_clean_wv1/446/446c0209.pcm 257 | ../../data/aurora4/test_clean_wv1/446/446c020a.pcm 258 | ../../data/aurora4/test_clean_wv1/446/446c020b.pcm 259 | ../../data/aurora4/test_clean_wv1/446/446c020c.pcm 260 | ../../data/aurora4/test_clean_wv1/446/446c020d.pcm 261 | ../../data/aurora4/test_clean_wv1/446/446c020e.pcm 262 | ../../data/aurora4/test_clean_wv1/446/446c020f.pcm 263 | ../../data/aurora4/test_clean_wv1/446/446c020g.pcm 264 | ../../data/aurora4/test_clean_wv1/446/446c020h.pcm 265 | ../../data/aurora4/test_clean_wv1/446/446c020i.pcm 266 | ../../data/aurora4/test_clean_wv1/446/446c020j.pcm 267 | ../../data/aurora4/test_clean_wv1/446/446c020k.pcm 268 | ../../data/aurora4/test_clean_wv1/446/446c020l.pcm 269 | ../../data/aurora4/test_clean_wv1/446/446c020m.pcm 270 | ../../data/aurora4/test_clean_wv1/446/446c020n.pcm 271 | ../../data/aurora4/test_clean_wv1/446/446c020o.pcm 272 | ../../data/aurora4/test_clean_wv1/446/446c020p.pcm 273 | ../../data/aurora4/test_clean_wv1/446/446c020q.pcm 274 | ../../data/aurora4/test_clean_wv1/446/446c020r.pcm 275 | ../../data/aurora4/test_clean_wv1/446/446c020s.pcm 276 | ../../data/aurora4/test_clean_wv1/446/446c020t.pcm 277 | ../../data/aurora4/test_clean_wv1/446/446c020u.pcm 278 | ../../data/aurora4/test_clean_wv1/446/446c020v.pcm 279 | ../../data/aurora4/test_clean_wv1/446/446c020w.pcm 280 | ../../data/aurora4/test_clean_wv1/446/446c020x.pcm 281 | ../../data/aurora4/test_clean_wv1/446/446c020y.pcm 282 | ../../data/aurora4/test_clean_wv1/446/446c020z.pcm 283 | ../../data/aurora4/test_clean_wv1/446/446c0210.pcm 284 | ../../data/aurora4/test_clean_wv1/446/446c0211.pcm 285 | ../../data/aurora4/test_clean_wv1/446/446c0212.pcm 286 | ../../data/aurora4/test_clean_wv1/446/446c0213.pcm 287 | ../../data/aurora4/test_clean_wv1/446/446c0214.pcm 288 | ../../data/aurora4/test_clean_wv1/447/447c0201.pcm 289 | ../../data/aurora4/test_clean_wv1/447/447c0202.pcm 290 | ../../data/aurora4/test_clean_wv1/447/447c0203.pcm 291 | ../../data/aurora4/test_clean_wv1/447/447c0204.pcm 292 | ../../data/aurora4/test_clean_wv1/447/447c0205.pcm 293 | ../../data/aurora4/test_clean_wv1/447/447c0206.pcm 294 | ../../data/aurora4/test_clean_wv1/447/447c0207.pcm 295 | ../../data/aurora4/test_clean_wv1/447/447c0208.pcm 296 | ../../data/aurora4/test_clean_wv1/447/447c0209.pcm 297 | ../../data/aurora4/test_clean_wv1/447/447c020a.pcm 298 | ../../data/aurora4/test_clean_wv1/447/447c020b.pcm 299 | ../../data/aurora4/test_clean_wv1/447/447c020c.pcm 300 | ../../data/aurora4/test_clean_wv1/447/447c020d.pcm 301 | ../../data/aurora4/test_clean_wv1/447/447c020e.pcm 302 | ../../data/aurora4/test_clean_wv1/447/447c020f.pcm 303 | ../../data/aurora4/test_clean_wv1/447/447c020g.pcm 304 | ../../data/aurora4/test_clean_wv1/447/447c020h.pcm 305 | ../../data/aurora4/test_clean_wv1/447/447c020i.pcm 306 | ../../data/aurora4/test_clean_wv1/447/447c020j.pcm 307 | ../../data/aurora4/test_clean_wv1/447/447c020k.pcm 308 | ../../data/aurora4/test_clean_wv1/447/447c020l.pcm 309 | ../../data/aurora4/test_clean_wv1/447/447c020m.pcm 310 | ../../data/aurora4/test_clean_wv1/447/447c020n.pcm 311 | ../../data/aurora4/test_clean_wv1/447/447c020o.pcm 312 | ../../data/aurora4/test_clean_wv1/447/447c020p.pcm 313 | ../../data/aurora4/test_clean_wv1/447/447c020q.pcm 314 | ../../data/aurora4/test_clean_wv1/447/447c020r.pcm 315 | ../../data/aurora4/test_clean_wv1/447/447c020s.pcm 316 | ../../data/aurora4/test_clean_wv1/447/447c020t.pcm 317 | ../../data/aurora4/test_clean_wv1/447/447c020u.pcm 318 | ../../data/aurora4/test_clean_wv1/447/447c020v.pcm 319 | ../../data/aurora4/test_clean_wv1/447/447c020w.pcm 320 | ../../data/aurora4/test_clean_wv1/447/447c020x.pcm 321 | ../../data/aurora4/test_clean_wv1/447/447c020y.pcm 322 | ../../data/aurora4/test_clean_wv1/447/447c020z.pcm 323 | ../../data/aurora4/test_clean_wv1/447/447c0210.pcm 324 | ../../data/aurora4/test_clean_wv1/447/447c0211.pcm 325 | ../../data/aurora4/test_clean_wv1/447/447c0212.pcm 326 | ../../data/aurora4/test_clean_wv1/447/447c0213.pcm 327 | ../../data/aurora4/test_clean_wv1/447/447c0214.pcm 328 | ../../data/aurora4/test_clean_wv1/447/447c0215.pcm 329 | ../../data/aurora4/test_clean_wv1/447/447c0216.pcm 330 | ../../data/aurora4/test_clean_wv1/447/447c0217.pcm 331 | -------------------------------------------------------------------------------- /egs/case1/benchmark/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | { time ./benchmark.sh ; } &> benchmark.log 4 | -------------------------------------------------------------------------------- /egs/case1/benchmark/test.wer: -------------------------------------------------------------------------------- 1 | %WER 14.46 [ 774 / 5353, 76 ins, 144 del, 554 sub ] 2 | %SER 67.88 [ 224 / 330 ] 3 | Scored 330 sentences, 0 not present in hyp. 4 | -------------------------------------------------------------------------------- /egs/case2/conf/actors.ini: -------------------------------------------------------------------------------- 1 | ; Interfaces 2 | [m_command_line] 3 | actor_type = CommandLineInterface 4 | 5 | ; Readers 6 | [m_file_list_reader] 7 | actor_type = FileListReader 8 | file_list = pcm.list 9 | 10 | [m_pcm_reader] 11 | actor_type = PCMReader 12 | samples_per_chunk = 2000 13 | bits_per_sample = 16 14 | 15 | ; Feature extraction / transformation modules 16 | [m_mfcc_extractor] 17 | actor_type = ComputeMFCCFeats 18 | use_energy = false 19 | vtln_warp_local = 1 20 | 21 | [m_cmvn_applier] 22 | actor_type = ApplyCMVN 23 | norm_vars = false 24 | context_size = 200 25 | 26 | [m_delta_adder] 27 | actor_type = AddDeltas 28 | 29 | ; Decoders 30 | [m_gmm_decoder_wsj] 31 | actor_type = GMMDecodeFasterOnline 32 | max_active = 7000 33 | beam = 13.0 34 | acoustic_scale = 0.083333 35 | allow_partial = true 36 | model_rxfilename = ../models/wsj/final.mdl 37 | fst_rxfilename = ../models/wsj/HCLG.fst 38 | word_syms_filename = ../models/wsj/words.txt 39 | words_wspecifier = ark,t:wsj.tra 40 | alignment_wspecifier = 41 | lattice_wspecifier = 42 | 43 | [m_gmm_decoder_hub4] 44 | actor_type = GMMDecodeFasterOnline 45 | max_active = 7000 46 | beam = 13.0 47 | acoustic_scale = 0.083333 48 | allow_partial = true 49 | model_rxfilename = ../models/hub4/final.mdl 50 | fst_rxfilename = ../models/hub4/HCLG.fst 51 | word_syms_filename = ../models/hub4/words.txt 52 | words_wspecifier = ark,t:hub4.tra 53 | alignment_wspecifier = 54 | lattice_wspecifier = 55 | 56 | [m_gmm_decoder_icsi] 57 | actor_type = GMMDecodeFasterOnline 58 | max_active = 7000 59 | beam = 13.0 60 | acoustic_scale = 0.083333 61 | allow_partial = true 62 | model_rxfilename = ../models/icsi/final.mdl 63 | fst_rxfilename = ../models/icsi/HCLG.fst 64 | word_syms_filename = ../models/icsi/words.txt 65 | words_wspecifier = ark,t:icsi.tra 66 | alignment_wspecifier = 67 | lattice_wspecifier = 68 | -------------------------------------------------------------------------------- /egs/case2/conf/graph.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | m_file_list_reader -> m_pcm_reader -> m_mfcc_extractor -> m_cmvn_applier -> m_delta_adder; 3 | m_delta_adder -> m_gmm_decoder_wsj; 4 | m_delta_adder -> m_gmm_decoder_hub4; 5 | m_delta_adder -> m_gmm_decoder_icsi; 6 | } 7 | -------------------------------------------------------------------------------- /egs/case2/int2sym.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Copyright 2010-2011 Microsoft Corporation 3 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 | # KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 12 | # WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 13 | # MERCHANTABLITY OR NON-INFRINGEMENT. 14 | # See the Apache 2 License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | $ignore_noninteger = 0; 19 | $ignore_first_field = 0; 20 | $field = -1; 21 | for($x = 0; $x < 2; $x++) { 22 | if($ARGV[0] eq "--ignore-noninteger") { $ignore_noninteger = 1; shift @ARGV; } 23 | if($ARGV[0] eq "--ignore-first-field") { $ignore_first_field = 1; shift @ARGV; } 24 | if($ARGV[0] eq "--field") { 25 | shift @ARGV; $field = $ARGV[0]+0; shift @ARGV; 26 | if ($field < 1) { die "Bad argument to --field option: $field"; } 27 | } 28 | } 29 | 30 | if ($ignore_first_field && $field > 0) { die "Incompatible options ignore-first-field and field"; } 31 | $zfield = $field-1; # Change to zero-based indexing. 32 | 33 | $symtab = shift @ARGV; 34 | if(!defined $symtab) { 35 | die "Usage: sym2int.pl symtab [input] > output\n"; 36 | } 37 | open(F, "<$symtab") || die "Error opening symbol table file $symtab"; 38 | while() { 39 | @A = split(" ", $_); 40 | @A == 2 || die "bad line in symbol table file: $_"; 41 | $int2sym{$A[1]} = $A[0]; 42 | } 43 | 44 | sub int2sym { 45 | my $a = shift @_; 46 | my $pos = shift @_; 47 | if($a !~ m:^\d+$:) { # not all digits.. 48 | if($ignore_noninteger) { 49 | print $a . " "; 50 | next; 51 | } else { 52 | if($pos == 0) { 53 | die "int2sym.pl: found noninteger token $a (try --ignore-first-field)\n"; 54 | } else { 55 | die "int2sym.pl: found noninteger token $a (try --ignore-noninteger if valid input)\n"; 56 | } 57 | } 58 | } 59 | $s = $int2sym{$a}; 60 | if(!defined ($s)) { 61 | die "int2sym.pl: integer $a not in symbol table $symtab."; 62 | } 63 | return $s; 64 | } 65 | 66 | $error = 0; 67 | while(<>) { 68 | @A = split(" ", $_); 69 | if($ignore_first_field) { 70 | $key = shift @A; 71 | print $key . " "; 72 | } 73 | if ($field != -1) { 74 | if ($zfield <= $#A && $zfield >= 0) { 75 | $a = $A[$zfield]; 76 | $A[$zfield] = int2sym($a, $zfield); 77 | } 78 | print join(" ", @A); 79 | } else { 80 | for ($pos = 0; $pos <= $#A; $pos++) { 81 | $a = $A[$pos]; 82 | $s = int2sym($a, $pos); 83 | print $s . " "; 84 | } 85 | } 86 | print "\n"; 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /egs/case2/pcm.list: -------------------------------------------------------------------------------- 1 | ../data/sample/440c0401.pcm -------------------------------------------------------------------------------- /egs/case2/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BARISTAROOT=../.. 4 | export PATH=$BARISTAROOT/bin:$PATH 5 | 6 | wsjdir=../models/wsj 7 | hub4dir=../models/hub4 8 | icsidir=../models/icsi 9 | 10 | barista conf/actors.ini conf/graph.dot &> log 11 | 12 | perl int2sym.pl --ignore-first-field $wsjdir/words.txt wsj.tra > wsj.hyp 13 | perl int2sym.pl --ignore-first-field $hub4dir/words.txt hub4.tra > hub4.hyp 14 | perl int2sym.pl --ignore-first-field $icsidir/words.txt icsi.tra > icsi.hyp 15 | -------------------------------------------------------------------------------- /egs/data/README.md: -------------------------------------------------------------------------------- 1 | Create a new folder for each dataset, e.g. sample, aurora4, etc. -------------------------------------------------------------------------------- /egs/data/sample/440c0401.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usc-sail/barista/e035208848a5d0d2f270d1352e5ffcce6f74cc71/egs/data/sample/440c0401.pcm -------------------------------------------------------------------------------- /egs/data/sample/440c0401.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usc-sail/barista/e035208848a5d0d2f270d1352e5ffcce6f74cc71/egs/data/sample/440c0401.wav -------------------------------------------------------------------------------- /egs/data/sample/README.md: -------------------------------------------------------------------------------- 1 | Small set of audio files for testing. 2 | -------------------------------------------------------------------------------- /egs/demo/README.md: -------------------------------------------------------------------------------- 1 | This is a demo setup for running the dummy filter module. -------------------------------------------------------------------------------- /egs/demo/conf/actors.ini: -------------------------------------------------------------------------------- 1 | ; Readers 2 | [file_list_reader] 3 | actor_type = FileListReader 4 | file_list = pcm.list 5 | 6 | [pcm_reader] 7 | actor_type = PCMReader 8 | samples_per_chunk = 2000 9 | bits_per_sample = 16 10 | 11 | ; Writers 12 | [pcm_writer] 13 | actor_type = VectorWriter 14 | sink_file = pcm.txt 15 | 16 | [filter1_writer] 17 | actor_type = VectorWriter 18 | sink_file = filter1.txt 19 | 20 | [filter2_writer] 21 | actor_type = VectorWriter 22 | sink_file = filter2.txt 23 | 24 | ; Filters 25 | [filter1] 26 | actor_type = Filter 27 | weight = 2.0 28 | 29 | [filter2] 30 | actor_type = Filter 31 | weight = 3.0 -------------------------------------------------------------------------------- /egs/demo/conf/graph.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | file_list_reader -> pcm_reader -> pcm_writer; 3 | pcm_reader -> filter1 -> filter1_writer; 4 | pcm_reader -> filter2 -> filter2_writer; 5 | } 6 | -------------------------------------------------------------------------------- /egs/demo/pcm.list: -------------------------------------------------------------------------------- 1 | ../data/sample/440c0401.pcm 2 | -------------------------------------------------------------------------------- /egs/demo/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BARISTAROOT=../.. 4 | export PATH=$BARISTAROOT/bin:$PATH 5 | 6 | barista conf/actors.ini conf/graph.dot &> log 7 | -------------------------------------------------------------------------------- /egs/feat/README.md: -------------------------------------------------------------------------------- 1 | Example feature extraction setup. -------------------------------------------------------------------------------- /egs/feat/conf/actors.ini: -------------------------------------------------------------------------------- 1 | ; Readers 2 | [m_file_list_reader] 3 | actor_type = FileListReader 4 | file_list = pcm.list 5 | 6 | [m_pcm_reader] 7 | actor_type = PCMReader 8 | samples_per_chunk = 2000 9 | bits_per_sample = 16 10 | 11 | ; Writers 12 | [m_pcm_writer] 13 | actor_type = VectorWriter 14 | sink_file = pcm.txt 15 | 16 | [m_mfcc_writer] 17 | actor_type = MatrixWriter 18 | sink_file = mfcc.txt 19 | 20 | [m_cmvn_writer] 21 | actor_type = MatrixWriter 22 | sink_file = cmvn.txt 23 | 24 | [m_delta_writer] 25 | actor_type = MatrixWriter 26 | sink_file = delta.txt 27 | 28 | ; Feature extraction / transformation modules 29 | [m_mfcc_extractor] 30 | actor_type = ComputeMFCCFeats 31 | use_energy = false 32 | vtln_warp_local = 1 33 | 34 | [m_cmvn_applier] 35 | actor_type = ApplyCMVN 36 | norm_vars = false 37 | context_size = 1000 38 | 39 | [m_delta_adder] 40 | actor_type = AddDeltas 41 | -------------------------------------------------------------------------------- /egs/feat/conf/graph.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | m_file_list_reader -> m_pcm_reader -> m_mfcc_extractor -> m_cmvn_applier -> m_delta_adder; 3 | m_pcm_reader -> m_pcm_writer; 4 | m_mfcc_extractor -> m_mfcc_writer; 5 | m_cmvn_applier -> m_cmvn_writer; 6 | m_delta_adder -> m_delta_writer; 7 | } 8 | -------------------------------------------------------------------------------- /egs/feat/log: -------------------------------------------------------------------------------- 1 | barista conf/actors.ini conf/graph.dot 2 | ++ m_file_list_reader: file list: pcm.list 3 | ++ m_pcm_writer: sink file: pcm.txt 4 | ++ m_mfcc_writer: sink file: mfcc.txt 5 | ++ m_cmvn_writer: sink file: cmvn.txt 6 | ++ m_delta_writer: sink file: delta.txt 7 | ++ m_file_list_reader: Finished reading file list: pcm.list 8 | ++ Done 9 | -------------------------------------------------------------------------------- /egs/feat/pcm.list: -------------------------------------------------------------------------------- 1 | ../data/sample/440c0401.pcm 2 | -------------------------------------------------------------------------------- /egs/feat/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BARISTAROOT=../.. 4 | export PATH=$BARISTAROOT/bin:$PATH 5 | 6 | barista conf/actors.ini conf/graph.dot &> log 7 | -------------------------------------------------------------------------------- /egs/live/README.md: -------------------------------------------------------------------------------- 1 | Example setup for live real time speech recognition. -------------------------------------------------------------------------------- /egs/live/conf/actors.ini: -------------------------------------------------------------------------------- 1 | ; Interfaces 2 | [m_command_line] 3 | actor_type = CommandLineInterface 4 | 5 | ; Readers 6 | [m_portaudio_reader] 7 | actor_type = PaReader 8 | 9 | ; Feature extraction / transformation modules 10 | [m_mfcc_extractor] 11 | actor_type = ComputeMFCCFeats 12 | use_energy = false 13 | vtln_warp_local = 1 14 | 15 | [m_cmvn_applier] 16 | actor_type = ApplyCMVN 17 | norm_vars = false 18 | context_size = 1000 19 | 20 | [m_delta_adder] 21 | actor_type = AddDeltas 22 | 23 | ; Decoders 24 | [m_gmm_decoder] 25 | actor_type = GMMDecodeFasterOnline 26 | max_active = 7000 27 | beam = 13.0 28 | acoustic_scale = 0.083333 29 | allow_partial = true 30 | model_rxfilename = ../models/wsj/final.mdl 31 | fst_rxfilename = ../models/wsj/HCLG.fst 32 | word_syms_filename = ../models/wsj/words.txt 33 | words_wspecifier = ark,t:| ./int2sym.pl --ignore-first-field ../models/wsj/words.txt > live.hyp 34 | alignment_wspecifier = 35 | lattice_wspecifier = 36 | -------------------------------------------------------------------------------- /egs/live/conf/graph.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | m_command_line -> m_portaudio_reader -> m_mfcc_extractor -> m_cmvn_applier -> m_delta_adder -> m_gmm_decoder; 3 | } 4 | -------------------------------------------------------------------------------- /egs/live/int2sym.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Copyright 2010-2011 Microsoft Corporation 3 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 | # KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 12 | # WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 13 | # MERCHANTABLITY OR NON-INFRINGEMENT. 14 | # See the Apache 2 License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | $ignore_noninteger = 0; 19 | $ignore_first_field = 0; 20 | $field = -1; 21 | for($x = 0; $x < 2; $x++) { 22 | if($ARGV[0] eq "--ignore-noninteger") { $ignore_noninteger = 1; shift @ARGV; } 23 | if($ARGV[0] eq "--ignore-first-field") { $ignore_first_field = 1; shift @ARGV; } 24 | if($ARGV[0] eq "--field") { 25 | shift @ARGV; $field = $ARGV[0]+0; shift @ARGV; 26 | if ($field < 1) { die "Bad argument to --field option: $field"; } 27 | } 28 | } 29 | 30 | if ($ignore_first_field && $field > 0) { die "Incompatible options ignore-first-field and field"; } 31 | $zfield = $field-1; # Change to zero-based indexing. 32 | 33 | $symtab = shift @ARGV; 34 | if(!defined $symtab) { 35 | die "Usage: sym2int.pl symtab [input] > output\n"; 36 | } 37 | open(F, "<$symtab") || die "Error opening symbol table file $symtab"; 38 | while() { 39 | @A = split(" ", $_); 40 | @A == 2 || die "bad line in symbol table file: $_"; 41 | $int2sym{$A[1]} = $A[0]; 42 | } 43 | 44 | sub int2sym { 45 | my $a = shift @_; 46 | my $pos = shift @_; 47 | if($a !~ m:^\d+$:) { # not all digits.. 48 | if($ignore_noninteger) { 49 | print $a . " "; 50 | next; 51 | } else { 52 | if($pos == 0) { 53 | die "int2sym.pl: found noninteger token $a (try --ignore-first-field)\n"; 54 | } else { 55 | die "int2sym.pl: found noninteger token $a (try --ignore-noninteger if valid input)\n"; 56 | } 57 | } 58 | } 59 | $s = $int2sym{$a}; 60 | if(!defined ($s)) { 61 | die "int2sym.pl: integer $a not in symbol table $symtab."; 62 | } 63 | return $s; 64 | } 65 | 66 | $error = 0; 67 | while(<>) { 68 | @A = split(" ", $_); 69 | if($ignore_first_field) { 70 | $key = shift @A; 71 | print $key . " "; 72 | } 73 | if ($field != -1) { 74 | if ($zfield <= $#A && $zfield >= 0) { 75 | $a = $A[$zfield]; 76 | $A[$zfield] = int2sym($a, $zfield); 77 | } 78 | print join(" ", @A); 79 | } else { 80 | for ($pos = 0; $pos <= $#A; $pos++) { 81 | $a = $A[$pos]; 82 | $s = int2sym($a, $pos); 83 | print $s . " "; 84 | } 85 | } 86 | print "\n"; 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /egs/live/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BARISTAROOT=../.. 4 | export PATH=$BARISTAROOT/bin:$PATH 5 | 6 | barista conf/actors.ini conf/graph.dot 7 | -------------------------------------------------------------------------------- /egs/models/README.md: -------------------------------------------------------------------------------- 1 | Create a new folder for each set of models, e.g. wsj, hub4, icsi, etc. -------------------------------------------------------------------------------- /src/base/common.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_COMMON_H_ 2 | #define BARISTA_COMMON_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "base/kaldi-types.h" 10 | 11 | #include "cppa/cppa.hpp" 12 | 13 | #include 14 | 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/base/kaldi-type-info.h: -------------------------------------------------------------------------------- 1 | #include "cppa/cppa.hpp" 2 | 3 | #include "base/kaldi-types.h" 4 | #include "matrix/kaldi-vector.h" 5 | #include "matrix/kaldi-matrix.h" 6 | 7 | using namespace cppa; 8 | 9 | namespace kaldi { 10 | template 11 | bool operator==(const Vector& lhs, const Vector& rhs) { 12 | if (lhs.Dim() != rhs.Dim()) 13 | return false; 14 | 15 | for (MatrixIndexT i = 0; i < lhs.Dim(); i++) { 16 | if (lhs(i) != rhs(i)) 17 | return false; 18 | } 19 | 20 | return true; 21 | } 22 | 23 | template 24 | bool operator==(const Matrix& lhs, const Matrix& rhs) { 25 | if (lhs.NumRows() != rhs.NumRows() || lhs.NumCols() != rhs.NumCols()) 26 | return false; 27 | 28 | for (MatrixIndexT i = 0; i < lhs.NumRows(); i++) { 29 | for (MatrixIndexT j = 0; j < lhs.NumCols(); j++) { 30 | if (lhs(i, j) != rhs(i, j)) 31 | return false; 32 | } 33 | } 34 | 35 | return true; 36 | } 37 | 38 | } 39 | 40 | // abstract_uniform_type_info implements all functions of uniform_type_info 41 | // except for serialize() and deserialize() if the template parameter T: 42 | // - does have a default constructor 43 | // - does have a copy constructor 44 | // - does provide operator== 45 | 46 | template 47 | class VectorTypeInfo : public util::abstract_uniform_type_info > { 48 | 49 | protected: 50 | 51 | void serialize(const void* ptr, serializer* sink) const { 52 | // ptr is guaranteed to be a pointer of type Vector 53 | auto vector_ptr = reinterpret_cast*>(ptr); 54 | sink->write_value(static_cast(vector_ptr->Dim())); 55 | sink->write_raw(vector_ptr->SizeInBytes(), vector_ptr->Data()); 56 | } 57 | 58 | void deserialize(void* ptr, deserializer* source) const { 59 | // ptr is guaranteed to be a pointer of type Vector 60 | auto vector_ptr = reinterpret_cast*>(ptr); 61 | // vector_ptr->clear(); 62 | auto size = source->read(); 63 | vector_ptr->Resize(size, kaldi::kUndefined); 64 | source->read_raw(vector_ptr->SizeInBytes(), vector_ptr->Data()); 65 | } 66 | 67 | }; 68 | 69 | 70 | template 71 | class MatrixTypeInfo : public util::abstract_uniform_type_info > { 72 | 73 | protected: 74 | 75 | void serialize(const void* ptr, serializer* sink) const { 76 | // ptr is guaranteed to be a pointer of type Matrix 77 | auto matrix_ptr = reinterpret_cast*>(ptr); 78 | sink->write_value(static_cast(matrix_ptr->NumRows())); 79 | sink->write_value(static_cast(matrix_ptr->NumCols())); 80 | sink->write_raw(matrix_ptr->SizeInBytes(), matrix_ptr->Data()); 81 | } 82 | 83 | void deserialize(void* ptr, deserializer* source) const { 84 | // ptr is guaranteed to be a pointer of type Matrix 85 | auto matrix_ptr = reinterpret_cast*>(ptr); 86 | // matrix_ptr->clear(); 87 | auto num_rows = source->read(); 88 | auto num_cols = source->read(); 89 | matrix_ptr->Resize(num_rows, num_cols, kaldi::kUndefined); 90 | source->read_raw(matrix_ptr->SizeInBytes(), matrix_ptr->Data()); 91 | } 92 | 93 | }; 94 | 95 | // Announces kaldi types to the libcppa type system. 96 | bool AnnounceKaldiTypes() { 97 | announce(typeid(kaldi::Vector), 98 | std::unique_ptr{new VectorTypeInfo}); 99 | announce(typeid(kaldi::Matrix), 100 | std::unique_ptr{new MatrixTypeInfo}); 101 | return true; 102 | } -------------------------------------------------------------------------------- /src/base/module-base.cc: -------------------------------------------------------------------------------- 1 | #include "module-base.h" 2 | 3 | using namespace std; 4 | using namespace cppa; 5 | 6 | behavior ModuleBase::Config(){ 7 | return ( 8 | on(atom("JOIN"), arg_match) >> [=](const group_ptr& gptr) { 9 | self->join(gptr); 10 | return atom("JOINED"); 11 | }, 12 | on(atom("LINK"), arg_match) >> [=](const actor_ptr& other) { 13 | self->link_to(other); 14 | return atom("LINKED"); 15 | }, 16 | on(atom("QUIT")) >> [=]() { 17 | self->quit(exit_reason::user_shutdown); 18 | }, 19 | on(atom("RUN")) >> [=]() { 20 | become(running_state); 21 | } 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /src/base/module-base.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_MODULE_BASE_H_ 2 | #define BARISTA_MODULE_BASE_H_ 3 | 4 | #include "common.h" 5 | 6 | class ModuleBase : public cppa::sb_actor { 7 | public: 8 | std::string name; 9 | cppa::group_ptr subscribers; 10 | 11 | cppa::behavior running_state; 12 | cppa::behavior config_state; 13 | cppa::behavior& init_state = config_state; 14 | 15 | ModuleBase(const std::string& name_, const cppa::group_ptr& subscribers_) : 16 | name(name_), subscribers(subscribers_) { 17 | config_state = Config(); 18 | } 19 | 20 | cppa::behavior Config(); 21 | 22 | private: 23 | friend class cppa::sb_actor; 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/bin/barista.cc: -------------------------------------------------------------------------------- 1 | #include "base/kaldi-type-info.h" 2 | #include "io/vector-writer.h" 3 | #include "io/matrix-writer.h" 4 | #include "io/command-line-interface.h" 5 | #include "io/file-list-reader.h" 6 | #include "io/portaudio-reader.h" 7 | #include "io/pcm-reader.h" 8 | #include "feat/compute-mfcc-feats.h" 9 | #include "feat/apply-cmvn.h" 10 | #include "feat/add-deltas.h" 11 | #include "feat/filter.h" 12 | #include "gmm/gmm-decode-faster-online.h" 13 | #include "util/common-utils.h" 14 | #include "graphviz/gvc.h" 15 | #include "boost/property_tree/ini_parser.hpp" 16 | 17 | using namespace std; 18 | using namespace cppa; 19 | using namespace kaldi; 20 | 21 | using boost::property_tree::ptree; 22 | using boost::property_tree::ini_parser::read_ini; 23 | 24 | typedef vector edge_list_type; 25 | typedef pair vertex_type; 26 | typedef vector adjacency_list_type; 27 | 28 | // Reads a graph in DOT (Graphviz) format. 29 | bool ReadGraph(string filename, adjacency_list_type* graph) { 30 | FILE* fp; 31 | fp = fopen(filename.c_str(), "r"); 32 | if (fp == NULL) { 33 | cerr << "Could not open graph file: " << filename << endl; 34 | return false; 35 | } 36 | // Read the graph and construct an adjacency list 37 | Agraph_t* g = agread(fp, 0); 38 | fclose(fp); 39 | for (Agnode_t* n = agfstnode(g); n; n = agnxtnode(g, n)) { 40 | edge_list_type edges; 41 | for (Agedge_t* e = agfstout(g, n); e; e = agnxtout(g, e)) { 42 | edges.push_back(agnameof(aghead(e))); 43 | } 44 | graph->push_back(make_pair(agnameof(n), edges)); 45 | } 46 | agclose(g); 47 | return true; 48 | } 49 | 50 | // Spawns actors 51 | bool SpawnActors(adjacency_list_type& graph, ptree& config, 52 | map* actor_map, 53 | map* subscribers_map) { 54 | 55 | // Spawn an actor for each node in the graph 56 | for (int u = 0; u < graph.size(); u++) { 57 | string actor_name = graph[u].first; 58 | string actor_type = config.get(actor_name + ".actor_type"); 59 | // aout << actor_name << " : " << actor_type << endl; 60 | 61 | // Create a subscribers group for the actor to be spawned 62 | auto subscribers = group::anonymous(); 63 | subscribers_map->insert(make_pair(actor_name, subscribers)); 64 | 65 | // Spawn the actor 66 | if (actor_type == "FileListReader") { 67 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 68 | } else if (actor_type == "CommandLineInterface") { 69 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 70 | } else if (actor_type == "PaReader") { 71 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 72 | } else if (actor_type == "PCMReader") { 73 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 74 | } else if (actor_type == "ComputeMFCCFeats") { 75 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 76 | } else if (actor_type == "ApplyCMVN") { 77 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 78 | } else if (actor_type == "AddDeltas") { 79 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 80 | } else if (actor_type == "Filter") { 81 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 82 | } else if (actor_type == "GMMDecodeFasterOnline") { 83 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 84 | } else if (actor_type == "VectorWriter") { 85 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 86 | } else if (actor_type == "MatrixWriter") { 87 | actor_map->insert(make_pair(actor_name, spawn(actor_name, subscribers, config))); 88 | } else { 89 | aout << "Unknown actor type: " << actor_type << endl; 90 | return false; 91 | } 92 | } 93 | return true; 94 | } 95 | 96 | // Run actors after setting up group subscriptions 97 | bool RunActors(adjacency_list_type& graph, 98 | map* actor_map, 99 | map* subscribers_map, 100 | group_ptr actors) { 101 | 102 | // Run each actor in the graph 103 | for (int u = 0; u < graph.size(); u++) { 104 | string actor_name = graph[u].first; 105 | 106 | // Add the actor to the actors group 107 | sync_send((*actor_map)[actor_name], atom("JOIN"), actors).await( 108 | on(atom("JOINED")) >> [&]() { /* handle */ }, 109 | after(chrono::seconds(30)) >> [&] { 110 | aout << "Actor" << actor_name << 111 | " failed to subscribe to the actors group." << endl; 112 | return false; 113 | } 114 | ); 115 | 116 | // Iterate over the subscribers of the current actor 117 | for (int v = 0; v < graph[u].second.size(); v++) { 118 | string subscriber_name = graph[u].second[v]; 119 | // Ask each subscriber to join the subscribers group 120 | sync_send((*actor_map)[subscriber_name], 121 | atom("JOIN"), (*subscribers_map)[actor_name]).await( 122 | on(atom("JOINED")) >> [&]() { /* handle */ }, 123 | after(chrono::seconds(30)) >> [&] { 124 | aout << "Actor " << subscriber_name << 125 | " failed to subscribe to actor" << actor_name << endl; 126 | return false; 127 | } 128 | ); 129 | // Create a link between the actor and the subscriber 130 | sync_send((*actor_map)[subscriber_name], 131 | atom("LINK"), (*actor_map)[actor_name]).await( 132 | on(atom("LINKED")) >> [&]() { /* handle */ }, 133 | after(chrono::seconds(3)) >> [&] { 134 | aout << "Actor " << subscriber_name << 135 | " failed to link to actor" << actor_name << endl; 136 | return false; 137 | } 138 | ); 139 | } 140 | 141 | // Send the RUN message to the current actor now that 142 | // all of its subscribers are added to its subscribers group. 143 | send((*actor_map)[actor_name], atom("RUN")); 144 | } 145 | return true; 146 | } 147 | 148 | int main(int argc, char *argv[]) { 149 | try { 150 | const char *usage = 151 | "Launch a barista instance.\n" 152 | "Usage: barista [options] module-init.ini module-graph.dot\n" 153 | "Note: module-init is an INI file used for initializing the modules.\n" 154 | " module-graph is a DOT file used for defining the module graph."; 155 | ParseOptions po(usage); 156 | po.Read(argc, argv); 157 | 158 | if (po.NumArgs() != 2) { 159 | po.PrintUsage(); 160 | exit(1); 161 | } 162 | 163 | string config_filename = po.GetArg(1), graph_filename = po.GetArg(2); 164 | 165 | // Read actor config 166 | ptree config; 167 | read_ini(config_filename, config); 168 | 169 | // Read actor graph 170 | adjacency_list_type graph; 171 | if(!ReadGraph(graph_filename, &graph)) 172 | exit(1); 173 | 174 | // Announce kaldi types to the libcppa type system; 175 | AnnounceKaldiTypes(); 176 | 177 | // Spawn and run actors 178 | map actor_map; 179 | map subscribers_map; 180 | auto actors = group::anonymous(); 181 | if (!SpawnActors(graph, config, &actor_map, &subscribers_map) || 182 | !RunActors(graph, &actor_map, &subscribers_map, actors)) { 183 | exit(1); 184 | } 185 | 186 | // Send the START message to the actors group 187 | send(actors, atom("START")); 188 | 189 | // Wait until other actors are done 190 | await_all_others_done(); 191 | 192 | // Clean up before exiting main 193 | shutdown(); 194 | 195 | aout << " ++ Done" << endl; 196 | return 0; 197 | } catch (const exception &e) { 198 | cerr << e.what(); 199 | return -1; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/decoder/faster-online-decoder.cc: -------------------------------------------------------------------------------- 1 | // decoder/faster-online-decoder.cc 2 | 3 | // Copyright 2009-2012 Microsoft Corporation 4 | // Johns Hopkins University (author: Daniel Povey) 5 | 6 | // See ../../COPYING for clarification regarding multiple authors 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 16 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 17 | // MERCHANTABLITY OR NON-INFRINGEMENT. 18 | // See the Apache 2 License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | #include "decoder/faster-online-decoder.h" 22 | 23 | namespace kaldi { 24 | 25 | 26 | FasterOnlineDecoder::FasterOnlineDecoder(const fst::Fst &fst, 27 | const FasterOnlineDecoderOptions &opts): fst_(fst), config_(opts) { 28 | KALDI_ASSERT(config_.hash_ratio >= 1.0); // less doesn't make much sense. 29 | KALDI_ASSERT(config_.max_active > 1); 30 | KALDI_ASSERT(config_.min_active >= 0 && config_.min_active < config_.max_active); 31 | toks_.SetSize(1000); // just so on the first frame we do something reasonable. 32 | } 33 | 34 | void FasterOnlineDecoder::InitDecode() { 35 | // clean up from last time: 36 | ClearToks(toks_.Clear()); 37 | StateId start_state = fst_.Start(); 38 | KALDI_ASSERT(start_state != fst::kNoStateId); 39 | Arc dummy_arc(0, 0, Weight::One(), start_state); 40 | toks_.Insert(start_state, new Token(dummy_arc, NULL)); 41 | ProcessNonemitting(std::numeric_limits::max()); 42 | } 43 | 44 | void FasterOnlineDecoder::Decode(DecodableInterface *decodable) { 45 | for (int32 frame = 0; !decodable->IsLastFrame(frame-1); frame++) { 46 | BaseFloat weight_cutoff = ProcessEmitting(decodable, frame); 47 | ProcessNonemitting(weight_cutoff); 48 | } 49 | } 50 | 51 | bool FasterOnlineDecoder::ReachedFinal() { 52 | for (Elem *e = toks_.GetList(); e != NULL; e = e->tail) { 53 | Weight this_weight = Times(e->val->weight_, fst_.Final(e->key)); 54 | if (this_weight != Weight::Zero()) 55 | return true; 56 | } 57 | return false; 58 | } 59 | 60 | bool FasterOnlineDecoder::GetBestPath(fst::MutableFst *fst_out) { 61 | // GetBestPath gets the decoding output. If is_final == true, it limits itself 62 | // to final states; otherwise it gets the most likely token not taking into 63 | // account final-probs. fst_out will be empty (Start() == kNoStateId) if 64 | // nothing was available. It returns true if it got output (thus, fst_out 65 | // will be nonempty). 66 | fst_out->DeleteStates(); 67 | Token *best_tok = NULL; 68 | bool is_final = ReachedFinal(); 69 | if (!is_final) { 70 | for (Elem *e = toks_.GetList(); e != NULL; e = e->tail) 71 | if (best_tok == NULL || *best_tok < *(e->val) ) 72 | best_tok = e->val; 73 | } else { 74 | Weight best_weight = Weight::Zero(); 75 | for (Elem *e = toks_.GetList(); e != NULL; e = e->tail) { 76 | Weight this_weight = Times(e->val->weight_, fst_.Final(e->key)); 77 | if (this_weight != Weight::Zero() && 78 | this_weight.Value() < best_weight.Value()) { 79 | best_weight = this_weight; 80 | best_tok = e->val; 81 | } 82 | } 83 | } 84 | if (best_tok == NULL) return false; // No output. 85 | 86 | std::vector arcs_reverse; // arcs in reverse order. 87 | 88 | for (Token *tok = best_tok; tok != NULL; tok = tok->prev_) { 89 | BaseFloat tot_cost = tok->weight_.Value() - 90 | (tok->prev_ ? tok->prev_->weight_.Value() : 0.0), 91 | graph_cost = tok->arc_.weight.Value(), 92 | ac_cost = tot_cost - graph_cost; 93 | LatticeArc l_arc(tok->arc_.ilabel, 94 | tok->arc_.olabel, 95 | LatticeWeight(graph_cost, ac_cost), 96 | tok->arc_.nextstate); 97 | arcs_reverse.push_back(l_arc); 98 | } 99 | KALDI_ASSERT(arcs_reverse.back().nextstate == fst_.Start()); 100 | arcs_reverse.pop_back(); // that was a "fake" token... gives no info. 101 | 102 | StateId cur_state = fst_out->AddState(); 103 | fst_out->SetStart(cur_state); 104 | for (ssize_t i = static_cast(arcs_reverse.size())-1; i >= 0; i--) { 105 | LatticeArc arc = arcs_reverse[i]; 106 | arc.nextstate = fst_out->AddState(); 107 | fst_out->AddArc(cur_state, arc); 108 | cur_state = arc.nextstate; 109 | } 110 | if (is_final) { 111 | Weight final_weight = fst_.Final(best_tok->arc_.nextstate); 112 | fst_out->SetFinal(cur_state, LatticeWeight(final_weight.Value(), 0.0)); 113 | } else { 114 | fst_out->SetFinal(cur_state, LatticeWeight::One()); 115 | } 116 | RemoveEpsLocal(fst_out); 117 | return true; 118 | } 119 | 120 | 121 | // Gets the weight cutoff. Also counts the active tokens. 122 | BaseFloat FasterOnlineDecoder::GetCutoff(Elem *list_head, size_t *tok_count, 123 | BaseFloat *adaptive_beam, Elem **best_elem) { 124 | BaseFloat best_weight = std::numeric_limits::infinity(); 125 | size_t count = 0; 126 | if (config_.max_active == std::numeric_limits::max() && 127 | config_.min_active == 0) { 128 | for (Elem *e = list_head; e != NULL; e = e->tail, count++) { 129 | BaseFloat w = static_cast(e->val->weight_.Value()); 130 | if (w < best_weight) { 131 | best_weight = w; 132 | if (best_elem) *best_elem = e; 133 | } 134 | } 135 | if (tok_count != NULL) *tok_count = count; 136 | if (adaptive_beam != NULL) *adaptive_beam = config_.beam; 137 | return best_weight + config_.beam; 138 | } else { 139 | tmp_array_.clear(); 140 | for (Elem *e = list_head; e != NULL; e = e->tail, count++) { 141 | BaseFloat w = e->val->weight_.Value(); 142 | tmp_array_.push_back(w); 143 | if (w < best_weight) { 144 | best_weight = w; 145 | if (best_elem) *best_elem = e; 146 | } 147 | } 148 | if (tok_count != NULL) *tok_count = count; 149 | BaseFloat beam_cutoff = best_weight + config_.beam, 150 | min_active_cutoff = std::numeric_limits::infinity(), 151 | max_active_cutoff = std::numeric_limits::infinity(); 152 | 153 | if (tmp_array_.size() > static_cast(config_.max_active)) { 154 | std::nth_element(tmp_array_.begin(), 155 | tmp_array_.begin() + config_.max_active, 156 | tmp_array_.end()); 157 | max_active_cutoff = tmp_array_[config_.max_active]; 158 | } 159 | if (tmp_array_.size() > static_cast(config_.min_active)) { 160 | if (config_.min_active == 0) min_active_cutoff = best_weight; 161 | else { 162 | std::nth_element(tmp_array_.begin(), 163 | tmp_array_.begin() + config_.min_active, 164 | tmp_array_.size() > static_cast(config_.max_active) ? 165 | tmp_array_.begin() + config_.max_active : 166 | tmp_array_.end()); 167 | min_active_cutoff = tmp_array_[config_.min_active]; 168 | } 169 | } 170 | 171 | if (max_active_cutoff < beam_cutoff) { // max_active is tighter than beam. 172 | if (adaptive_beam) 173 | *adaptive_beam = max_active_cutoff - best_weight + config_.beam_delta; 174 | return max_active_cutoff; 175 | } else if (min_active_cutoff > beam_cutoff) { // min_active is looser than beam. 176 | if (adaptive_beam) 177 | *adaptive_beam = min_active_cutoff - best_weight + config_.beam_delta; 178 | return min_active_cutoff; 179 | } else { 180 | *adaptive_beam = config_.beam; 181 | return beam_cutoff; 182 | } 183 | } 184 | } 185 | 186 | void FasterOnlineDecoder::PossiblyResizeHash(size_t num_toks) { 187 | size_t new_sz = static_cast(static_cast(num_toks) 188 | * config_.hash_ratio); 189 | if (new_sz > toks_.Size()) { 190 | toks_.SetSize(new_sz); 191 | } 192 | } 193 | 194 | // ProcessEmitting returns the likelihood cutoff used. 195 | BaseFloat FasterOnlineDecoder::ProcessEmitting(DecodableInterface *decodable, int frame) { 196 | Elem *last_toks = toks_.Clear(); 197 | size_t tok_cnt; 198 | BaseFloat adaptive_beam; 199 | Elem *best_elem = NULL; 200 | BaseFloat weight_cutoff = GetCutoff(last_toks, &tok_cnt, 201 | &adaptive_beam, &best_elem); 202 | KALDI_VLOG(3) << tok_cnt << " tokens active."; 203 | PossiblyResizeHash(tok_cnt); // This makes sure the hash is always big enough. 204 | 205 | // This is the cutoff we use after adding in the log-likes (i.e. 206 | // for the next frame). This is a bound on the cutoff we will use 207 | // on the next frame. 208 | BaseFloat next_weight_cutoff = std::numeric_limits::infinity(); 209 | 210 | // First process the best token to get a hopefully 211 | // reasonably tight bound on the next cutoff. 212 | if (best_elem) { 213 | StateId state = best_elem->key; 214 | Token *tok = best_elem->val; 215 | for (fst::ArcIterator > aiter(fst_, state); 216 | !aiter.Done(); 217 | aiter.Next()) { 218 | const Arc &arc = aiter.Value(); 219 | if (arc.ilabel != 0) { // we'd propagate.. 220 | BaseFloat ac_cost = - decodable->LogLikelihood(frame, arc.ilabel), 221 | new_weight = arc.weight.Value() + tok->weight_.Value() + ac_cost; 222 | if (new_weight + adaptive_beam < next_weight_cutoff) 223 | next_weight_cutoff = new_weight + adaptive_beam; 224 | } 225 | } 226 | } 227 | 228 | // int32 n = 0, np = 0; 229 | 230 | // the tokens are now owned here, in last_toks, and the hash is empty. 231 | // 'owned' is a complex thing here; the point is we need to call TokenDelete 232 | // on each elem 'e' to let toks_ know we're done with them. 233 | for (Elem *e = last_toks, *e_tail; e != NULL; e = e_tail) { // loop this way 234 | // n++; 235 | // because we delete "e" as we go. 236 | StateId state = e->key; 237 | Token *tok = e->val; 238 | if (tok->weight_.Value() < weight_cutoff) { // not pruned. 239 | // np++; 240 | KALDI_ASSERT(state == tok->arc_.nextstate); 241 | for (fst::ArcIterator > aiter(fst_, state); 242 | !aiter.Done(); 243 | aiter.Next()) { 244 | Arc arc = aiter.Value(); 245 | if (arc.ilabel != 0) { // propagate.. 246 | Weight ac_weight(- decodable->LogLikelihood(frame, arc.ilabel)); 247 | BaseFloat new_weight = arc.weight.Value() + tok->weight_.Value() 248 | + ac_weight.Value(); 249 | if (new_weight < next_weight_cutoff) { // not pruned.. 250 | Token *new_tok = new Token(arc, ac_weight, tok); 251 | Elem *e_found = toks_.Find(arc.nextstate); 252 | if (new_weight + adaptive_beam < next_weight_cutoff) 253 | next_weight_cutoff = new_weight + adaptive_beam; 254 | if (e_found == NULL) { 255 | toks_.Insert(arc.nextstate, new_tok); 256 | } else { 257 | if ( *(e_found->val) < *new_tok ) { 258 | Token::TokenDelete(e_found->val); 259 | e_found->val = new_tok; 260 | } else { 261 | Token::TokenDelete(new_tok); 262 | } 263 | } 264 | } 265 | } 266 | } 267 | } 268 | e_tail = e->tail; 269 | Token::TokenDelete(e->val); 270 | toks_.Delete(e); 271 | } 272 | return next_weight_cutoff; 273 | } 274 | 275 | // TODO: first time we go through this, could avoid using the queue. 276 | void FasterOnlineDecoder::ProcessNonemitting(BaseFloat cutoff) { 277 | // Processes nonemitting arcs for one frame. 278 | KALDI_ASSERT(queue_.empty()); 279 | for (Elem *e = toks_.GetList(); e != NULL; e = e->tail) 280 | queue_.push_back(e->key); 281 | while (!queue_.empty()) { 282 | StateId state = queue_.back(); 283 | queue_.pop_back(); 284 | Token *tok = toks_.Find(state)->val; // would segfault if state not 285 | // in toks_ but this can't happen. 286 | if (tok->weight_.Value() > cutoff) { // Don't bother processing successors. 287 | continue; 288 | } 289 | KALDI_ASSERT(tok != NULL && state == tok->arc_.nextstate); 290 | for (fst::ArcIterator > aiter(fst_, state); 291 | !aiter.Done(); 292 | aiter.Next()) { 293 | const Arc &arc = aiter.Value(); 294 | if (arc.ilabel == 0) { // propagate nonemitting only... 295 | Token *new_tok = new Token(arc, tok); 296 | if (new_tok->weight_.Value() > cutoff) { // prune 297 | Token::TokenDelete(new_tok); 298 | } else { 299 | Elem *e_found = toks_.Find(arc.nextstate); 300 | if (e_found == NULL) { 301 | toks_.Insert(arc.nextstate, new_tok); 302 | queue_.push_back(arc.nextstate); 303 | } else { 304 | if ( *(e_found->val) < *new_tok ) { 305 | Token::TokenDelete(e_found->val); 306 | e_found->val = new_tok; 307 | queue_.push_back(arc.nextstate); 308 | } else { 309 | Token::TokenDelete(new_tok); 310 | } 311 | } 312 | } 313 | } 314 | } 315 | } 316 | } 317 | 318 | void FasterOnlineDecoder::ClearToks(Elem *list) { 319 | for (Elem *e = list, *e_tail; e != NULL; e = e_tail) { 320 | Token::TokenDelete(e->val); 321 | e_tail = e->tail; 322 | toks_.Delete(e); 323 | } 324 | } 325 | 326 | } // end namespace kaldi. 327 | -------------------------------------------------------------------------------- /src/decoder/faster-online-decoder.h: -------------------------------------------------------------------------------- 1 | // decoder/faster-online-decoder.h 2 | 3 | // Copyright 2009-2011 Microsoft Corporation 4 | 5 | // See ../../COPYING for clarification regarding multiple authors 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 15 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 16 | // MERCHANTABLITY OR NON-INFRINGEMENT. 17 | // See the Apache 2 License for the specific language governing permissions and 18 | // limitations under the License. 19 | 20 | #ifndef KALDI_DECODER_FASTER_ONLINE_DECODER_H_ 21 | #define KALDI_DECODER_FASTER_ONLINE_DECODER_H_ 22 | 23 | #include "util/stl-utils.h" 24 | #include "itf/options-itf.h" 25 | #include "util/hash-list.h" 26 | #include "fst/fstlib.h" 27 | #include "itf/decodable-itf.h" 28 | #include "lat/kaldi-lattice.h" // for CompactLatticeArc 29 | 30 | #ifdef _MSC_VER 31 | #include 32 | #else 33 | #include 34 | #endif 35 | using std::tr1::unordered_map; 36 | 37 | namespace kaldi { 38 | 39 | struct FasterOnlineDecoderOptions { 40 | BaseFloat beam; 41 | int32 max_active; 42 | int32 min_active; 43 | BaseFloat beam_delta; 44 | BaseFloat hash_ratio; 45 | FasterOnlineDecoderOptions(): beam(16.0), 46 | max_active(std::numeric_limits::max()), 47 | min_active(20), // This decoder mostly used for 48 | // alignment, use small default. 49 | beam_delta(0.5), 50 | hash_ratio(2.0) { } 51 | void Register(OptionsItf *po, bool full) { /// if "full", use obscure 52 | /// options too. 53 | /// Depends on program. 54 | po->Register("beam", &beam, "Decoder beam"); 55 | po->Register("max-active", &max_active, "Decoder max active states."); 56 | po->Register("min-active", &min_active, 57 | "Decoder min active states (don't prune if #active less than this)."); 58 | if (full) { 59 | po->Register("beam-delta", &beam_delta, 60 | "Increment used in decoder [obscure setting]"); 61 | po->Register("hash-ratio", &hash_ratio, 62 | "Setting used in decoder to control hash behavior"); 63 | } 64 | } 65 | }; 66 | 67 | class FasterOnlineDecoder { 68 | public: 69 | typedef fst::StdArc Arc; 70 | typedef Arc::Label Label; 71 | typedef Arc::StateId StateId; 72 | typedef Arc::Weight Weight; 73 | 74 | FasterOnlineDecoder(const fst::Fst &fst, 75 | const FasterOnlineDecoderOptions &config); 76 | 77 | void SetOptions(const FasterOnlineDecoderOptions &config) { config_ = config; } 78 | 79 | ~FasterOnlineDecoder() { ClearToks(toks_.Clear()); } 80 | 81 | void InitDecode(); 82 | 83 | void Decode(DecodableInterface *decodable); 84 | 85 | bool ReachedFinal(); 86 | 87 | bool GetBestPath(fst::MutableFst *fst_out); 88 | 89 | protected: 90 | 91 | class Token { 92 | public: 93 | Arc arc_; // contains only the graph part of the cost; 94 | // we can work out the acoustic part from difference between 95 | // "weight_" and prev->weight_. 96 | Token *prev_; 97 | int32 ref_count_; 98 | Weight weight_; // weight up to current point. 99 | inline Token(const Arc &arc, Weight &ac_weight, Token *prev): 100 | arc_(arc), prev_(prev), ref_count_(1) { 101 | if (prev) { 102 | prev->ref_count_++; 103 | weight_ = Times(Times(prev->weight_, arc.weight), ac_weight); 104 | } else { 105 | weight_ = Times(arc.weight, ac_weight); 106 | } 107 | } 108 | inline Token(const Arc &arc, Token *prev): 109 | arc_(arc), prev_(prev), ref_count_(1) { 110 | if (prev) { 111 | prev->ref_count_++; 112 | weight_ = Times(prev->weight_, arc.weight); 113 | } else { 114 | weight_ = arc.weight; 115 | } 116 | } 117 | inline bool operator < (const Token &other) { 118 | return weight_.Value() > other.weight_.Value(); 119 | // This makes sense for log + tropical semiring. 120 | } 121 | 122 | inline static void TokenDelete(Token *tok) { 123 | while (--tok->ref_count_ == 0) { 124 | Token *prev = tok->prev_; 125 | delete tok; 126 | if (prev == NULL) return; 127 | else tok = prev; 128 | } 129 | #ifdef KALDI_PARANOID 130 | KALDI_ASSERT(tok->ref_count_ > 0); 131 | #endif 132 | } 133 | }; 134 | typedef HashList::Elem Elem; 135 | 136 | 137 | /// Gets the weight cutoff. Also counts the active tokens. 138 | BaseFloat GetCutoff(Elem *list_head, size_t *tok_count, 139 | BaseFloat *adaptive_beam, Elem **best_elem); 140 | 141 | void PossiblyResizeHash(size_t num_toks); 142 | 143 | // ProcessEmitting returns the likelihood cutoff used. 144 | BaseFloat ProcessEmitting(DecodableInterface *decodable, int frame); 145 | 146 | // TODO: first time we go through this, could avoid using the queue. 147 | void ProcessNonemitting(BaseFloat cutoff); 148 | 149 | // HashList defined in ../util/hash-list.h. It actually allows us to maintain 150 | // more than one list (e.g. for current and previous frames), but only one of 151 | // them at a time can be indexed by StateId. 152 | HashList toks_; 153 | const fst::Fst &fst_; 154 | FasterOnlineDecoderOptions config_; 155 | std::vector queue_; // temp variable used in ProcessNonemitting, 156 | std::vector tmp_array_; // used in GetCutoff. 157 | // make it class member to avoid internal new/delete. 158 | 159 | // It might seem unclear why we call ClearToks(toks_.Clear()). 160 | // There are two separate cleanup tasks we need to do at when we start a new file. 161 | // one is to delete the Token objects in the list; the other is to delete 162 | // the Elem objects. toks_.Clear() just clears them from the hash and gives ownership 163 | // to the caller, who then has to call toks_.Delete(e) for each one. It was designed 164 | // this way for convenience in propagating tokens from one frame to the next. 165 | void ClearToks(Elem *list); 166 | 167 | KALDI_DISALLOW_COPY_AND_ASSIGN(FasterOnlineDecoder); 168 | }; 169 | 170 | 171 | } // end namespace kaldi. 172 | 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /src/feat/add-deltas.cc: -------------------------------------------------------------------------------- 1 | #include "add-deltas.h" 2 | 3 | using namespace std; 4 | using namespace kaldi; 5 | using namespace cppa; 6 | 7 | behavior AddDeltas::Run(){ 8 | return ( 9 | on >() >> [=](string key, Matrix feats) { 10 | 11 | // redundant check -- this should already be taken care of 12 | // if (feats.NumRows() == 0) { 13 | // continue; 14 | // } 15 | 16 | // Create dummy pad feats for first feature block 17 | if (pad_feats.NumRows() == 0) { 18 | pad_feats.Resize(pad_size / 2, feats.NumCols()); 19 | for (MatrixIndexT i = 0; i < pad_size / 2; i++) 20 | pad_feats.CopyRowFromVec(feats.Row(0), i); 21 | } 22 | 23 | // Create a new matrix for padded features 24 | Matrix padded_feats(pad_feats.NumRows() + feats.NumRows(), 25 | feats.NumCols()); 26 | 27 | // Add pad features 28 | padded_feats.Range(0, pad_feats.NumRows(), 29 | 0, pad_feats.NumCols()).CopyFromMat(pad_feats); 30 | // Add current features 31 | padded_feats.Range(pad_feats.NumRows(), feats.NumRows(), 32 | 0, feats.NumCols()).CopyFromMat(feats); 33 | 34 | // Compute delta features 35 | ComputeDeltas(opts, padded_feats, &delta_feats); 36 | 37 | // Send truncated delta feats 38 | if (delta_feats.NumRows() > pad_size) { 39 | out_data = Matrix( 40 | SubMatrix(delta_feats, pad_size / 2, 41 | delta_feats.NumRows() - pad_size, 42 | 0, delta_feats.NumCols())); 43 | send(subscribers, key, out_data); 44 | } 45 | 46 | // Update pad features 47 | pad_feats = Matrix( 48 | SubMatrix(padded_feats, 49 | max(0, padded_feats.NumRows() - pad_size), 50 | min(padded_feats.NumRows(), pad_size), 51 | 0, padded_feats.NumCols())); 52 | }, 53 | on(atom("UTT_END")) >> [=]() { 54 | // Guard against a very short utterance 55 | MatrixIndexT offset = max(pad_size / 2, delta_feats.NumRows() - pad_size / 2); 56 | out_data = Matrix( 57 | SubMatrix(delta_feats, 58 | offset, delta_feats.NumRows() - offset, 59 | 0, delta_feats.NumCols())); 60 | // Send the remaining delta feats 61 | send(subscribers, "", out_data); 62 | 63 | // Empty pad feats 64 | pad_feats.Resize(0, 0); 65 | 66 | // Send the utterance end signal 67 | send(subscribers, atom("UTT_END")); 68 | }, 69 | on(atom("QUIT")) >> [=]() { 70 | self->quit(exit_reason::user_shutdown); 71 | }, 72 | on(atom("DONE")) >> [=]() { 73 | send(subscribers, atom("DONE")); 74 | self->quit(exit_reason::normal); 75 | } 76 | ); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/feat/add-deltas.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_ADD_DELTAS_H_ 2 | #define BARISTA_ADD_DELTAS_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | #include 7 | 8 | class AddDeltas : public ModuleBase { 9 | public: 10 | AddDeltas(const std::string& name_, 11 | const cppa::group_ptr& subscribers_, 12 | const boost::property_tree::ptree& config) : 13 | ModuleBase(name_, subscribers_) { 14 | 15 | // config 16 | // order = config.get(name + ".order"); 17 | // window = config.get(name + ".window"); 18 | 19 | // FIXME: Here we should set the delta opts according to config file 20 | 21 | // opts.order: Order of delta computation 22 | // opts.window: Parameter controlling window for delta computation 23 | // (actual window size for each delta order is 2 * window + 1) 24 | // The behavior at the edges is to replicate the first or last frame. 25 | 26 | // pad_size: how many contextual frames we need for correct computation 27 | pad_size = 2 * opts.order * opts.window; 28 | 29 | pad_feats(0, 0); 30 | 31 | running_state = Run(); 32 | } 33 | 34 | cppa::behavior Run(); 35 | 36 | private: 37 | // configurable members 38 | bool norm_vars; 39 | 40 | // class internal members 41 | kaldi::DeltaFeaturesOptions opts; 42 | kaldi::MatrixIndexT pad_size; 43 | 44 | kaldi::Matrix pad_feats; 45 | kaldi::Matrix delta_feats; 46 | 47 | kaldi::Matrix out_data; 48 | 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/feat/apply-cmvn.cc: -------------------------------------------------------------------------------- 1 | #include "apply-cmvn.h" 2 | 3 | using namespace std; 4 | using namespace kaldi; 5 | using namespace cppa; 6 | 7 | /// Discard stats gathered from a single frame (weighted). 8 | void DiscardCmvnStats(const VectorBase &feats, 9 | BaseFloat weight, 10 | MatrixBase *stats) { 11 | int32 dim = feats.Dim(); 12 | KALDI_ASSERT(stats != NULL); 13 | KALDI_ASSERT(stats->NumRows() == 2 && stats->NumCols() == dim + 1); 14 | // Remove these __restrict__ modifiers if they cause compilation problems. 15 | // It's just an optimization. 16 | double *__restrict__ mean_ptr = stats->RowData(0), 17 | *__restrict__ var_ptr = stats->RowData(1), 18 | *__restrict__ count_ptr = mean_ptr + dim; 19 | const BaseFloat * __restrict__ feats_ptr = feats.Data(); 20 | *count_ptr -= weight; 21 | // Careful-- if we change the format of the matrix, the "mean_ptr < count_ptr" 22 | // statement below might become wrong. 23 | for (; mean_ptr < count_ptr; mean_ptr++, var_ptr++, feats_ptr++) { 24 | *mean_ptr -= *feats_ptr * weight; 25 | *var_ptr -= *feats_ptr * *feats_ptr * weight; 26 | } 27 | } 28 | 29 | behavior ApplyCMVN::Run(){ 30 | return ( 31 | on >() >> [=](string key, Matrix data) { 32 | 33 | if (buffer.NumRows() == 0) { 34 | buffer.Resize(buffer_size, data.NumCols(), kUndefined); 35 | out_data.Resize(data.NumRows() + context_size, data.NumCols(), kUndefined); 36 | InitCmvnStats(data.NumCols(), &cmvn_stats); 37 | full = false; // buffer is not full 38 | head = 0; 39 | current = 0; 40 | last = 0; 41 | } 42 | 43 | for (int i = 0; i < data.NumRows(); i++) { 44 | // The frame at buffer head is not included in the current context 45 | // so we discard the cmvn stats gathered from that frame 46 | if (full) 47 | DiscardCmvnStats(buffer.Row(head), 1.0, &cmvn_stats); 48 | // Accumulate the stats gathered from the data frame 49 | AccCmvnStats(data.Row(i), 1.0, &cmvn_stats); 50 | // Insert data frame to the buffer at head position 51 | buffer.CopyRowFromVec(data.Row(i), head); 52 | // Update buffer head index 53 | head = (head + 1) % buffer_size; 54 | if (!full) { 55 | if (head == 0) { 56 | last = context_size + 1; 57 | NormalizeFrames(); 58 | full = true; 59 | } 60 | } else { 61 | last = current + 1; 62 | NormalizeFrames(); 63 | } 64 | } 65 | 66 | // Send normalized frames 67 | if (out_size > 0) { 68 | out_data.Resize(out_size, buffer.NumCols(), kCopyData); 69 | send(subscribers, key, out_data); 70 | out_size = 0; 71 | } 72 | }, 73 | on(atom("UTT_END")) >> [=]() { 74 | // Normalize remaning frames of current utterance 75 | last = head; 76 | NormalizeFrames(); 77 | if (out_size > 0) { 78 | out_data.Resize(out_size, buffer.NumCols(), kCopyData); 79 | send(subscribers, "", out_data); 80 | out_size = 0; 81 | } 82 | send(subscribers, atom("UTT_END")); 83 | buffer.Resize(0, 0); 84 | }, 85 | on(atom("QUIT")) >> [=]() { 86 | self->quit(exit_reason::user_shutdown); 87 | }, 88 | on(atom("DONE")) >> [=]() { 89 | send(subscribers, atom("DONE")); 90 | self->quit(exit_reason::normal); 91 | } 92 | ); 93 | } 94 | 95 | bool ApplyCMVN::NormalizeFrames() { 96 | // Compute number of frames to be normalized and update output size 97 | uint32 num_frames = (last - current + buffer_size) % buffer_size; 98 | uint32 row_offset = out_size; 99 | out_size = row_offset + num_frames; 100 | 101 | // Resize output matrix if necessary 102 | if (out_size > out_data.NumRows()) { 103 | out_data.Resize(out_size, buffer.NumCols(), kCopyData); 104 | } 105 | // Copy frames to be normalized into output 106 | for (int i = row_offset; i < out_size; i++) { 107 | out_data.CopyRowFromVec(buffer.Row(current), i); 108 | current = (current + 1) % buffer_size; 109 | } 110 | // Apply CMVN 111 | auto frames = out_data.RowRange(row_offset, num_frames); 112 | ApplyCmvn(cmvn_stats, norm_vars, &frames); 113 | return true; 114 | } 115 | -------------------------------------------------------------------------------- /src/feat/apply-cmvn.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_APPLY_CMVN_H_ 2 | #define BARISTA_APPLY_CMVN_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | #include 7 | 8 | class ApplyCMVN : public ModuleBase { 9 | public: 10 | ApplyCMVN(const std::string& name_, 11 | const cppa::group_ptr& subscribers_, 12 | const boost::property_tree::ptree& config) : 13 | ModuleBase(name_, subscribers_) { 14 | 15 | // config 16 | norm_vars = config.get(name + ".norm_vars"); 17 | context_size = config.get(name + ".context_size"); 18 | 19 | buffer_size = 2 * context_size + 1; 20 | head = 0; 21 | current = 0; 22 | out_size = 0; 23 | 24 | running_state = Run(); 25 | } 26 | 27 | cppa::behavior Run(); 28 | 29 | private: 30 | bool NormalizeFrames(); 31 | 32 | // configurable members 33 | bool norm_vars; 34 | kaldi::uint32 context_size; 35 | 36 | // class internal members 37 | kaldi::Matrix buffer; // circular buffer 38 | kaldi::uint32 buffer_size; 39 | kaldi::uint32 head; // keeps track of head frame 40 | kaldi::uint32 current; // keeps track of first frame to normalize 41 | kaldi::uint32 last; // keeps track of last frame to normalize 42 | bool full; // buffer full or not 43 | 44 | kaldi::Matrix out_data; // normalized frames 45 | kaldi::uint32 out_size; // number of normalized frames 46 | 47 | kaldi::Matrix cmvn_stats; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/feat/compute-mfcc-feats.cc: -------------------------------------------------------------------------------- 1 | #include "compute-mfcc-feats.h" 2 | 3 | using namespace std; 4 | using namespace kaldi; 5 | using namespace cppa; 6 | 7 | behavior ComputeMFCCFeats::Run(){ 8 | return ( 9 | on >() >> [=](string key, Vector in_data) { 10 | ComputeMFCC(key, in_data); 11 | }, 12 | on(atom("UTT_END")) >> [=]() { 13 | waveform.Resize(0); 14 | send(subscribers, atom("UTT_END")); 15 | }, 16 | on(atom("QUIT")) >> [=]() { 17 | self->quit(exit_reason::user_shutdown); 18 | }, 19 | on(atom("DONE")) >> [=]() { 20 | send(subscribers, atom("DONE")); 21 | self->quit(exit_reason::normal); 22 | } 23 | ); 24 | } 25 | 26 | bool ComputeMFCCFeats::ComputeMFCC(string& key, Vector& in_data) { 27 | 28 | // add new wave data at the end of waveform 29 | waveform.Resize(waveform.Dim() + in_data.Dim(), kaldi::kCopyData); 30 | SubVector(waveform, waveform.Dim() - in_data.Dim(), in_data.Dim()).CopyFromVec(in_data); 31 | 32 | // if the waveform data length is less than window length, continue to get data 33 | if (waveform.Dim() < frame_window_length) 34 | return false; 35 | 36 | // after computing features of the current waveform data, 37 | // save the remainder for the next chunk 38 | Vector waveform_remainder; 39 | mfcc->Compute(waveform, vtln_warp_local, &out_data, &waveform_remainder); 40 | waveform.Swap(&waveform_remainder); 41 | 42 | send(subscribers, key, out_data); 43 | return true; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/feat/compute-mfcc-feats.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_COMPUTE_MFCC_FEATS_H_ 2 | #define BARISTA_COMPUTE_MFCC_FEATS_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | #include 7 | 8 | class ComputeMFCCFeats : public ModuleBase { 9 | public: 10 | ComputeMFCCFeats(const std::string& name_, 11 | const cppa::group_ptr& subscribers_, 12 | const boost::property_tree::ptree& config) : 13 | ModuleBase(name_, subscribers_) { 14 | // config 15 | use_energy = config.get(name + ".use_energy"); 16 | vtln_warp_local = config.get(name + ".vtln_warp_local"); 17 | 18 | // Set MFCC options and allocate an MFCC extractor 19 | kaldi::MfccOptions op; 20 | op.use_energy = use_energy; 21 | frame_window_length = op.frame_opts.WindowSize(); 22 | mfcc = new kaldi::Mfcc(op); 23 | 24 | //initialize 25 | waveform(0); 26 | out_data(0, 0); 27 | 28 | running_state = Run(); 29 | } 30 | 31 | ~ComputeMFCCFeats() { 32 | delete mfcc; 33 | } 34 | 35 | cppa::behavior Run(); 36 | 37 | private: 38 | bool ComputeMFCC(std::string& key, kaldi::Vector& in_data); 39 | 40 | // configurable members 41 | bool use_energy; 42 | kaldi::BaseFloat vtln_warp_local; 43 | 44 | // class internal members 45 | kaldi::Mfcc* mfcc; 46 | 47 | kaldi::uint32 frame_window_length; 48 | 49 | kaldi::Vector waveform; // holds the input waveform 50 | kaldi::Matrix out_data; // holds the features 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/feat/filter.cc: -------------------------------------------------------------------------------- 1 | #include "filter.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | using namespace kaldi; 7 | using namespace cppa; 8 | 9 | behavior Filter::Run(){ 10 | return ( 11 | on >() >> [=](string key, Vector data) { 12 | for (int i = 0; i < data.Dim(); i++) { 13 | data(i) = data(i) * weight; 14 | } 15 | send(subscribers, key, data); 16 | }, 17 | on(atom("UTT_END")) >> [=]() { 18 | send(subscribers, atom("UTT_END")); 19 | }, 20 | on(atom("QUIT")) >> [=]() { 21 | self->quit(exit_reason::user_shutdown); 22 | }, 23 | on(atom("DONE")) >> [=]() { 24 | send(subscribers, atom("DONE")); 25 | self->quit(exit_reason::normal); 26 | } 27 | ); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/feat/filter.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_FILTER_H_ 2 | #define BARISTA_FILTER_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | // Dummy filter which simply multiplies input vector by a scalar weight. 7 | // It can be used as a template for implementing new Barista modules. 8 | 9 | class Filter : public ModuleBase { 10 | public: 11 | Filter(const std::string& name_, 12 | const cppa::group_ptr& subscribers_, 13 | const boost::property_tree::ptree& config) : 14 | ModuleBase(name_, subscribers_) { 15 | // config 16 | weight = config.get(name + ".weight"); 17 | 18 | running_state = Run(); 19 | } 20 | 21 | ~Filter() {} 22 | 23 | cppa::behavior Run(); 24 | 25 | private: 26 | // configurable members 27 | kaldi::BaseFloat weight; 28 | 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/gmm/gmm-decode-faster-online.cc: -------------------------------------------------------------------------------- 1 | #include "gmm-decode-faster-online.h" 2 | 3 | using namespace std; 4 | using namespace kaldi; 5 | using namespace cppa; 6 | 7 | 8 | fst::Fst* ReadNetwork(std::string& filename) { 9 | // read decoding network FST 10 | kaldi::Input ki(filename); // use ki.Stream() instead of is. 11 | if (!ki.Stream().good()) KALDI_ERR << "Could not open decoding-graph FST " 12 | << filename; 13 | fst::FstHeader hdr; 14 | if (!hdr.Read(ki.Stream(), "")) { 15 | KALDI_ERR << "Reading FST: error reading FST header."; 16 | } 17 | if (hdr.ArcType() != fst::StdArc::Type()) { 18 | KALDI_ERR << "FST with arc type " << hdr.ArcType() << " not supported.\n"; 19 | } 20 | fst::FstReadOptions ropts("", &hdr); 21 | fst::Fst *decode_fst = NULL; 22 | if (hdr.FstType() == "vector") { 23 | decode_fst = fst::VectorFst::Read(ki.Stream(), ropts); 24 | } else if (hdr.FstType() == "const") { 25 | decode_fst = fst::ConstFst::Read(ki.Stream(), ropts); 26 | } else { 27 | KALDI_ERR << "Reading FST: unsupported FST type: " << hdr.FstType(); 28 | } 29 | if (decode_fst == NULL) { // fst code will warn. 30 | KALDI_ERR << "Error reading FST (after reading header)."; 31 | return NULL; 32 | } else { 33 | return decode_fst; 34 | } 35 | } 36 | 37 | void WriteBestPath(FasterOnlineDecoder &decoder, 38 | bool allow_partial, 39 | BaseFloat acoustic_scale, 40 | std::string &key, 41 | std::string &lattice_wspecifier, 42 | int32 utt_frame_count, 43 | fst::SymbolTable *word_syms, 44 | Int32VectorWriter &words_writer, 45 | Int32VectorWriter &alignment_writer, 46 | CompactLatticeWriter &clat_writer, 47 | int *num_success, 48 | int *num_fail, 49 | kaldi::int64 *frame_count, 50 | BaseFloat *tot_like) { 51 | 52 | fst::VectorFst decoded; // linear FST. 53 | 54 | if ( (allow_partial || decoder.ReachedFinal()) 55 | && decoder.GetBestPath(&decoded) ) { 56 | if (!decoder.ReachedFinal()) 57 | KALDI_WARN << "Decoder did not reach end-state, " 58 | << "outputting partial traceback since --allow-partial=true"; 59 | *num_success += 1; 60 | if (!decoder.ReachedFinal()) 61 | KALDI_WARN << "Decoder did not reach end-state, outputting partial traceback."; 62 | std::vector alignment; 63 | std::vector words; 64 | LatticeWeight weight; 65 | *frame_count += utt_frame_count; 66 | 67 | GetLinearSymbolSequence(decoded, &alignment, &words, &weight); 68 | 69 | if (words_writer.IsOpen()) 70 | words_writer.Write(key, words); 71 | if (alignment_writer.IsOpen()) 72 | alignment_writer.Write(key, alignment); 73 | 74 | if (lattice_wspecifier != "") { 75 | if (acoustic_scale != 0.0) // We'll write the lattice without acoustic scaling 76 | fst::ScaleLattice(fst::AcousticLatticeScale(1.0 / acoustic_scale), &decoded); 77 | fst::VectorFst clat; 78 | ConvertLattice(decoded, &clat, true); 79 | clat_writer.Write(key, clat); 80 | } 81 | 82 | if (word_syms != NULL) { 83 | std::cerr << key << ' '; 84 | for (size_t i = 0; i < words.size(); i++) { 85 | std::string s = word_syms->Find(words[i]); 86 | if (s == "") 87 | KALDI_ERR << "Word-id " << words[i] <<" not in symbol table."; 88 | std::cerr << s << ' '; 89 | } 90 | std::cerr << '\n'; 91 | } 92 | BaseFloat like = -weight.Value1() -weight.Value2(); 93 | *tot_like += like; 94 | KALDI_LOG << "Log-like per frame for utterance " << key << " is " 95 | << (like / utt_frame_count) << " over " 96 | << utt_frame_count << " frames."; 97 | KALDI_VLOG(2) << "Cost for utterance " << key << " is " 98 | << weight.Value1() << " + " << weight.Value2(); 99 | } else { 100 | *num_fail += 1; 101 | KALDI_WARN << "Did not successfully decode utterance " << key 102 | << ", len = " << utt_frame_count; 103 | } 104 | } 105 | 106 | behavior GMMDecodeFasterOnline::Run(){ 107 | return ( 108 | on >() >> [=](string key, Matrix feats) { 109 | 110 | // read key 111 | std::stringstream ss; 112 | ss << utt_number; 113 | utt_key = ss.str(); 114 | 115 | DecodableAmDiagGmmScaled gmm_decodable(am_gmm, trans_model, feats, 116 | acoustic_scale); 117 | 118 | // If utt_key has changed, initialize decoder for the new utterance 119 | if (utt_key.compare(prev_utt_key) != 0) { 120 | decoder->InitDecode(); 121 | } 122 | decoder->Decode(&gmm_decodable); 123 | utt_frame_count += feats.NumRows(); 124 | prev_utt_key = utt_key; 125 | }, 126 | on(atom("UTT_END")) >> [=]() { 127 | // finish decoding previous utterance 128 | if (utt_frame_count > 0) { 129 | WriteBestPath(*decoder, allow_partial, acoustic_scale, utt_key, 130 | lattice_wspecifier, utt_frame_count, word_syms, 131 | words_writer, alignment_writer, clat_writer, 132 | &num_success, &num_fail, &frame_count, &tot_like); 133 | utt_frame_count = 0; 134 | } 135 | utt_number++; 136 | }, 137 | on(atom("START")) >> [=]() { 138 | timer.Reset(); 139 | }, 140 | on(atom("QUIT")) >> [=]() { 141 | self->quit(exit_reason::user_shutdown); 142 | }, 143 | on(atom("DONE")) >> [=]() { 144 | double elapsed = timer.Elapsed(); 145 | KALDI_LOG << "Time taken [excluding initialization] "<< elapsed 146 | << "s: real-time factor assuming 100 frames/sec is " 147 | << (elapsed*100.0/frame_count); 148 | KALDI_LOG << "Done " << num_success << " utterances, failed for " 149 | << num_fail; 150 | KALDI_LOG << "Overall log-likelihood per frame is " 151 | << (tot_like/frame_count) << " over " << frame_count<<" frames."; 152 | self->quit(exit_reason::normal); 153 | } 154 | ); 155 | } 156 | -------------------------------------------------------------------------------- /src/gmm/gmm-decode-faster-online.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_GMM_DECODE_FASTER_ONLINE_H_ 2 | #define BARISTA_GMM_DECODE_FASTER_ONLINE_H_ 3 | 4 | #include "base/module-base.h" 5 | #include "decoder/faster-online-decoder.h" 6 | 7 | #include "base/kaldi-common.h" 8 | #include "util/common-utils.h" 9 | #include "gmm/am-diag-gmm.h" 10 | #include "gmm/decodable-am-diag-gmm.h" 11 | #include "hmm/transition-model.h" 12 | #include "fstext/fstext-lib.h" 13 | #include "util/timer.h" 14 | #include "lat/kaldi-lattice.h" // for CompactLatticeArc 15 | 16 | fst::Fst* ReadNetwork(std::string& filename); 17 | 18 | class GMMDecodeFasterOnline : public ModuleBase { 19 | public: 20 | GMMDecodeFasterOnline(const std::string& name_, 21 | const cppa::group_ptr& subscribers_, 22 | const boost::property_tree::ptree& config) : 23 | ModuleBase(name_, subscribers_) { 24 | 25 | // config 26 | word_syms_filename = config.get(name + ".word_syms_filename"); 27 | model_rxfilename = config.get(name + ".model_rxfilename"); 28 | fst_rxfilename = config.get(name + ".fst_rxfilename"); 29 | 30 | words_wspecifier = config.get(name + ".words_wspecifier"); 31 | alignment_wspecifier = config.get(name + ".alignment_wspecifier"); 32 | lattice_wspecifier = config.get(name + ".lattice_wspecifier"); 33 | 34 | acoustic_scale = config.get(name + ".acoustic_scale"); 35 | beam = config.get(name + ".beam"); 36 | max_active = config.get(name + ".max_active"); 37 | allow_partial = config.get(name + ".allow_partial"); 38 | 39 | // set decoder options 40 | decoder_opts.beam = beam; 41 | decoder_opts.max_active = max_active; 42 | 43 | // read acoustic model 44 | bool binary; 45 | kaldi::Input ki(model_rxfilename, &binary); 46 | trans_model.Read(ki.Stream(), binary); 47 | am_gmm.Read(ki.Stream(), binary); 48 | 49 | // setup output writers 50 | words_wspecifier != "" && words_writer.Open(words_wspecifier); 51 | alignment_wspecifier != "" && alignment_writer.Open(alignment_wspecifier); 52 | lattice_wspecifier != "" && clat_writer.Open(lattice_wspecifier); 53 | 54 | // read word symbols 55 | word_syms = NULL; 56 | if (word_syms_filename != "") 57 | if (!(word_syms = fst::SymbolTable::ReadText(word_syms_filename))) 58 | KALDI_ERR << "Could not read symbol table from file " 59 | << word_syms_filename; 60 | 61 | 62 | // It's important that we initialize decode_fst after feature_reader, as it 63 | // can prevent crashes on systems installed without enough virtual memory. 64 | // It has to do with what happens on UNIX systems if you call fork() on a 65 | // large process: the page-table entries are duplicated, which requires a 66 | // lot of virtual memory. 67 | 68 | // read decoding network 69 | decode_fst = ReadNetwork(fst_rxfilename); 70 | 71 | // initialize the decoder 72 | decoder = new kaldi::FasterOnlineDecoder(*decode_fst, decoder_opts); 73 | 74 | // initialize counters, etc. 75 | tot_like = 0.0; 76 | frame_count = 0; 77 | num_success = 0; 78 | num_fail = 0; 79 | 80 | utt_key = ""; 81 | prev_utt_key = ""; 82 | utt_frame_count = 0; 83 | utt_number = 1; 84 | 85 | running_state = Run(); 86 | 87 | } 88 | 89 | ~GMMDecodeFasterOnline() { 90 | delete word_syms; 91 | delete decoder; 92 | delete decode_fst; 93 | } 94 | 95 | cppa::behavior Run(); 96 | 97 | private: 98 | 99 | // configurable members 100 | std::string word_syms_filename; 101 | std::string model_rxfilename; 102 | std::string fst_rxfilename; 103 | 104 | std::string words_wspecifier; 105 | std::string alignment_wspecifier; 106 | std::string lattice_wspecifier; 107 | 108 | kaldi::BaseFloat acoustic_scale; 109 | kaldi::BaseFloat beam; 110 | kaldi::int32 max_active; 111 | bool allow_partial; 112 | 113 | // class internal members 114 | kaldi::FasterOnlineDecoderOptions decoder_opts; 115 | kaldi::TransitionModel trans_model; 116 | kaldi::AmDiagGmm am_gmm; 117 | 118 | kaldi::Int32VectorWriter words_writer; 119 | kaldi::Int32VectorWriter alignment_writer; 120 | kaldi::CompactLatticeWriter clat_writer; 121 | 122 | fst::SymbolTable *word_syms; 123 | 124 | fst::Fst *decode_fst; 125 | 126 | kaldi::FasterOnlineDecoder *decoder; 127 | 128 | 129 | kaldi::BaseFloat tot_like; 130 | kaldi::int64 frame_count; 131 | kaldi::int32 num_success, num_fail; 132 | 133 | kaldi::Timer timer; 134 | 135 | kaldi::int32 utt_frame_count; 136 | kaldi::int32 utt_number; 137 | 138 | std::string utt_key; 139 | std::string prev_utt_key; 140 | 141 | }; 142 | 143 | #endif 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /src/io/command-line-interface.cc: -------------------------------------------------------------------------------- 1 | #include "command-line-interface.h" 2 | 3 | using namespace std; 4 | using namespace cppa; 5 | 6 | behavior CommandLineInterface::Run(){ 7 | return ( 8 | on(atom("START")) >> [=]() { 9 | aout << "Usage: press enter to toggle microphone ON/OFF." << endl; 10 | aout << " press Q to exit the program." << endl; 11 | char c = '\0'; 12 | while (true) { 13 | c = cin.get(); 14 | if (c == 'q') 15 | break; 16 | switch (c) { 17 | case '\n': 18 | aout << " ++ " << name << ": Sending toggle. " << endl; 19 | send(subscribers, atom("TOGGLE")); 20 | break; 21 | } 22 | } 23 | aout << " ++ " << name << ": Quitting... " << endl; 24 | self->quit(exit_reason::user_shutdown); 25 | }, 26 | on(atom("QUIT")) >> [=]() { 27 | self->quit(exit_reason::user_shutdown); 28 | } 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /src/io/command-line-interface.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_COMMAND_LINE_INTERFACE_H_ 2 | #define BARISTA_COMMAND_LINE_INTERFACE_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | class CommandLineInterface : public ModuleBase { 7 | public: 8 | CommandLineInterface(const std::string& name_, 9 | const cppa::group_ptr& subscribers_, 10 | const boost::property_tree::ptree& config) : 11 | ModuleBase(name_, subscribers_) { 12 | running_state = Run(); 13 | } 14 | 15 | cppa::behavior Run(); 16 | 17 | private: 18 | 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/io/file-list-reader.cc: -------------------------------------------------------------------------------- 1 | #include "file-list-reader.h" 2 | 3 | using namespace std; 4 | using namespace cppa; 5 | 6 | behavior FileListReader::Run(){ 7 | return ( 8 | on(atom("START")) >> [=]() { 9 | ifstream files(file_list.c_str()); 10 | string file_name; 11 | while(getline(files, file_name)) { 12 | if (file_name != "") 13 | send(subscribers, "", file_name); 14 | } 15 | files.close(); 16 | aout << " ++ " << name << ": Finished reading file list: " << file_list << endl; 17 | send(subscribers, atom("DONE")); 18 | self->quit(exit_reason::normal); 19 | }, 20 | on(atom("QUIT")) >> [=]() { 21 | self->quit(exit_reason::user_shutdown); 22 | } 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /src/io/file-list-reader.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_FILE_LIST_READER_H_ 2 | #define BARISTA_FILE_LIST_READER_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | class FileListReader : public ModuleBase { 7 | public: 8 | FileListReader(const std::string& name_, 9 | const cppa::group_ptr& subscribers_, 10 | const boost::property_tree::ptree& config) : 11 | ModuleBase(name_, subscribers_) { 12 | 13 | file_list = config.get(name + ".file_list"); 14 | cppa::aout << " ++ " << name << ": file list: " << file_list << std::endl; 15 | 16 | running_state = Run(); 17 | } 18 | 19 | cppa::behavior Run(); 20 | 21 | private: 22 | std::string file_list; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/io/matrix-writer.cc: -------------------------------------------------------------------------------- 1 | #include "matrix-writer.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | using namespace kaldi; 7 | using namespace cppa; 8 | 9 | behavior MatrixWriter::Run(){ 10 | return ( 11 | on >() >> [=](string key, Matrix data) { 12 | data.Write(*sink, false); 13 | }, 14 | on(atom("UTT_END")) >> [=]() { 15 | *sink << endl; 16 | }, 17 | on(atom("QUIT")) >> [=]() { 18 | self->quit(exit_reason::user_shutdown); 19 | }, 20 | on(atom("DONE")) >> [=]() { 21 | self->quit(exit_reason::normal); 22 | } 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /src/io/matrix-writer.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_MATRIX_WRITER_H_ 2 | #define BARISTA_MATRIX_WRITER_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | class MatrixWriter : public ModuleBase { 7 | public: 8 | MatrixWriter(const std::string& name_, 9 | const cppa::group_ptr& subscribers_, 10 | const boost::property_tree::ptree& config) : 11 | ModuleBase(name_, subscribers_) { 12 | // config 13 | sink_file = config.get(name + ".sink_file"); 14 | 15 | // initialize 16 | sink = new std::ofstream(sink_file.c_str()); 17 | cppa::aout << " ++ " << name << ": sink file: " << sink_file << std::endl; 18 | 19 | running_state = Run(); 20 | } 21 | 22 | ~MatrixWriter() { 23 | sink->close(); 24 | delete sink; 25 | } 26 | 27 | cppa::behavior Run(); 28 | 29 | private: 30 | // configurable members 31 | std::string sink_file; 32 | 33 | // class internal members 34 | std::ofstream* sink; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/io/pcm-reader.cc: -------------------------------------------------------------------------------- 1 | #include "pcm-reader.h" 2 | 3 | using namespace std; 4 | using namespace kaldi; 5 | using namespace cppa; 6 | 7 | // Defines the running behavior: 8 | behavior PCMReader::Run(){ 9 | return ( 10 | on() >> [=](string key, string file_name) { 11 | ReadPCMFile(key, file_name); 12 | }, 13 | on(atom("QUIT")) >> [=]() { 14 | self->quit(exit_reason::user_shutdown); 15 | }, 16 | on(atom("DONE")) >> [=]() { 17 | send(subscribers, atom("DONE")); 18 | self->quit(exit_reason::normal); 19 | } 20 | ); 21 | } 22 | 23 | // Reads a PCM file and publishes its content chunk by chunk. 24 | bool PCMReader::ReadPCMFile(string& key, string& file_name) { 25 | ifstream pcm_file(file_name.c_str(), ios::binary); 26 | while(pcm_file.good()) { 27 | ReadPCMChunk(pcm_file); 28 | send(subscribers, key, data); 29 | } 30 | send(subscribers, atom("UTT_END")); 31 | pcm_file.close(); 32 | return true; 33 | } 34 | 35 | // Reads a chunk of PCM data from the input stream, 36 | // converts it to a vector of floats and stores the result in 'data'. 37 | bool PCMReader::ReadPCMChunk(ifstream& pcm_file) { 38 | char *data_ptr = chunk_data; 39 | pcm_file.read(data_ptr, bytes_per_chunk); 40 | uint32 num_bytes_read = pcm_file.gcount(); // Get how many bytes were read 41 | if (num_bytes_read == 0) 42 | return false; 43 | // TODO: assert: num_bytes_read % bytes_per_sample == 0 44 | uint32 num_samples_read = num_bytes_read / bytes_per_sample; 45 | data.Resize(num_samples_read); 46 | for (uint32 i = 0; i < num_samples_read; ++i) { 47 | switch (bits_per_sample) { 48 | case 8: 49 | data(i) = *data_ptr; 50 | data_ptr++; 51 | break; 52 | case 16: 53 | { 54 | int16 k = *reinterpret_cast(data_ptr); 55 | #ifdef __BIG_ENDIAN__ 56 | KALDI_SWAP2(k); 57 | #endif 58 | data(i) = k; 59 | data_ptr += 2; 60 | break; 61 | } 62 | case 32: 63 | { 64 | int32 k = *reinterpret_cast(data_ptr); 65 | #ifdef __BIG_ENDIAN__ 66 | KALDI_SWAP4(k); 67 | #endif 68 | data(i) = k; 69 | data_ptr += 4; 70 | break; 71 | } 72 | default: 73 | KALDI_ERR << "ReadPCMChunk: bits_per_sample = " << bits_per_sample; 74 | } 75 | } 76 | return true; 77 | } 78 | -------------------------------------------------------------------------------- /src/io/pcm-reader.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_PCM_READER_H_ 2 | #define BARISTA_PCM_READER_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | #include 7 | 8 | class PCMReader : public ModuleBase { 9 | public: 10 | PCMReader(const std::string& name_, 11 | const cppa::group_ptr& subscribers_, 12 | const boost::property_tree::ptree& config) : 13 | ModuleBase(name_, subscribers_) { 14 | // config 15 | bits_per_sample = config.get(name + ".bits_per_sample"); 16 | samples_per_chunk = config.get(name + ".samples_per_chunk"); 17 | 18 | // initialize other member variables 19 | bytes_per_sample = bits_per_sample / 8; 20 | bytes_per_chunk = bytes_per_sample * samples_per_chunk; 21 | chunk_data = new char[bytes_per_chunk]; 22 | data(samples_per_chunk); 23 | 24 | running_state = Run(); 25 | } 26 | 27 | ~PCMReader() { 28 | delete chunk_data; 29 | } 30 | 31 | cppa::behavior Run(); 32 | 33 | private: 34 | bool ReadPCMFile(std::string& key, std::string& file_name); 35 | bool ReadPCMChunk(std::ifstream& pcm_file); 36 | 37 | // configurable members 38 | kaldi::uint32 bits_per_sample; 39 | kaldi::uint32 samples_per_chunk; 40 | 41 | // class internal members 42 | kaldi::uint32 bytes_per_sample; 43 | kaldi::uint32 bytes_per_chunk; 44 | char* chunk_data; // binary chunk read from file 45 | kaldi::Vector data; // output pcm data (represented as floats) 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/io/portaudio-reader.cc: -------------------------------------------------------------------------------- 1 | #include "portaudio-reader.h" 2 | 3 | using namespace std; 4 | using namespace kaldi; 5 | using namespace cppa; 6 | 7 | // Defines the running behavior 8 | behavior PaReader::Run(){ 9 | return ( 10 | on(atom("TOGGLE")) >> [=]() { 11 | if (active) { 12 | audio_src->Read(&data); 13 | send(subscribers, "mic", data); 14 | send(subscribers, atom("UTT_END")); 15 | aout << endl << " ++ " << name << ": Microphone OFF." << endl; 16 | active = false; 17 | } else { 18 | active = true; 19 | aout << " ++ " << name << ": Microphone ON. Listening..." << endl; 20 | } 21 | }, 22 | on(atom("QUIT")) >> [=]() { 23 | self->quit(exit_reason::user_shutdown); 24 | }, 25 | after(std::chrono::milliseconds(200)) >> [=]() { 26 | if (active) { 27 | aout << "." << flush; 28 | audio_src->Read(&data); 29 | send(subscribers, "mic", data); 30 | } 31 | } 32 | ); 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/io/portaudio-reader.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_PORTAUDIO_READER_H_ 2 | #define BARISTA_PORTAUDIO_READER_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | #include "matrix/kaldi-vector.h" 7 | #include "online/online-audio-source.h" 8 | 9 | class PaReader : public ModuleBase { 10 | public: 11 | PaReader(const std::string& name_, 12 | const cppa::group_ptr& subscribers_, 13 | const boost::property_tree::ptree& config) : 14 | ModuleBase(name_, subscribers_) { 15 | // config 16 | timeout = 0; 17 | sample_freq = 16000; // Input sampling frequency is fixed to 16KHz 18 | ring_size = config.get(name + ".ring_size", 32768); 19 | report_int = config.get(name + ".report_int", 4); 20 | samples_per_chunk = 4560; // = frame_size_ + (nvec - 1) * frame_shift_ 21 | 22 | // initialize other member variables 23 | audio_src = new kaldi::OnlinePaSource(timeout, sample_freq, ring_size, 24 | report_int); 25 | data.Resize(samples_per_chunk); 26 | 27 | active = false; 28 | 29 | running_state = Run(); 30 | } 31 | 32 | ~PaReader() { 33 | delete audio_src; 34 | } 35 | 36 | cppa::behavior Run(); 37 | 38 | private: 39 | 40 | // configurable members 41 | kaldi::uint32 timeout; // Audio acquisition timeout 42 | kaldi::int32 sample_freq; // Input sampling frequency 43 | kaldi::int32 ring_size; // PortAudio's internal ring buffer size in bytes 44 | kaldi::int32 report_int; // Report interval for PortAudio buffer overflows 45 | // in number of feature batches 46 | kaldi::int32 samples_per_chunk; // number of features decoded in one go 47 | 48 | // class internal members 49 | kaldi::OnlinePaSource* audio_src; 50 | kaldi::Vector data; // output pcm data (represented as floats) 51 | 52 | bool active; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/io/vector-writer.cc: -------------------------------------------------------------------------------- 1 | #include "vector-writer.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | using namespace kaldi; 7 | using namespace cppa; 8 | 9 | behavior VectorWriter::Run(){ 10 | return ( 11 | on >() >> [=](string key, Vector data) { 12 | data.Write(*sink, false); 13 | }, 14 | on(atom("UTT_END")) >> [=]() { 15 | *sink << endl; 16 | }, 17 | on(atom("QUIT")) >> [=]() { 18 | self->quit(exit_reason::user_shutdown); 19 | }, 20 | on(atom("DONE")) >> [=]() { 21 | self->quit(exit_reason::normal); 22 | } 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /src/io/vector-writer.h: -------------------------------------------------------------------------------- 1 | #ifndef BARISTA_VECTOR_WRITER_H_ 2 | #define BARISTA_VECTOR_WRITER_H_ 3 | 4 | #include "base/module-base.h" 5 | 6 | class VectorWriter : public ModuleBase { 7 | public: 8 | VectorWriter(const std::string& name_, 9 | const cppa::group_ptr& subscribers_, 10 | const boost::property_tree::ptree& config) : 11 | ModuleBase(name_, subscribers_) { 12 | // config 13 | sink_file = config.get(name + ".sink_file"); 14 | 15 | // initialize 16 | sink = new std::ofstream(sink_file.c_str()); 17 | cppa::aout << " ++ " << name << ": sink file: " << sink_file << std::endl; 18 | 19 | running_state = Run(); 20 | } 21 | 22 | ~VectorWriter() { 23 | sink->close(); 24 | delete sink; 25 | } 26 | 27 | cppa::behavior Run(); 28 | 29 | private: 30 | // configurable members 31 | std::string sink_file; 32 | 33 | // class internal members 34 | std::ofstream* sink; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | # SHELL += -x 2 | 3 | KALDI_VERSION = 3755 4 | CPPA_VERSION = V0.8.1 5 | 6 | # We do not support compiling libcppa with clang. 7 | COMPILER = $(shell $(CXX) -v 2>&1 ) 8 | ifeq ($(findstring clang,$(COMPILER)),clang) 9 | ERR_IF_CLANG = $(error Clang is not supported for this target. \ 10 | Use g++ >= 4.7 instead (g++-4.8 recommended).) 11 | endif 12 | 13 | ifeq ($(findstring GCC,$(COMPILER)),GCC) 14 | GCC_VERSION := $(shell $(CXX) -dumpversion) 15 | GCC_NUMBER := $(shell echo $(GCC_VERSION) | cut -f1,2 -d. | \ 16 | sed 's/\./ /' | xargs printf "%d%02d") 17 | GCC_LT_47 := $(shell expr $(GCC_NUMBER) \< 407) 18 | ifeq ("$(GCC_LT_47)","1") 19 | ERR_IF_GCC_LT_47 = $(error g++ $(GCC_VERSION) is not supported for this \ 20 | target. Use g++ >= 4.7 instead \ 21 | (g++-4.8 recommended).) 22 | endif 23 | endif 24 | 25 | 26 | INSTALLED_KALDI_VERSION := $(shell [ -d kaldi/.svn ] && svnversion -n kaldi) 27 | UPDATE_KALDI := $(shell [ "$(INSTALLED_KALDI_VERSION)" != "" ] && \ 28 | [ $(KALDI_VERSION) -ne $(INSTALLED_KALDI_VERSION) ] \ 29 | && rm -f kaldi/.checkout && echo true) 30 | 31 | INSTALLED_CPPA_VERSION := $(shell [ -d libcppa/.git ] && cd libcppa && \ 32 | git describe) 33 | UPDATE_CPPA := $(shell [ "$(INSTALLED_CPPA_VERSION)" != "" ] && \ 34 | [ "$(CPPA_VERSION)" != "$(INSTALLED_CPPA_VERSION)" ] \ 35 | && rm -f libcppa/.checkout && echo true) 36 | 37 | print-%: 38 | @echo '$*=$($*)' 39 | 40 | all: kaldi libcppa graphviz 41 | 42 | .PHONY: clean 43 | clean: kaldi/clean graphviz/clean libcppa/clean 44 | 45 | .PHONY: kaldi/clean 46 | kaldi/clean: 47 | $(MAKE) -C kaldi/tools clean; $(MAKE) -C kaldi/src clean; \ 48 | rm -f kaldi/src/.install kaldi/src/.depend kaldi/src/.configure; \ 49 | rm -f kaldi/tools/.install kaldi/tools/portaudio/.install; \ 50 | rm -rf kaldi/tools/portaudio; 51 | 52 | .PHONY: libcppa/clean 53 | libcppa/clean: 54 | rm -rf libcppa/build libcppa/.install libcppa/.configure 55 | 56 | .PHONY: graphviz/clean 57 | graphviz/clean: 58 | $(MAKE) -C graphviz clean && rm -f graphviz/.install graphviz/.configure 59 | 60 | .PHONY: distclean 61 | distclean: 62 | rm -rf kaldi graphviz libcppa 63 | 64 | 65 | .PHONY: kaldi 66 | kaldi: kaldi/src/.install 67 | 68 | kaldi/src/.install: kaldi/src/.depend kaldi/tools/portaudio/.install 69 | cd kaldi/src && $(MAKE) CXX=$(CXX) && $(MAKE) online CXX=$(CXX) && \ 70 | touch .install 71 | 72 | kaldi/src/.depend: kaldi/src/.configure 73 | $(MAKE) -C kaldi/src depend CXX=$(CXX) && touch $@ 74 | 75 | kaldi/src/.configure: kaldi/tools/.install 76 | cd kaldi/src && ./configure && touch .configure 77 | 78 | kaldi/tools/portaudio/.install: kaldi/.checkout 79 | cd kaldi/tools && ./install_portaudio.sh && touch portaudio/.install 80 | 81 | kaldi/tools/.install: kaldi/.checkout 82 | $(MAKE) -C kaldi/tools CXX=$(CXX) && touch $@ 83 | 84 | kaldi/.checkout: 85 | ifeq ($(UPDATE_KALDI),true) 86 | @echo 'Updating Kaldi: $(INSTALLED_KALDI_VERSION) -> $(KALDI_VERSION)' && \ 87 | svn co svn://svn.code.sf.net/p/kaldi/code/trunk@$(KALDI_VERSION) kaldi && \ 88 | touch $@ 89 | else 90 | svn co svn://svn.code.sf.net/p/kaldi/code/trunk@$(KALDI_VERSION) kaldi && \ 91 | touch $@ 92 | endif 93 | 94 | 95 | .PHONY: libcppa 96 | libcppa: libcppa/.install 97 | 98 | libcppa/.install: libcppa/.configure 99 | cd libcppa && $(MAKE) && $(MAKE) install && \ 100 | touch .install 101 | 102 | libcppa/.configure: libcppa/.checkout 103 | $(ERR_IF_CLANG) 104 | $(ERR_IF_GCC_LT_47) 105 | cd libcppa && \ 106 | rm -rf build/CMakeFiles && \ 107 | ./configure --prefix=`pwd` --with-gcc=$(CXX) --build-static \ 108 | --disable-context-switching --no-protobuf-examples && touch .configure 109 | 110 | libcppa/.checkout: 111 | ifeq ($(UPDATE_CPPA),true) 112 | @echo 'Updating libcppa: $(INSTALLED_CPPA_VERSION) -> $(CPPA_VERSION)' && \ 113 | cd libcppa && git checkout -- CMakeLists.txt && git checkout master && \ 114 | git pull && git checkout $(CPPA_VERSION) && \ 115 | sed -i.bk '2s:cppa CXX:cppa C CXX:' CMakeLists.txt && touch .checkout 116 | else 117 | git clone git://github.com/Neverlord/libcppa.git && \ 118 | cd libcppa && git checkout $(CPPA_VERSION) && \ 119 | sed -i.bk '2s:cppa CXX:cppa C CXX:' CMakeLists.txt && touch .checkout 120 | endif 121 | 122 | 123 | .PHONY: graphviz 124 | graphviz: graphviz/.install 125 | 126 | graphviz/.install: graphviz/.configure 127 | cd graphviz && $(MAKE) && $(MAKE) install && \ 128 | touch .install 129 | 130 | graphviz/.configure: graphviz/.checkout 131 | cd graphviz && \ 132 | ./configure --prefix=`pwd` --without-x CC=$(CC) CXX=$(CXX) && \ 133 | touch .configure 134 | 135 | graphviz/.checkout: 136 | wget -T 10 -t 3 --no-check-certificate \ 137 | http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.36.0.tar.gz \ 138 | && tar xozf graphviz-2.36.0.tar.gz && rm -f graphviz-2.36.0.tar.gz && \ 139 | mv graphviz-2.36.0 graphviz && touch $@ 140 | --------------------------------------------------------------------------------