设为首页 收藏本站
查看: 1002|回复: 0

[经验分享] viaVoice开发,怎样设置IBM viavoice的语言

[复制链接]

尚未签到

发表于 2017-5-26 12:38:25 | 显示全部楼层 |阅读模式
  #include <speech.h>
#include <mmsystem.h>
#include "reslist.hpp"
  #define MAX_PHRASELEN128
  
class SapiSpeech;
class Result;
class ResultsList;
  typedef enum SpeechEventEnum
{
ENG_ATTRIBCHANGED,
ENG_INTERFERENCE,
ENG_SOUND,
ENG_UTTERANCEBEGIN,
ENG_UTTERANCEEND,
ENG_VUMETER,
DCT_BOOKMARK,
DCT_PAUSED,
DCT_PHRASESTART,
DCT_PHRASEHYPOTHESIS,
DCT_PHRASEFINISH,
DCT_REEVALUATE,
DCT_TRAINING,
DCT_UNARCHIVE,
} SPCHEVENTID;
  typedef struct WantNotificationsStruct
{
BOOL bEngAttribChanged;
BOOL bEngInterference;
BOOL bEngSound;
BOOL bEngUtteranceBegin;
BOOL bEngUtteranceEnd;
BOOL bEngVUMeter;
BOOL bDctBookmark;
BOOL bDctPaused;
BOOL bDctPhraseStart;
BOOL bDctPhraseHypothesis;
BOOL bDctPhraseFinish;
BOOL bDctReevaluate;
BOOL bDctTraining;
BOOL bDctUnarchive;
} WantNotifications;
  extern WantNotifications tellMe;// notification bits to suppress/enable
extern const char*pGStopPhr;// "stop dictation" phrase for various languages
  //------------------------------------------------------------------------------
// Description: Dictation Grammar notification sink class definition
//------------------------------------------------------------------------------
class SpchDctSink : public ISRGramNotifySink
{
public:
ResultsList m_ResList;
  public:
SpchDctSink( SapiSpeech *pSpch);
~SpchDctSink();
  // IUnkown members that delegate to m_punkOuter
// Non-delegating object IUnknown
STDMETHODIMP QueryInterface (REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
  // ISRNotifySink
STDMETHODIMP BookMark (DWORD);
STDMETHODIMP Paused ();
STDMETHODIMP PhraseFinish (DWORD, QWORD, QWORD, PSRPHRASE, LPUNKNOWN);
STDMETHODIMP PhraseHypothesis (DWORD, QWORD, QWORD, PSRPHRASE, LPUNKNOWN);
STDMETHODIMP PhraseStart (QWORD);
STDMETHODIMP ReEvaluate (LPUNKNOWN);
STDMETHODIMP Training (DWORD);
STDMETHODIMP UnArchive (LPUNKNOWN);
void Cleanup();
  protected:
DWORD m_dwRefCnt;
SapiSpeech*m_pSpchObj;
private:
};
  
//------------------------------------------------------------------------------
// Description: Engine notification sink class definition
//------------------------------------------------------------------------------
class SpchEngSink : public ISRNotifySink
{
public:
DWORD m_dwKey;// key returned by engine when this not. is registered
// is used when engine wants to unregister this notification
  private:
  public:
SpchEngSink(SapiSpeech *pSpch);
~SpchEngSink();
  // IUnkown members that delegate to m_punkOuter
// Non-delegating object IUnknown
STDMETHODIMP QueryInterface (REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
  // ISRNotifySink
STDMETHODIMP AttribChanged (DWORD);
STDMETHODIMP Interference (QWORD, QWORD, DWORD);
STDMETHODIMP Sound (QWORD, QWORD);
STDMETHODIMP UtteranceBegin (QWORD);
STDMETHODIMP UtteranceEnd (QWORD, QWORD);
STDMETHODIMP VUMeter (QWORD, WORD);
  protected:
DWORD m_dwRefCnt;
SapiSpeech*m_pSpchObj;
};
  
//------------------------------------------------------------------------------
// Description: Dictation Grammar notification sink class definition
//------------------------------------------------------------------------------
class SpchLtdSink : public ISRGramNotifySink
{
  public:
SpchLtdSink( SapiSpeech *pSpch);
~SpchLtdSink();
  // IUnkown members that delegate to m_punkOuter
// Non-delegating object IUnknown
STDMETHODIMP QueryInterface (REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
  // ISRNotifySink
STDMETHODIMP BookMark (DWORD);
STDMETHODIMP Paused ();
STDMETHODIMP PhraseFinish (DWORD, QWORD, QWORD, PSRPHRASE, LPUNKNOWN);
STDMETHODIMP PhraseHypothesis (DWORD, QWORD, QWORD, PSRPHRASE, LPUNKNOWN);
STDMETHODIMP PhraseStart (QWORD);
STDMETHODIMP ReEvaluate (LPUNKNOWN);
STDMETHODIMP Training (DWORD);
STDMETHODIMP UnArchive (LPUNKNOWN);
  protected:
DWORD m_dwRefCnt;
SapiSpeech*m_pSpchObj;
private:
};
  
//------------------------------------------------------------------------------
// Description: Sapi speech engine interface class definition
//------------------------------------------------------------------------------
class SapiSpeech
{
private:// variables
PISRCENTRAL m_pSpchCentral;
PISRGRAMCOMMON m_pGramCommon;
PISRGRAMDICTATION m_pSpchGramDict;
PISRGRAMCOMMON m_pLtdGramCommon;
int state;
  public:// variables
CEdit*m_pCEdit;// This is where dictated text goes
CListBox*m_pStatusLB;
SpchDctSink*m_pSpchDctSink;
SpchLtdSink*m_pSpchLtdSink;
SpchEngSink*m_pSpchEngSink;
  private:// methods
const char *getGrammarLanguageSuffix(GUID &engGuid);
const char *getStopPhrase(const char *pCountryCode);
intinitForDictation(int Sequencing);
intinitGrammars( const char * const stopPhrase );
voidterminate();
  public:// methods
SapiSpeech(CEdit *pCEdit);
~SapiSpeech();
int getState(void) { return state; }
void logEventSink(SPCHEVENTID id, char *fmt, ...);
int activate(BOOL pause = FALSE);
int deactivate();
  void setDebugCtrl(CListBox *pLB) { m_pStatusLB = pLB; }
int resetContext( void );
  };
  

  #include "stdafx.h"
#include <winreg.h>
#include <speech.h>
#include "SetIBM.h"
#include "SetDlg.h"
  #ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
  
#define CTRL_ENGINE_CONNECT_ID 100
  externPISRENUMpISRModeEnum;
externPIVOICECMDpIVoiceCmd;
  /////////////////////////////////////////////////////////////////////////////
// CSetIBMApp
  BEGIN_MESSAGE_MAP(CSetIBMApp, CWinApp)
//{{AFX_MSG_MAP(CSetIBMApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
  /////////////////////////////////////////////////////////////////////////////
// CSetIBMApp construction
  CSetIBMApp::CSetIBMApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_bNoGUI = FALSE;
m_iExitCode = EXIT_OK;
}
  /////////////////////////////////////////////////////////////////////////////
// The one and only CSetIBMApp object
  CSetIBMApp theApp;
  /////////////////////////////////////////////////////////////////////////////
// CSetIBMApp initialization
  BOOL CSetIBMApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
  if ( FAILED(CoInitialize(NULL)) ) return FALSE;
  #ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
  // Perform our task
m_iExitCode = DoApplication();
  // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
CoUninitialize();
  return FALSE;
}
  int CSetIBMApp::ExitInstance()
{
  
// TODO: Add your specialized code here and/or call the base class
int rc = CWinApp::ExitInstance();

// return own exit code if not zero
return (m_iExitCode != 0 ? m_iExitCode : rc);
}
  /////////////////////////////////////////////////////////////////////////////
// CSetIBMApp
  CSetIBMCommandLineInfo::CSetIBMCommandLineInfo() : CCommandLineInfo()
{
m_bSwitchF = FALSE;
}
  void CSetIBMCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
// only process switches
if (!bFlag) return;
  switch(tolower(lpszParam[0]))
{
case 'f':// switch /f: (F)orce ViaVoice default
m_bSwitchF = TRUE;
break;
}
}
  int CSetIBMApp::DoApplication(void)
{
// Parse command line for parameters.
CSetIBMCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
  if ( cmdInfo.m_bSwitchF )
m_bNoGUI=TRUE;
  CSetIBMDlg dlg;
int rc;

if ( !m_bNoGUI )
{
m_pMainWnd = &dlg;// app's main wnd is the dlg
rc = dlg.DoModal();
}
else
rc = dlg.DoInvisible();// do not show any window
  switch (rc)
{
case IDOK:
// TODO: Place code here to handle when the dialog is
// dismissed with OK
break;
case IDCANCEL:
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
break;
case IDABORT:
//error occured
return EXIT_LANGNI;
case IDCLOSE:
return EXIT_ERR;
}
  return EXIT_OK;
}

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-381411-1-1.html 上篇帖子: IBM Guardium 下篇帖子: IBM-AIX裸设备添加表空间数据文
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表