[Freeswitch-svn] [commit] r13881 - in freeswitch/trunk/libs/unimrcp: . build/vsprops plugins/mrcp-pocketsphinx plugins/mrcp-pocketsphinx/src

FreeSWITCH SVN brian at freeswitch.org
Fri Jun 19 20:40:47 PDT 2009


Author: brian
Date: Fri Jun 19 22:40:46 2009
New Revision: 13881

Log:
Author: achaloyan <achaloyan at f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Fri Jun 19 19:14:14 2009 +0000

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



Added:
   freeswitch/trunk/libs/unimrcp/build/vsprops/pocketsphinx.vsprops
   freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/
   freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am
   freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj
   freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/
   freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c
Modified:
   freeswitch/trunk/libs/unimrcp/.update

Modified: freeswitch/trunk/libs/unimrcp/.update
==============================================================================
--- freeswitch/trunk/libs/unimrcp/.update	(original)
+++ freeswitch/trunk/libs/unimrcp/.update	Fri Jun 19 22:40:46 2009
@@ -1 +1 @@
-Tue Jun 16 17:36:06 CDT 2009
+Fri Jun 19 22:39:34 CDT 2009

Added: freeswitch/trunk/libs/unimrcp/build/vsprops/pocketsphinx.vsprops
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/unimrcp/build/vsprops/pocketsphinx.vsprops	Fri Jun 19 22:40:46 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="pocketsphinx"
+	InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unibase.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalIncludeDirectories="&quot;$(PocketSphinxDir)\include&quot;;&quot;$(SphinxBaseDir)\include&quot;"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="sphinxbase.lib pocketsphinx.lib"
+		AdditionalLibraryDirectories="&quot;$(PocketSphinxDir)\bin\$(ConfigurationName)&quot;;&quot;$(SphinxBaseDir)\lib\$(ConfigurationName)&quot;"
+	/>
+	<UserMacro
+		Name="PocketSphinxDir"
+		Value="$(LibRootDir)libs\pocketsphinx"
+	/>
+	<UserMacro
+		Name="SphinxBaseDir"
+		Value="$(LibRootDir)libs\sphinxbase"
+	/>
+</VisualStudioPropertySheet>

Added: freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am	Fri Jun 19 22:40:46 2009
@@ -0,0 +1,16 @@
+MAINTAINERCLEANFILES 	    = Makefile.in
+
+INCLUDES                    = -Iinclude \
+                              -I$(top_srcdir)/libs/mrcp-engine/include \
+                              -I$(top_srcdir)/libs/mrcp/include \
+                              -I$(top_srcdir)/libs/mrcp/message/include \
+                              -I$(top_srcdir)/libs/mrcp/control/include \
+                              -I$(top_srcdir)/libs/mrcp/resources/include \
+                              -I$(top_srcdir)/libs/mpf/include \
+                              -I$(top_srcdir)/libs/apr-toolkit/include \
+                             $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES)
+
+plugin_LTLIBRARIES          = mrcppocketsphinx.la
+
+mrcppocketsphinx_la_SOURCES = src/mrcp_pocketsphinx.c.c
+mrcppocketsphinx_la_LDFLAGS = -module $(PLUGIN_LT_VERSION)

Added: freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj	Fri Jun 19 22:40:46 2009
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="mrcppocketsphinx"
+	ProjectGUID="{3C614AE8-B611-4D43-A9AF-1CAA440A9F69}"
+	RootNamespace="mrcppocketsphinx"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unidebug.vsprops;$(ProjectDir)..\..\build\vsprops\pocketsphinx.vsprops;$(ProjectDir)..\..\build\vsprops\unimrcpplugin.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="include"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unirelease.vsprops;$(ProjectDir)..\..\build\vsprops\pocketsphinx.vsprops;$(ProjectDir)..\..\build\vsprops\unimrcpplugin.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="include"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="include"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+		<Filter
+			Name="src"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			>
+			<File
+				RelativePath=".\src\mrcp_pocketsphinx.c"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Added: freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c	Fri Jun 19 22:40:46 2009
@@ -0,0 +1,232 @@
+/*
+ * 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.
+ */
+
+/* 
+ * Some mandatory rules for plugin implementation.
+ * 1. Each plugin MUST contain the following function as an entry point of the plugin
+ *        MRCP_PLUGIN_DECLARE(mrcp_resource_engine_t*) mrcp_plugin_create(apr_pool_t *pool)
+ * 2. One and only one response MUST be sent back to the received request.
+ * 3. Methods (callbacks) of the MRCP engine channel MUST not block.
+ *   (asynch response can be sent from the context of other thread)
+ * 4. Methods (callbacks) of the MPF engine stream MUST not block.
+ */
+
+#include "mrcp_resource_engine.h"
+#include "mrcp_recog_resource.h"
+#include "mrcp_recog_header.h"
+#include "mrcp_generic_header.h"
+#include "mrcp_message.h"
+#include "mpf_activity_detector.h"
+#include "apt_log.h"
+
+
+typedef struct pocketsphinx_engine_t pocketsphinx_engine_t;
+typedef struct pocketsphinx_recognizer_t pocketsphinx_recognizer_t;
+
+/** Declaration of recognizer engine methods */
+static apt_bool_t pocketsphinx_engine_destroy(mrcp_resource_engine_t *engine);
+static apt_bool_t pocketsphinx_engine_open(mrcp_resource_engine_t *engine);
+static apt_bool_t pocketsphinx_engine_close(mrcp_resource_engine_t *engine);
+static mrcp_engine_channel_t* pocketsphinx_recognizer_create(mrcp_resource_engine_t *engine, apr_pool_t *pool);
+
+static const struct mrcp_engine_method_vtable_t engine_vtable = {
+	pocketsphinx_engine_destroy,
+	pocketsphinx_engine_open,
+	pocketsphinx_engine_close,
+	pocketsphinx_recognizer_create
+};
+
+
+/** Declaration of recognizer channel methods */
+static apt_bool_t pocketsphinx_recognizer_destroy(mrcp_engine_channel_t *channel);
+static apt_bool_t pocketsphinx_recognizer_open(mrcp_engine_channel_t *channel);
+static apt_bool_t pocketsphinx_recognizer_close(mrcp_engine_channel_t *channel);
+static apt_bool_t pocketsphinx_recognizer_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *request);
+
+static const struct mrcp_engine_channel_method_vtable_t channel_vtable = {
+	pocketsphinx_recognizer_destroy,
+	pocketsphinx_recognizer_open,
+	pocketsphinx_recognizer_close,
+	pocketsphinx_recognizer_request_process
+};
+
+/** Declaration of recognizer audio stream methods */
+static apt_bool_t pocketsphinx_stream_destroy(mpf_audio_stream_t *stream);
+static apt_bool_t pocketsphinx_stream_open(mpf_audio_stream_t *stream);
+static apt_bool_t pocketsphinx_stream_close(mpf_audio_stream_t *stream);
+static apt_bool_t pocketsphinx_stream_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame);
+
+static const mpf_audio_stream_vtable_t audio_stream_vtable = {
+	pocketsphinx_stream_destroy,
+	NULL,
+	NULL,
+	NULL,
+	pocketsphinx_stream_open,
+	pocketsphinx_stream_close,
+	pocketsphinx_stream_write
+};
+
+/** Declaration of pocketsphinx engine */
+struct pocketsphinx_engine_t {
+	mrcp_resource_engine_t *base;
+};
+
+/** Declaration of pocketsphinx recognizer */
+struct pocketsphinx_recognizer_t {
+	/** Back pointer to engine */
+	pocketsphinx_engine_t   *engine;
+	/** Engine channel base */
+	mrcp_engine_channel_t   *channel;
+};
+
+/** Declare this macro to use log routine of the server, plugin is loaded from */
+MRCP_PLUGIN_LOGGER_IMPLEMENT
+
+
+/** Create pocketsphinx engine (engine is an aggregation of recognizers) */
+MRCP_PLUGIN_DECLARE(mrcp_resource_engine_t*) mrcp_plugin_create(apr_pool_t *pool)
+{
+	pocketsphinx_engine_t *engine = apr_palloc(pool,sizeof(pocketsphinx_engine_t));
+	
+	/* create resource engine base */
+	engine->base = mrcp_resource_engine_create(
+					MRCP_RECOGNIZER_RESOURCE,  /* MRCP resource identifier */
+					engine,                    /* object to associate */
+					&engine_vtable,            /* virtual methods table of resource engine */
+					pool);                     /* pool to allocate memory from */
+	return engine->base;
+}
+
+static apt_bool_t pocketsphinx_engine_destroy(mrcp_resource_engine_t *engine)
+{
+	return TRUE;
+}
+
+static apt_bool_t pocketsphinx_engine_open(mrcp_resource_engine_t *engine)
+{
+	return TRUE;
+}
+
+static apt_bool_t pocketsphinx_engine_close(mrcp_resource_engine_t *engine)
+{
+	return TRUE;
+}
+
+/** Create pocketsphinx recognizer */
+static mrcp_engine_channel_t* pocketsphinx_recognizer_create(mrcp_resource_engine_t *engine, apr_pool_t *pool)
+{
+	mrcp_engine_channel_t *channel;
+	pocketsphinx_recognizer_t *recognizer = apr_palloc(pool,sizeof(pocketsphinx_recognizer_t));
+
+	/* create engine channel base */
+	channel = mrcp_engine_sink_channel_create(
+			engine,               /* resource engine */
+			&channel_vtable,      /* virtual methods table of engine channel */
+			&audio_stream_vtable, /* virtual methods table of audio stream */
+			recognizer,           /* object to associate */
+			NULL,                 /* codec descriptor might be NULL by default */
+			pool);                /* pool to allocate memory from */
+	
+	recognizer->channel = channel;
+	return channel;
+}
+
+/** Destroy engine channel */
+static apt_bool_t pocketsphinx_recognizer_destroy(mrcp_engine_channel_t *channel)
+{
+	return TRUE;
+}
+
+/** Open engine channel (asynchronous response MUST be sent)*/
+static apt_bool_t pocketsphinx_recognizer_open(mrcp_engine_channel_t *channel)
+{
+	return mrcp_engine_channel_open_respond(channel,TRUE);
+}
+
+/** Close engine channel (asynchronous response MUST be sent)*/
+static apt_bool_t pocketsphinx_recognizer_close(mrcp_engine_channel_t *channel)
+{
+	return mrcp_engine_channel_close_respond(channel);
+}
+
+
+/** Process RECOGNIZE request */
+static apt_bool_t pocketsphinx_recognize(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response)
+{
+	return TRUE;
+}
+
+/** Process STOP request */
+static apt_bool_t pocketsphinx_stop(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response)
+{
+	return TRUE;
+}
+
+static apt_bool_t pocketsphinx_recognizer_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *request)
+{
+	pocketsphinx_recognizer_t *recognizer = channel->method_obj;
+	apt_bool_t processed = FALSE;
+	mrcp_message_t *response = mrcp_response_create(request,request->pool);
+	switch(request->start_line.method_id) {
+		case RECOGNIZER_SET_PARAMS:
+			break;
+		case RECOGNIZER_GET_PARAMS:
+			break;
+		case RECOGNIZER_DEFINE_GRAMMAR:
+			break;
+		case RECOGNIZER_RECOGNIZE:
+			processed = pocketsphinx_recognize(recognizer,request,response);
+			break;
+		case RECOGNIZER_GET_RESULT:
+			break;
+		case RECOGNIZER_START_INPUT_TIMERS:
+			break;
+		case RECOGNIZER_STOP:
+			processed = pocketsphinx_stop(recognizer,request,response);
+			break;
+		default:
+			break;
+	}
+	if(processed == FALSE) {
+		/* send asynchronous response for not handled request */
+		mrcp_engine_channel_message_send(channel,response);
+	}
+	return TRUE;
+}
+
+
+
+
+
+static apt_bool_t pocketsphinx_stream_destroy(mpf_audio_stream_t *stream)
+{
+	return TRUE;
+}
+
+static apt_bool_t pocketsphinx_stream_open(mpf_audio_stream_t *stream)
+{
+	return TRUE;
+}
+
+static apt_bool_t pocketsphinx_stream_close(mpf_audio_stream_t *stream)
+{
+	return TRUE;
+}
+
+static apt_bool_t pocketsphinx_stream_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame)
+{
+	return TRUE;
+}



More information about the Freeswitch-svn mailing list