mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-26 11:47:53 +00:00
Merge pull request #2856 from signalwire/pocketsphinx
[mod_pocketsphinx] Use system libraries when possible
This commit is contained in:
commit
5d5104f9fa
20
configure.ac
20
configure.ac
@ -1563,6 +1563,26 @@ PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2], [
|
|||||||
AM_CONDITIONAL([HAVE_AMQP], [false])
|
AM_CONDITIONAL([HAVE_AMQP], [false])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES([SPHINXBASE], [sphinxbase >= 5],[
|
||||||
|
AM_CONDITIONAL([HAVE_SPHINXBASE],[true])],[
|
||||||
|
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SPHINXBASE],[false])])
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES([POCKETSPHINX], [pocketsphinx >= 5],[
|
||||||
|
AM_CONDITIONAL([HAVE_POCKETSPHINX],[true])
|
||||||
|
# Extract the version of pocketsphinx
|
||||||
|
POCKETSPHINX_VERSION=`$PKG_CONFIG --modversion pocketsphinx`
|
||||||
|
AC_DEFINE_UNQUOTED([POCKETSPHINX_VERSION], ["$POCKETSPHINX_VERSION"], [Version of pocketsphinx])
|
||||||
|
AC_MSG_NOTICE([POCKETSPHINX_VERSION is $POCKETSPHINX_VERSION])
|
||||||
|
# Parse major version but take only first digit for now
|
||||||
|
POCKETSPHINX_MAJOR_VERSION=`echo $POCKETSPHINX_VERSION | cut -c1`
|
||||||
|
AC_MSG_NOTICE([POCKETSPHINX_MAJOR_VERSION is $POCKETSPHINX_MAJOR_VERSION])
|
||||||
|
AC_DEFINE_UNQUOTED([POCKETSPHINX_MAJOR_VERSION], [$POCKETSPHINX_MAJOR_VERSION], [Major version of pocketsphinx])
|
||||||
|
AC_SUBST(POCKETSPHINX_MAJOR_VERSION)
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
AM_CONDITIONAL([HAVE_POCKETSPHINX],[false])
|
||||||
|
])
|
||||||
|
|
||||||
PKG_CHECK_MODULES([H2O], [libh2o-evloop >= 0.11.0],[
|
PKG_CHECK_MODULES([H2O], [libh2o-evloop >= 0.11.0],[
|
||||||
AM_CONDITIONAL([HAVE_H2O],[true])],[
|
AM_CONDITIONAL([HAVE_H2O],[true])],[
|
||||||
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_H2O],[false])])
|
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_H2O],[false])])
|
||||||
|
1
debian/control-modules
vendored
1
debian/control-modules
vendored
@ -231,6 +231,7 @@ Build-Depends: libflite-dev | flite1-dev
|
|||||||
Module: asr_tts/mod_pocketsphinx
|
Module: asr_tts/mod_pocketsphinx
|
||||||
Description: mod_pocketsphinx
|
Description: mod_pocketsphinx
|
||||||
Adds mod_pocketsphinx.
|
Adds mod_pocketsphinx.
|
||||||
|
Build-Depends: libsphinxbase-dev, libpocketsphinx-dev
|
||||||
|
|
||||||
Module: asr_tts/mod_tts_commandline
|
Module: asr_tts/mod_tts_commandline
|
||||||
Description: mod_tts_commandline
|
Description: mod_tts_commandline
|
||||||
|
@ -16,11 +16,16 @@ SPHINXMODEL=communicator_semi_6000_20080321
|
|||||||
|
|
||||||
mod_LTLIBRARIES = mod_pocketsphinx.la
|
mod_LTLIBRARIES = mod_pocketsphinx.la
|
||||||
mod_pocketsphinx_la_SOURCES = mod_pocketsphinx.c
|
mod_pocketsphinx_la_SOURCES = mod_pocketsphinx.c
|
||||||
mod_pocketsphinx_la_CFLAGS = $(AM_CFLAGS) -I$(SPHINXBASE_DIR)/include -I$(POCKETSPHINX_DIR)/include
|
|
||||||
mod_pocketsphinx_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
|
||||||
mod_pocketsphinx_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
mod_pocketsphinx_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
||||||
|
if HAVE_POCKETSPHINX
|
||||||
|
mod_pocketsphinx_la_CFLAGS = $(AM_CFLAGS) $(SPHINXBASE_CFLAGS) $(POCKETSPHINX_CFLAGS) -DPOCKETSPHINX_MAJOR_VERSION=$(POCKETSPHINX_MAJOR_VERSION)
|
||||||
|
mod_pocketsphinx_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LDFLAGS) $(SPHINXBASE_LDFLAGS)
|
||||||
|
else
|
||||||
|
mod_pocketsphinx_la_CFLAGS = $(AM_CFLAGS) -I$(SPHINXBASE_DIR)/include -I$(POCKETSPHINX_DIR)/include -DPOCKETSPHINX_MAJOR_VERSION=0
|
||||||
|
mod_pocketsphinx_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
||||||
|
|
||||||
BUILT_SOURCES=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
BUILT_SOURCES=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
||||||
|
endif
|
||||||
|
|
||||||
$(SPHINXBASE_DIR):
|
$(SPHINXBASE_DIR):
|
||||||
$(GETLIB) $(SPHINXBASE).tar.gz
|
$(GETLIB) $(SPHINXBASE).tar.gz
|
||||||
@ -66,5 +71,8 @@ $(DESTDIR)$(grammardir)/model/communicator:
|
|||||||
dictionary:
|
dictionary:
|
||||||
@install -m0644 $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic
|
@install -m0644 $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic
|
||||||
|
|
||||||
|
if HAVE_POCKETSPHINX
|
||||||
|
install-data-local: $(POCKETSPHINX_DIR) $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
|
||||||
|
else
|
||||||
install-data-local: $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
|
install-data-local: $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
|
||||||
|
endif
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<Import Project="$(SolutionDir)w32\pocketsphinx.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
@ -77,7 +78,7 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;..\..\..\..\libs\pocketsphinx-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -103,7 +104,7 @@
|
|||||||
</Midl>
|
</Midl>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;..\..\..\..\libs\pocketsphinx-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -126,7 +127,7 @@
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;..\..\..\..\libs\pocketsphinx-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
@ -156,7 +157,7 @@
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;..\..\..\..\libs\pocketsphinx-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..\..\libs\sphinxbase-0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_POCKETSPHINX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
@ -203,7 +203,12 @@ static switch_status_t pocketsphinx_asr_load_grammar(switch_asr_handle_t *ah, co
|
|||||||
}
|
}
|
||||||
switch_mutex_unlock(ps->flag_mutex);
|
switch_mutex_unlock(ps->flag_mutex);
|
||||||
|
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
ps_start_utt(ps->ps, NULL);
|
ps_start_utt(ps->ps, NULL);
|
||||||
|
#else
|
||||||
|
ps_start_utt(ps->ps);
|
||||||
|
#endif
|
||||||
|
|
||||||
ps->silence_time = switch_micro_time_now();
|
ps->silence_time = switch_micro_time_now();
|
||||||
switch_clear_flag(ps, PSFLAG_START_OF_SPEECH);
|
switch_clear_flag(ps, PSFLAG_START_OF_SPEECH);
|
||||||
switch_clear_flag(ps, PSFLAG_NOINPUT_TIMEOUT);
|
switch_clear_flag(ps, PSFLAG_NOINPUT_TIMEOUT);
|
||||||
@ -338,22 +343,38 @@ static switch_status_t pocketsphinx_asr_feed(switch_asr_handle_t *ah, void *data
|
|||||||
char const *hyp;
|
char const *hyp;
|
||||||
|
|
||||||
switch_mutex_lock(ps->flag_mutex);
|
switch_mutex_lock(ps->flag_mutex);
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
|
if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
|
||||||
|
#else
|
||||||
|
if ((hyp = ps_get_hyp(ps->ps, &ps->score))) {
|
||||||
|
#endif
|
||||||
if (!zstr(hyp)) {
|
if (!zstr(hyp)) {
|
||||||
ps_end_utt(ps->ps);
|
ps_end_utt(ps->ps);
|
||||||
switch_clear_flag(ps, PSFLAG_READY);
|
switch_clear_flag(ps, PSFLAG_READY);
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
|
if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
|
||||||
|
#else
|
||||||
|
if ((hyp = ps_get_hyp(ps->ps, &ps->score))) {
|
||||||
|
#endif
|
||||||
if (zstr(hyp)) {
|
if (zstr(hyp)) {
|
||||||
if (!switch_test_flag(ps, PSFLAG_SPEECH_TIMEOUT)) {
|
if (!switch_test_flag(ps, PSFLAG_SPEECH_TIMEOUT)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n");
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
ps_start_utt(ps->ps, NULL);
|
ps_start_utt(ps->ps, NULL);
|
||||||
|
#else
|
||||||
|
ps_start_utt(ps->ps);
|
||||||
|
#endif
|
||||||
switch_set_flag(ps, PSFLAG_READY);
|
switch_set_flag(ps, PSFLAG_READY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* get match and confidence */
|
/* get match and confidence */
|
||||||
int32_t conf;
|
int32_t conf;
|
||||||
|
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
conf = ps_get_prob(ps->ps, &ps->uttid);
|
conf = ps_get_prob(ps->ps, &ps->uttid);
|
||||||
|
#else
|
||||||
|
conf = ps_get_prob(ps->ps);
|
||||||
|
#endif
|
||||||
|
|
||||||
ps->confidence = (conf + 20000) / 200;
|
ps->confidence = (conf + 20000) / 200;
|
||||||
|
|
||||||
@ -427,7 +448,11 @@ static switch_status_t pocketsphinx_asr_resume(switch_asr_handle_t *ah)
|
|||||||
if (!switch_test_flag(ps, PSFLAG_READY)) {
|
if (!switch_test_flag(ps, PSFLAG_READY)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Manually Resuming\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Manually Resuming\n");
|
||||||
|
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
if (ps_start_utt(ps->ps, NULL)) {
|
if (ps_start_utt(ps->ps, NULL)) {
|
||||||
|
#else
|
||||||
|
if (ps_start_utt(ps->ps)) {
|
||||||
|
#endif
|
||||||
status = SWITCH_STATUS_GENERR;
|
status = SWITCH_STATUS_GENERR;
|
||||||
} else {
|
} else {
|
||||||
switch_set_flag(ps, PSFLAG_READY);
|
switch_set_flag(ps, PSFLAG_READY);
|
||||||
@ -474,7 +499,11 @@ static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, cha
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto Resuming\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto Resuming\n");
|
||||||
switch_set_flag(ps, PSFLAG_READY);
|
switch_set_flag(ps, PSFLAG_READY);
|
||||||
|
|
||||||
|
#if POCKETSPHINX_MAJOR_VERSION < 1
|
||||||
ps_start_utt(ps->ps, NULL);
|
ps_start_utt(ps->ps, NULL);
|
||||||
|
#else
|
||||||
|
ps_start_utt(ps->ps);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
20
w32/pocketsphinx-version.props
Normal file
20
w32/pocketsphinx-version.props
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Project="basedir.props" Condition=" '$(BaseDirImported)' == ''"/>
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros">
|
||||||
|
<pocketsphinxMajorVersion>0</pocketsphinxMajorVersion>
|
||||||
|
<pocketsphinxVersion>0.7</pocketsphinxVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<pocketsphinxVersionImported>true</pocketsphinxVersionImported>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<BuildMacro Include="pocketsphinxVersion">
|
||||||
|
<Value>$(pocketsphinxVersion)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
18
w32/pocketsphinx.props
Normal file
18
w32/pocketsphinx.props
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Project="pocketsphinx-version.props" Condition=" '$(pocketsphinxVersionImported)' == '' "/>
|
||||||
|
</ImportGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Label="UserMacros">
|
||||||
|
<pocketsphinx_libDir>$(BaseDir)libs\pocketsphinx-$(pocketsphinxVersion)</pocketsphinx_libDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<AdditionalIncludeDirectories>$(pocketsphinx_libDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>POCKETSPHINX_MAJOR_VERSION=$(pocketsphinxMajorVersion);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user