Update of /cvsroot/playerstage/code/player/client_libs/libplayerc++
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28571/client_libs/libplayerc++
Modified Files:
Tag: release-2-0-patches
Makefile.am playerc++.h speechrecognitionproxy.cc
Log Message:
applied patch 1527657 to fix sphinx2 and speech recognition proxies
Index: playerc++.h
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/playerc++.h,v
retrieving revision 1.54.2.3
retrieving revision 1.54.2.4
diff -C2 -d -r1.54.2.3 -r1.54.2.4
*** playerc++.h 2 Aug 2006 17:00:33 -0000 1.54.2.3
--- playerc++.h 2 Aug 2006 17:36:41 -0000 1.54.2.4
***************
*** 2032,2058 ****
};
! // /**
! // The @p SpeechRecognition proxy provides access to a @ref
interface_speech_recognition device.
! // */
! // class SpeechRecognitionProxy : public ClientProxy
! // {
! //
! // private:
! //
! // void Subscribe(uint aIndex);
! // void Unsubscribe();
! //
! // // libplayerc data structure
! // playerc_speech_t *mDevice;
! //
! // public:
! // // Constructor
! // SpeechRecognitionProxy(PlayerClient *aPc, uint aIndex=0);
! //
! // ~SpeechRecognitionProxy();
! //
! // std::string GetText();
! //
! // };
// /**
--- 2032,2062 ----
};
! /**
! The @p SpeechRecognition proxy provides access to a @ref
interface_speech_recognition device.
! */
! class SpeechRecognitionProxy : public ClientProxy
! {
! void Subscribe(uint aIndex);
! void Unsubscribe();
!
! ///libplayerc data structure
! playerc_speech_recognition_t *mDevice;
! public:
! ///Constructor
! SpeechRecognitionProxy(PlayerClient *aPc, uint aIndex=0);
! ~SpeechRecognitionProxy();
! /// Accessor method for getting speech recognition data i.e. words.
! std::string GetWord(uint aWord) const{
! scoped_lock_t lock(mPc->mMutex);
! return std::string(mDevice->words[aWord]);
! }
!
! /// Gets the number of words.
! uint GetCount(void) const { return GetVar(mDevice->wordCount); }
!
! /// Word access operator.
! /// This operator provides an alternate way of access the speech
recognition data.
! std::string operator [](uint aWord) { return(GetWord(aWord)); }
! };
// /**
***************
*** 2233,2237 ****
std::ostream& operator << (std::ostream& os, const PlayerCc::SonarProxy& c);
std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechProxy&
c);
! //std::ostream& operator << (std::ostream& os, const
PlayerCc::SpeechRecognitionProxy& c);
//std::ostream& operator << (std::ostream& os, const
PlayerCc::WafeformProxy& c);
std::ostream& operator << (std::ostream& os, const PlayerCc::WiFiProxy& c);
--- 2237,2241 ----
std::ostream& operator << (std::ostream& os, const PlayerCc::SonarProxy& c);
std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechProxy&
c);
! std::ostream& operator << (std::ostream& os, const
PlayerCc::SpeechRecognitionProxy& c);
//std::ostream& operator << (std::ostream& os, const
PlayerCc::WafeformProxy& c);
std::ostream& operator << (std::ostream& os, const PlayerCc::WiFiProxy& c);
Index: Makefile.am
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/Makefile.am,v
retrieving revision 1.36.2.1
retrieving revision 1.36.2.2
diff -C2 -d -r1.36.2.1 -r1.36.2.2
*** Makefile.am 9 Jun 2006 18:27:45 -0000 1.36.2.1
--- Makefile.am 2 Aug 2006 17:36:41 -0000 1.36.2.2
***************
*** 57,60 ****
--- 57,61 ----
sonarproxy.cc \
speechproxy.cc \
+ speechrecognitionproxy.cc \
wifiproxy.cc \
wsnproxy.cc
***************
*** 67,71 ****
energyproxy.cc \
mcomproxy.cc \
- speechrecognitionproxy.cc \
waveformproxy.cc
--- 68,71 ----
Index: speechrecognitionproxy.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/speechrecognitionproxy.cc,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** speechrecognitionproxy.cc 7 Oct 2005 15:49:30 -0000 1.2
--- speechrecognitionproxy.cc 2 Aug 2006 17:36:41 -0000 1.2.4.1
***************
*** 27,88 ****
#include "playerc++.h"
! SpeechRecognitionProxy::SpeechRecognitionProxy (PlayerClient *pc, unsigned
short index, unsigned char access)
! : ClientProxy( pc, PLAYER_SPEECH_RECOGNITION_CODE, index, access)
{
}
- // Destructor
SpeechRecognitionProxy::~SpeechRecognitionProxy()
{
}
! // interface that all proxies must provide
! void SpeechRecognitionProxy::FillData (player_msghdr_t hdr, const char
*buffer)
{
! int i,j;
! int startIndex = 0;
!
! player_speech_recognition_data_t *data =
(player_speech_recognition_data_t*)buffer;
!
! if(hdr.size != sizeof(player_speech_recognition_data_t))
! {
! if(player_debug_level(-1) >= 1)
! fprintf(stderr,"WARNING: expected %d bytes of speech recognition data,
but "
! "received %d. Unexpected results may ensue.\n",
! sizeof(player_speech_recognition_data_t),hdr.size);
! }
!
! this->wordCount = 0;
!
! printf ("Text[%s] Length[%d]\n",data->text, strlen(data->text));
!
! // Split the text string into words
! for (i=0; i<strlen(data->text); i++)
! {
! // If space, then reached a word boundary. So create a new word
! if (data->text[i] == ' ' && i > startIndex)
! {
! // Copy the word
! for (j=startIndex; j<i; j++)
! this->words[this->wordCount][j-startIndex] = data->text[j];
!
! // Add string termination character
! this->words[this->wordCount][i-startIndex] = '\0';
!
! //printf("Word[%s]\n",this->words[this->wordCount]);
! startIndex = i+1;
! this->wordCount++;
! }
! }
}
! void SpeechRecognitionProxy::Clear()
{
! this->wordCount = 0;
! for (int i=0; i<20; i++)
{
! memset(this->words[i],0,30);
}
}
--- 27,80 ----
#include "playerc++.h"
! using namespace PlayerCc;
!
! SpeechRecognitionProxy::SpeechRecognitionProxy(PlayerClient *aPc, uint aIndex)
! : ClientProxy(aPc, aIndex),
! mDevice(NULL)
{
+ Subscribe(aIndex);
+ // how can I get this into the clientproxy.cc?
+ // right now, we're dependent on knowing its device type
+ mInfo = &(mDevice->info);
}
SpeechRecognitionProxy::~SpeechRecognitionProxy()
{
+ Unsubscribe();
}
! void
! SpeechRecognitionProxy::Subscribe(uint aIndex)
{
! scoped_lock_t lock(mPc->mMutex);
! mDevice = playerc_speech_recognition_create(mClient, aIndex);
! if (NULL==mDevice)
! throw PlayerError("SpeechRecognitionProxy::SpeechRecognitionProxy()",
"could not create");
! if (0 != playerc_speech_recognition_subscribe(mDevice, PLAYER_OPEN_MODE))
! throw PlayerError("SpeechRecognitionProxy::SpeechRecognitionProxy()",
"could not subscribe");
}
! void
! SpeechRecognitionProxy::Unsubscribe()
{
! assert(NULL!=mDevice);
! scoped_lock_t lock(mPc->mMutex);
! playerc_speech_recognition_unsubscribe(mDevice);
! playerc_speech_recognition_destroy(mDevice);
! mDevice = NULL;
! }
! std::ostream&
! std::operator << (std::ostream &os, const PlayerCc::SpeechRecognitionProxy &c)
! {
! os << "#SpeechRecognition (" << c.GetInterface() << ":" << c.GetIndex() <<
")" << std::endl;
! os << " words [" << c.GetCount() << "]: ";
! for (uint i=0; i < c.GetCount(); i++)
{
! std::cout << c.GetWord(i) << " " ;
}
+ os << std::endl;
+ return os;
}
+
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit