Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Initial CMake and project setup
#

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
SET(PROJECT_NAME sphinxbase)
PROJECT(${PROJECT_NAME})

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/build-data)
set(CMAKE_MACOSX_RPATH FALSE)

#
# Setup compiler flags
#

if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE CACHE Release FORCE)
endif()

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -std=gnu11 -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=gnu11 -O3")

#
# Final project settings
#
configure_file("${CMAKE_SOURCE_DIR}/include/sphinx_config.h.in" "${CMAKE_SOURCE_DIR}/include/sphinx_config.h")
INCLUDE_DIRECTORIES(include)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test EXCLUDE_FROM_ALL)

ADD_LIBRARY(${PROJECT_NAME}_static STATIC
$<TARGET_OBJECTS:libsphinxad>
$<TARGET_OBJECTS:fe>
$<TARGET_OBJECTS:feat>
$<TARGET_OBJECTS:lm>
$<TARGET_OBJECTS:util>
)

ADD_LIBRARY(${PROJECT_NAME} SHARED
$<TARGET_OBJECTS:libsphinxad>
$<TARGET_OBJECTS:fe>
$<TARGET_OBJECTS:feat>
$<TARGET_OBJECTS:lm>
$<TARGET_OBJECTS:util>
)

TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS})
51 changes: 51 additions & 0 deletions cmake/FindOSS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# - Find Oss
# Find Oss headers and libraries.
#
# OSS_INCLUDE_DIR - where to find soundcard.h, etc.
# OSS_FOUND - True if Oss found.

# OSS is not for APPLE or WINDOWS

IF(APPLE OR WIN32)
RETURN()
ENDIF()

FIND_PATH(LINUX_OSS_INCLUDE_DIR "linux/soundcard.h"
"/usr/include" "/usr/local/include"
)

FIND_PATH(SYS_OSS_INCLUDE_DIR "sys/soundcard.h"
"/usr/include" "/usr/local/include"
)

FIND_PATH(MACHINE_OSS_INCLUDE_DIR "machine/soundcard.h"
"/usr/include" "/usr/local/include"
)

SET(OSS_FOUND FALSE)

IF(LINUX_OSS_INCLUDE_DIR)
SET(OSS_FOUND TRUE)
SET(OSS_INCLUDE_DIR ${LINUX_OSS_INCLUDE_DIR})
SET(HAVE_LINUX_SOUNDCARD_H 1)
ENDIF()

IF(SYS_OSS_INCLUDE_DIR)
SET(OSS_FOUND TRUE)
SET(OSS_INCLUDE_DIR ${SYS_OSS_INCLUDE_DIR})
SET(HAVE_SYS_SOUNDCARD_H 1)
ENDIF()

IF(MACHINE_OSS_INCLUDE_DIR)
SET(OSS_FOUND TRUE)
SET(OSS_INCLUDE_DIR ${MACHINE_OSS_INCLUDE_DIR})
SET(HAVE_MACHINE_SOUNDCARD_H 1)
ENDIF()

MARK_AS_ADVANCED (
OSS_FOUND
OSS_INCLUDE_DIR
LINUX_OSS_INCLUDE_DIR
SYS_OSS_INCLUDE_DIR
MACHINE_OSS_INCLUDE_DIR
)
43 changes: 43 additions & 0 deletions cmake/FindPulseAudio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# - Find PulseAudio includes and libraries
#
# PULSEAUDIO_FOUND - True if PULSEAUDIO_INCLUDE_DIR &
# PULSEAUDIO_LIBRARY are found
# PULSEAUDIO_LIBRARIES - Set when PULSEAUDIO_LIBRARY is found
# PULSEAUDIO_INCLUDE_DIRS - Set when PULSEAUDIO_INCLUDE_DIR is found
#
# PULSEAUDIO_INCLUDE_DIR - where to find pulse/pulseaudio.h, etc.
# PULSEAUDIO_LIBRARY - the pulse library
# PULSEAUDIO_VERSION_STRING - the version of PulseAudio found
#

find_path(PULSEAUDIO_INCLUDE_DIR
NAMES pulse/pulseaudio.h
DOC "The PulseAudio include directory"
)

find_library(PULSEAUDIO_LIBRARY
NAMES pulse
DOC "The PulseAudio library"
)

if(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h")
file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulse_version_str
REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)")

string(REGEX REPLACE "^.*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*$" "\\1"
PULSEAUDIO_VERSION_STRING "${pulse_version_str}")
unset(pulse_version_str)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PulseAudio
REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR
VERSION_VAR PULSEAUDIO_VERSION_STRING
)

if(PULSEAUDIO_FOUND)
set(PULSEAUDIO_LIBRARIES ${PULSEAUDIO_LIBRARY})
set(PULSEAUDIO_INCLUDE_DIRS ${PULSEAUDIO_INCLUDE_DIR})
endif()

mark_as_advanced(PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY)
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_subdirectory(libsphinxad)
add_subdirectory(libsphinxbase)
#add_subdirectory(sphinx_adtools)
#add_subdirectory(sphinx_cepview)
#add_subdirectory(sphinx_fe)
#add_subdirectory(sphinx_jsgf2fsg)
#add_subdirectory(sphinx_lmtools)
33 changes: 33 additions & 0 deletions src/libsphinxad/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include_directories(${CMAKE_SOURCE_DIR}/include/sphinxbase)

if (WIN32)
set(SOURCES ${SOURCES} ad_win32.c)
set(LIBS winmm CACHE INTERNAL "libs")
endif ()

find_package(PulseAudio)
if (PULSEAUDIO_FOUND)
set(SOURCES ${SOURCES} ad_pulse.c)
set(LIBS ${PULSEAUDIO_LIBRARIES} CACHE INTERNAL "libs")
endif()

find_package(OSS)
if (OSS_FOUND)
set(SOURCES ${SOURCES} ad_oss.c )
endif()

find_package(OpenAL)
if (OPENAL_FOUND)
set(SOURCES ${SOURCES} ad_openal.c)
set(LIBS ${OPENAL_LIBRARY} CACHE INTERNAL "libs")
include_directories(${OPENAL_INCLUDE_DIR})
endif()

find_package(ALSA)
if (ALSA_FOUND)
set(SOURCES ${SOURCES} ad_alsa.c)
set(LIBS ${ALSA_LIBRARIES} CACHE INTERNAL "libs")
endif()

add_library(libsphinxad OBJECT ${SOURCES})
set_property(TARGET libsphinxad PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1 change: 0 additions & 1 deletion src/libsphinxad/ad_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#include <string.h>
#include <alsa/asoundlib.h>
#include <errno.h>
#include <config.h>
#include <unistd.h>

#include "prim_type.h"
Expand Down
1 change: 0 additions & 1 deletion src/libsphinxad/ad_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

#include <stdio.h>
#include <string.h>
#include <config.h>

#include "prim_type.h"
#include "ad.h"
Expand Down
14 changes: 3 additions & 11 deletions src/libsphinxad/ad_openal.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
* ====================================================================
*
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>

Expand Down Expand Up @@ -113,16 +112,9 @@ ad_read(ad_rec_t * r, int16 * buf, int32 max)
}


int32
ad_close(ad_rec_t * r)
int32 ad_close(ad_rec_t *r)
{
ALCboolean isClosed;

isClosed = alcCaptureCloseDevice(r -> device);
ALCboolean isClosed = alcCaptureCloseDevice(r -> device);

if (isClosed) {
return 0;
} else {
return -1;
}
return isClosed ? 0 : -1;
}
1 change: 0 additions & 1 deletion src/libsphinxad/ad_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
#include <config.h>

#include "prim_type.h"
#include "ad.h"
Expand Down
1 change: 0 additions & 1 deletion src/libsphinxad/ad_pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#include <stdio.h>
#include <string.h>
#include <config.h>

#include <pulse/pulseaudio.h>
#include <pulse/simple.h>
Expand Down
4 changes: 4 additions & 0 deletions src/libsphinxbase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_subdirectory(fe)
add_subdirectory(feat)
add_subdirectory(lm)
add_subdirectory(util)
23 changes: 23 additions & 0 deletions src/libsphinxbase/fe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SET(SOURCES fe_interface.c
fe_internal.h
fe_noise.c
fe_noise.h
fe_prespch_buf.c
fe_prespch_buf.h
fe_sigproc.c
fe_type.h
fe_warp.c
fe_warp.h
fe_warp_affine.c
fe_warp_affine.h
fe_warp_inverse_linear.c
fe_warp_inverse_linear.h
fe_warp_piecewise_linear.c
fe_warp_piecewise_linear.h
fixlog.c
yin.c
)

add_library(fe OBJECT ${SOURCES})

set_property(TARGET fe PROPERTY POSITION_INDEPENDENT_CODE TRUE)
9 changes: 9 additions & 0 deletions src/libsphinxbase/feat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SET(SOURCES agc.c
cmn.c
cmn_live.c
feat.c
lda.c
)

add_library(feat OBJECT ${SOURCES})
set_property(TARGET feat PROPERTY POSITION_INDEPENDENT_CODE TRUE)
14 changes: 14 additions & 0 deletions src/libsphinxbase/lm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SET(SOURCES fsg_model.c
jsgf.c
jsgf_parser.c
jsgf_scanner.c
lm_trie.c
lm_trie_quant.c
ngram_model.c
ngram_model_set.c
ngram_model_trie.c
ngrams_raw.c
)

add_library(lm OBJECT ${SOURCES})
set_property(TARGET lm PROPERTY POSITION_INDEPENDENT_CODE TRUE)
10 changes: 2 additions & 8 deletions src/libsphinxbase/lm/lm_trie_quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,8 @@ lm_trie_quant_mwrite(lm_trie_quant_t * quant, bitarr_address_t address,
int order_minus_2, float prob, float backoff)
{
bitarr_write_int57(address, quant->prob_bits + quant->bo_bits,
(uint64) ((bins_encode
(&quant->tables[order_minus_2][0],
prob) << quant->
bo_bits) | bins_encode(&quant->
tables
[order_minus_2]
[1],
backoff)));
(((int)bins_encode(&quant->tables[order_minus_2][0],prob) << quant->bo_bits)
| (int)bins_encode(&quant-> tables[order_minus_2][1], backoff)));
}

void
Expand Down
34 changes: 34 additions & 0 deletions src/libsphinxbase/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
SET(SOURCES bio.c
bitarr.c
bitvec.c
blas_lite.c
case.c
ckd_alloc.c
cmd_ln.c
dtoa.c
err.c
f2c_lite.c
filename.c
genrand.c
glist.c
hash_table.c
heap.c
listelem_alloc.c
logmath.c
matrix.c
mmio.c
pio.c
priority_queue.c
profile.c
sbthread.c
slamch.c
slapack_lite.c
strfuncs.c
)

if (WIN32)
set(SOURCES ${SOURCES} errno.c)
endif ()

add_library(util OBJECT ${SOURCES})
set_property(TARGET util PROPERTY POSITION_INDEPENDENT_CODE TRUE)
4 changes: 2 additions & 2 deletions src/libsphinxbase/util/bitarr.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static uint64 read_off(bitarr_address_t address)

uint64 bitarr_read_int57(bitarr_address_t address, uint8 length, uint64 mask)
{
return (read_off(address) >> get_shift(address.offset & 7, length)) & mask;
return ((int)read_off(address) >> get_shift(address.offset & 7, length)) & (int)mask;
}

void bitarr_write_int57(bitarr_address_t address, uint8 length, uint64 value)
Expand All @@ -93,7 +93,7 @@ void bitarr_write_int57(bitarr_address_t address, uint8 length, uint64 value)
value64 |= (value << get_shift(address.offset & 7, length));
memcpy(base_off, &value64, sizeof(value64));
#else
*(uint64 *)((uint8 *)(address.base) + (address.offset >> 3)) |= (value << get_shift(address.offset & 7, length));
*(int *)((uint8 *)(address.base) + (address.offset >> 3)) |= ((int)value << get_shift(address.offset & 7, length));
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsphinxbase/util/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# ifndef _WIN32_WCE
# include <time.h>
# endif
#elif defined(HAVE_UNISTD_H) /* I know this, this is Unix... */
#else
# include <unistd.h>
# include <sys/time.h>
# include <sys/resource.h>
Expand Down
Loading