提交 6d8d1a09 authored 作者: Brian West's avatar Brian West

commit e8f60761378fe392d80e89d0e3481316119e9809

Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Tue Jun 30 14:44:09 2009 +0000

    Further build and install integration
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1030 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 5b410e0dfc1852ee5c0d56d64b326d5130aed18a
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Tue Jun 30 13:24:27 2009 +0000

    Added utility project (preparesphinx) to copy the stuff pocketsphinx requires to run
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1029 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 2457575de160b378affdfa7a37cac1282d0024ca
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Tue Jun 30 13:18:59 2009 +0000

    Added a few more comments in config file
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1028 f001bc3a-424a-0410-80a0-a715b8f413a8

commit ffc40b15b409a79bdea286898ad1e8694fc1623c
Author: garmt.noname@gmail.com <garmt.noname@gmail.com@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Tue Jun 30 10:38:54 2009 +0000

    Added resampling to 8kHz so that it works with freeswitch (specify only L16/96/8000 codec in profile of media_engine/rtpfactory).
    Changed logging to DEBUG level rather than INFO.
    Added channel_guard for stop response.
    
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1027 f001bc3a-424a-0410-80a0-a715b8f413a8

commit d11439611186b46f1bfabc036b7e5d76f33f8b0e
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Mon Jun 29 19:46:54 2009 +0000

    Added entries for PocketSphinx (mrcppocketsphinx) and Flite (mrcpflite) plugins into unimrcpserver.xml (disabled by default)
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1026 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 63bc73426ba4efdf648a28cd3c1ff1daaef5bb49
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Mon Jun 29 15:04:01 2009 +0000

    Added enumeration of pocketsphinx models (narrowband, wideband), supported wideband either
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1025 f001bc3a-424a-0410-80a0-a715b8f413a8

commit d11439611186b46f1bfabc036b7e5d76f33f8b0e
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Mon Jun 29 19:46:54 2009 +0000

    Added entries for PocketSphinx (mrcppocketsphinx) and Flite (mrcpflite) plugins into unimrcpserver.xml (disabled by default)

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1026 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 63bc73426ba4efdf648a28cd3c1ff1daaef5bb49
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Mon Jun 29 15:04:01 2009 +0000

    Added enumeration of pocketsphinx models (narrowband, wideband), supported wideband either

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1025 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 04970484e4357e2a1c3c4385840640caada33468
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Mon Jun 29 13:21:35 2009 +0000

    Removed engine->guard, as all relevant calls are made within the context of the same thread

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1024 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 9bac2f3abdcfea5397aca4b86e209af090631e7a
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Mon Jun 29 13:15:30 2009 +0000

    Initialized 16kHz codec descriptor for flite channel, since available flite voice are in 16kHz.

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1023 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 4e902eb985b433416723f15646d3e99d385d18cb
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jun 28 20:05:22 2009 +0000

    Do not create bridge if resampling is required.
    Several sampling rates are supported, but there is no resampling yet.

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1022 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 6d35b1246a7061e4c8f3f608bb17e146870d63bd
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jun 28 18:14:25 2009 +0000

    Added makefile target to install pocketsphinx.xml with make install

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1021 f001bc3a-424a-0410-80a0-a715b8f413a8

commit c2b75c89d57c02bd8d4360aebcb7406ecbf90eb0
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jun 28 18:10:01 2009 +0000

    Set svn props (eol:native)

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1020 f001bc3a-424a-0410-80a0-a715b8f413a8

commit dd91ebea823dd2169e8c30f0cfe87fa199e1a0c2
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jun 28 17:46:46 2009 +0000

    Loaded pocketsphinx's properties from config file

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1019 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 2ba91890593d7a64136e675bb937efd9a2542cc7
Author: garmt.noname@gmail.com <garmt.noname@gmail.com@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jun 28 12:29:54 2009 +0000

    Removed session tasks, most channel tasks, flite voices are no longer global

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1018 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 0d739127f9267b3ad871d1a53a863802f101a6b5
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sat Jun 27 09:15:20 2009 +0000

    Implemented save_waveform, utterance will be saved in the filesystem

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1017 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 4ffd282ddf54ad861d73f36567ad201d135feff5
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sat Jun 27 08:24:19 2009 +0000

    Set 2 digits precision (digits after the decimal point) while generating float type values (Issue-35).

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1016 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 90446f5e6ece40e91fd5b340a45e6773e4e80a0f
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sat Jun 27 07:42:52 2009 +0000

    Set noinut and recognition timeouts if specified in RECOGNIZE request, reset input timer on partial match

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1015 f001bc3a-424a-0410-80a0-a715b8f413a8



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14104 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 03b73eb4
Fri Jun 26 15:16:40 CDT 2009
Wed Jul 1 19:53:07 CDT 2009
......@@ -6,15 +6,13 @@ AC_DEFUN([UNIMRCP_CHECK_FLITE],
AC_MSG_CHECKING([for Flite])
AC_ARG_WITH(flite,
[ --with-flite=PATH prefix for installed Flite or
path to Flite build tree],
[ --with-flite=PATH path to Flite build tree],
[flite_path=$withval],
[flite_path="/usr/local"]
[flite_path="/usr/src/flite"]
)
found_flite="no"
dnl TO BE DONE
flite_libdir="build/libs"
for dir in $flite_path ; do
cd $dir && flite_dir=`pwd` && cd - > /dev/null
......
......@@ -21,6 +21,7 @@ AC_DEFUN([UNIMRCP_CHECK_POCKETSPHINX],
found_pocketsphinx="yes"
UNIMRCP_POCKETSPHINX_INCLUDES="`pkg-config --cflags $dir/$pocketsphinx_config`"
UNIMRCP_POCKETSPHINX_LIBS="`pkg-config --libs $dir/$pocketsphinx_config`"
UNIMRCP_POCKETSPHINX_MODELS=
pocketsphinx_version="`pkg-config --modversion $dir/$pocketsphinx_config`"
break
fi
......@@ -28,6 +29,7 @@ AC_DEFUN([UNIMRCP_CHECK_POCKETSPHINX],
found_pocketsphinx="yes"
UNIMRCP_POCKETSPHINX_INCLUDES="-I$pocketsphinx_dir/include"
UNIMRCP_POCKETSPHINX_LIBS="$pocketsphinx_dir/$pocketsphinx_srcdir/libpocketsphinx/libpocketsphinx.la"
UNIMRCP_POCKETSPHINX_MODELS="$pocketsphinx_dir/model"
pocketsphinx_version="`pkg-config --modversion $pocketsphinx_dir/pocketsphinx.pc`"
break
fi
......@@ -46,5 +48,6 @@ esac
AC_SUBST(UNIMRCP_POCKETSPHINX_INCLUDES)
AC_SUBST(UNIMRCP_POCKETSPHINX_LIBS)
AC_SUBST(UNIMRCP_POCKETSPHINX_MODELS)
fi
])
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="preparesphinx"
ProjectGUID="{71D62A04-8EF6-4C6B-AC12-0C15A875E53A}"
RootNamespace="preparesphinx"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="10"
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\pocketsphinx.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="xcopy &quot;$(PocketSphinxDir)\bin\$(ConfigurationName)\pocketsphinx.dll&quot; &quot;$(SolutionDir)$(ConfigurationName)\bin\&quot; /Y&#x0D;&#x0A;xcopy &quot;$(SphinxBaseDir)\lib\$(ConfigurationName)\sphinxbase.dll&quot; &quot;$(SolutionDir)$(ConfigurationName)\bin\&quot; /Y&#x0D;&#x0A;&#x0D;&#x0A;xcopy &quot;$(PocketSphinxDir)\model\hmm\wsj1\*&quot; &quot;$(SolutionDir)$(ConfigurationName)\data\wsj1\&quot; /Y&#x0D;&#x0A;copy &quot;$(PocketSphinxDir)\model\lm\cmudict.0.6d&quot; &quot;$(SolutionDir)$(ConfigurationName)\data\default.dic&quot;&#x0D;&#x0A;&#x0D;&#x0A;if not exist &quot;$(SolutionDir)$(ConfigurationName)\conf\pocketsphinx.xml&quot; xcopy &quot;$(SolutionDir)plugins\mrcp-pocketsphinx\conf\pocketsphinx.xml&quot; &quot;$(SolutionDir)$(ConfigurationName)\conf\&quot; /Y&#x0D;&#x0A;"
ExcludedFromBuild="false"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="10"
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\pocketsphinx.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="xcopy &quot;$(PocketSphinxDir)\bin\$(ConfigurationName)\pocketsphinx.dll&quot; &quot;$(SolutionDir)$(ConfigurationName)\bin\&quot; /Y&#x0D;&#x0A;xcopy &quot;$(SphinxBaseDir)\lib\$(ConfigurationName)\sphinxbase.dll&quot; &quot;$(SolutionDir)$(ConfigurationName)\bin\&quot; /Y&#x0D;&#x0A;&#x0D;&#x0A;xcopy &quot;$(PocketSphinxDir)\model\hmm\wsj1\*&quot; &quot;$(SolutionDir)$(ConfigurationName)\data\wsj1\&quot; /Y&#x0D;&#x0A;copy &quot;$(PocketSphinxDir)\model\lm\cmudict.0.6d&quot; &quot;$(SolutionDir)$(ConfigurationName)\data\default.dic&quot;&#x0D;&#x0A;&#x0D;&#x0A;if not exist &quot;$(SolutionDir)$(ConfigurationName)\conf\pocketsphinx.xml&quot; xcopy &quot;$(SolutionDir)plugins\mrcp-pocketsphinx\conf\pocketsphinx.xml&quot; &quot;$(SolutionDir)$(ConfigurationName)\conf\&quot; /Y&#x0D;&#x0A;"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
......@@ -54,6 +54,8 @@
<!-- Resource plugins -->
<plugin>
<engine name="Cepstral-Swift-1" class="mrcpcepstral" enable="0"/>
<engine name="PocketSphinx-1" class="mrcppocketsphinx" enable="0"/>
<engine name="Flite-1" class="mrcpflite" enable="0"/>
<engine name="Demo-Synth-1" class="demosynth" enable="1"/>
<engine name="Demo-Recog-1" class="demorecog" enable="1"/>
</plugin>
......
......@@ -122,7 +122,7 @@ static APR_INLINE float apt_float_value_parse(const apt_str_t *str)
/** Generate float value */
static APR_INLINE apt_bool_t apt_float_value_generate(float value, apt_text_stream_t *stream)
{
int length = sprintf(stream->pos,"%.1f",value);
int length = sprintf(stream->pos,"%.2f",value);
if(length <= 0) {
return FALSE;
}
......
......@@ -208,6 +208,12 @@ static mpf_object_t* mpf_context_connection_create(mpf_context_t *context, mpf_t
object = mpf_null_bridge_create(source,sink,context->pool);
}
else {
if(rx_codec->descriptor->sampling_rate != tx_codec->descriptor->sampling_rate) {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,
"Resampling is not supported now. "
"Try to configure and use the same sampling rate on both ends");
return NULL;
}
if(rx_codec->vtable && rx_codec->vtable->decode) {
/* set decoder before bridge */
mpf_audio_stream_t *decoder = mpf_decoder_create(source,context->pool);
......
......@@ -15,6 +15,15 @@ INCLUDES = -Iinclude \
plugin_LTLIBRARIES = mrcppocketsphinx.la
mrcppocketsphinx_la_SOURCES = src/mrcp_pocketsphinx.c
mrcppocketsphinx_la_SOURCES = src/mrcp_pocketsphinx.c \
src/pocketsphinx_properties.c
mrcppocketsphinx_la_LDFLAGS = -module $(PLUGIN_LT_VERSION)
mrcppocketsphinx_la_LIBADD = $(UNIMRCP_POCKETSPHINX_LIBS) $(UNIMRCP_SPHINXBASE_LIBS) -lm
install-data-local:
test -d $(confdir) || $(mkinstalldirs) $(confdir)
test -f $(confdir)/pocketsphinx.xml || $(INSTALL) -m 644 conf/pocketsphinx.xml $(confdir)
test -d $(datadir)/wsj1 || $(mkinstalldirs) $(datadir)/wsj1; \
$(INSTALL) -m 644 $(UNIMRCP_POCKETSPHINX_MODELS)/hmm/wsj1/* $(datadir)/wsj1; \
$(INSTALL) -m 644 $(UNIMRCP_POCKETSPHINX_MODELS)/lm/cmudict.0.6d $(datadir)/default.dic
<!-- PocketSphinx Document -->
<pocketsphinx>
<!-- Senstitivity level and timeout are used for voice activity (speech) detection
reasonable values: level is in [2..250] range, timeout is in [100..500] msec range
-->
<sensitivity level="50" timeout="300"/>
<!-- Default values for noinput and recognition timeout,
these values can be overriden by client's requests
-->
<timers noinput-timeout="10000" recognition-timeout="15000"/>
<!-- PocketSphinx related model and dictionary data.
Default dir (dir="") is InstallDir/data
-->
<model dir="" narrowband="communicator" wideband="wsj1" dictionary="default.dic" preferred="narrowband"/>
<!-- <model dir="/usr/local/freeswitch/grammar" narrowband="model/communicator" wideband="model/wsj1" dictionary="default.dic"/> -->
<!-- Enable to save utterance.
Default dir (dir="") is InstallDir/data
-->
<save-waveform dir="" enable="0"/>
</pocketsphinx>
/*
* Copyright 2008 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __POCKETSPHINX_PROPERTIES_H__
#define __POCKETSPHINX_PROPERTIES_H__
/**
* @file pocketsphinx_properties.h
* @brief PocketSphinx Properties
*/
#include "apt_dir_layout.h"
APT_BEGIN_EXTERN_C
typedef enum {
POCKETSPHINX_MODEL_NARROWBAND,
POCKETSPHINX_MODEL_WIDEBAND
} pocketsphinx_model_e;
/** Declaration of pocketsphinx properties */
typedef struct pocketsphinx_properties_t pocketsphinx_properties_t;
/** Pocketsphinx properties */
struct pocketsphinx_properties_t {
const char *data_dir;
const char *dictionary;
const char *model_8k;
const char *model_16k;
pocketsphinx_model_e preferred_model;
apr_size_t sensitivity_level;
apr_size_t sensitivity_timeout;
apr_size_t no_input_timeout;
apr_size_t recognition_timeout;
apr_size_t partial_result_timeout;
apt_bool_t save_waveform;
const char *save_waveform_dir;
};
apt_bool_t pocketsphinx_properties_load(pocketsphinx_properties_t *properties,
const char *file_path,
const apt_dir_layout_t *dir_layout,
apr_pool_t *pool);
APT_END_EXTERN_C
#endif /*__POCKETSPHINX_PROPERTIES_H__*/
......@@ -149,6 +149,10 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\include\pocketsphinx_properties.h"
>
</File>
</Filter>
<Filter
Name="src"
......@@ -158,6 +162,10 @@
RelativePath=".\src\mrcp_pocketsphinx.c"
>
</File>
<File
RelativePath=".\src\pocketsphinx_properties.c"
>
</File>
</Filter>
</Files>
<Globals>
......
/*
* Copyright 2008 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <apr_xml.h>
#include "pocketsphinx_properties.h"
#include "apt_log.h"
static const apr_xml_elem* pocketsphinx_document_load(const char *file_path, apr_pool_t *pool)
{
apr_xml_parser *parser = NULL;
apr_xml_doc *doc = NULL;
const apr_xml_elem *root;
apr_file_t *fd = NULL;
apr_status_t rv;
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Open PocketSphinx Config File [%s]",file_path);
rv = apr_file_open(&fd,file_path,APR_READ|APR_BINARY,0,pool);
if(rv != APR_SUCCESS) {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open PocketSphinx Config File [%s]",file_path);
return FALSE;
}
rv = apr_xml_parse_file(pool,&parser,&doc,fd,2000);
if(rv != APR_SUCCESS) {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Parse PocketSphinx Config File [%s]",file_path);
apr_file_close(fd);
return FALSE;
}
root = doc->root;
if(!root || strcasecmp(root->name,"pocketsphinx") != 0) {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Document <%s>",root->name);
apr_file_close(fd);
return FALSE;
}
apr_file_close(fd);
return root;
}
static apt_bool_t sensitivity_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool)
{
const apr_xml_attr *attr;
for(attr = elem->attr; attr; attr = attr->next) {
if(strcasecmp(attr->name,"level") == 0) {
properties->sensitivity_level = atol(attr->value);
}
else if(strcasecmp(attr->name,"timeout") == 0) {
properties->sensitivity_timeout = atol(attr->value);
}
else {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name);
}
}
return TRUE;
}
static apt_bool_t timer_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool)
{
const apr_xml_attr *attr;
for(attr = elem->attr; attr; attr = attr->next) {
if(strcasecmp(attr->name,"noinput-timeout") == 0) {
properties->no_input_timeout = atol(attr->value);
}
else if(strcasecmp(attr->name,"recognition-timeout") == 0) {
properties->recognition_timeout = atol(attr->value);
}
else {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name);
}
}
return TRUE;
}
static apt_bool_t model_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool)
{
const apr_xml_attr *attr;
for(attr = elem->attr; attr; attr = attr->next) {
if(strcasecmp(attr->name,"dir") == 0) {
properties->data_dir = apr_pstrdup(pool,attr->value);
}
else if(strcasecmp(attr->name,"narrowband") == 0) {
properties->model_8k = apr_pstrdup(pool,attr->value);
}
else if(strcasecmp(attr->name,"wideband") == 0) {
properties->model_16k = apr_pstrdup(pool,attr->value);
}
else if(strcasecmp(attr->name,"dictionary") == 0) {
properties->dictionary = apr_pstrdup(pool,attr->value);
}
else if(strcasecmp(attr->name,"preferred") == 0) {
if(strcasecmp(attr->value,"narrowband") == 0) {
properties->preferred_model = POCKETSPHINX_MODEL_NARROWBAND;
}
else if(strcasecmp(attr->value,"wideband") == 0) {
properties->preferred_model = POCKETSPHINX_MODEL_WIDEBAND;
}
}
else {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name);
}
}
return TRUE;
}
static apt_bool_t save_waveform_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool)
{
const apr_xml_attr *attr;
for(attr = elem->attr; attr; attr = attr->next) {
if(strcasecmp(attr->name,"dir") == 0) {
properties->save_waveform_dir = apr_pstrdup(pool,attr->value);
}
else if(strcasecmp(attr->name,"enable") == 0) {
properties->save_waveform = atoi(attr->value);
}
else {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name);
}
}
return TRUE;
}
apt_bool_t pocketsphinx_properties_load(pocketsphinx_properties_t *properties,
const char *file_path,
const apt_dir_layout_t *dir_layout,
apr_pool_t *pool)
{
const apr_xml_elem *elem;
const apr_xml_elem *root;
char *path = NULL;
/* reset or set default properties */
properties->data_dir = NULL;
properties->dictionary = NULL;
properties->model_8k = NULL;
properties->model_16k = NULL;
properties->preferred_model = POCKETSPHINX_MODEL_NARROWBAND;
properties->no_input_timeout = 10000;
properties->recognition_timeout = 15000;
properties->partial_result_timeout = 100;
properties->save_waveform = TRUE;
properties->save_waveform_dir = NULL;
root = pocketsphinx_document_load(file_path,pool);
if(root) {
for(elem = root->first_child; elem; elem = elem->next) {
if(strcasecmp(elem->name,"sensitivity") == 0) {
sensitivity_properties_load(properties,elem,pool);
}
else if(strcasecmp(elem->name,"timers") == 0) {
timer_properties_load(properties,elem,pool);
}
else if(strcasecmp(elem->name,"model") == 0) {
model_properties_load(properties,elem,pool);
}
else if(strcasecmp(elem->name,"save-waveform") == 0) {
save_waveform_properties_load(properties,elem,pool);
}
else {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name);
}
}
}
/* verify loaded properties */
if(!properties->data_dir || *properties->data_dir == '\0') {
properties->data_dir = dir_layout->data_dir_path;
}
if(!properties->save_waveform_dir || *properties->save_waveform_dir == '\0') {
properties->save_waveform_dir = dir_layout->data_dir_path;
}
if(!properties->dictionary) {
properties->dictionary = "default.dic";
}
if(!properties->model_8k) {
properties->model_8k = "communicator";
}
if(!properties->model_16k) {
properties->model_16k = "wsj1";
}
if(apr_filepath_merge(&path,properties->data_dir,properties->dictionary,0,pool) == APR_SUCCESS) {
properties->dictionary = path;
}
if(apr_filepath_merge(&path,properties->data_dir,properties->model_8k,0,pool) == APR_SUCCESS) {
properties->model_8k = path;
}
if(apr_filepath_merge(&path,properties->data_dir,properties->model_16k,0,pool) == APR_SUCCESS) {
properties->model_16k = path;
}
return TRUE;
}
......@@ -148,6 +148,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpflite", "plugins\mrcp-f
{843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preparesphinx", "build\tools\preparesphinx.vcproj", "{71D62A04-8EF6-4C6B-AC12-0C15A875E53A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
......@@ -252,6 +254,8 @@ Global
{3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Release|Win32.ActiveCfg = Release|Win32
{56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Debug|Win32.ActiveCfg = Debug|Win32
{56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Release|Win32.ActiveCfg = Release|Win32
{71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Debug|Win32.ActiveCfg = Debug|Win32
{71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Release|Win32.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -284,5 +288,6 @@ Global
{17A33F3F-BAF5-403F-8EF4-FECDA7D9A335} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD}
{01D63BF5-7798-4746-852A-4B45229BB735} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C}
{4714EF49-BFD5-4B22-95F7-95A07F1EAC25} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C}
{71D62A04-8EF6-4C6B-AC12-0C15A875E53A} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C}
EndGlobalSection
EndGlobal
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论