Dim WithEvents RecoContext As SpeechLib.SpSharedRecoContext
Dim Grammar As SpeechLib.ISpeechRecoGrammar
Dim m_bRecoRunning As Boolean
Dim m_cChars As Short
Private Sub SimpleDict_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
SetState(False)
m_cChars = 0
End Sub
Private Sub btnStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnStart.Click
System.Diagnostics.Debug.Assert(Not m_bRecoRunning, "")
If (RecoContext Is Nothing) Then
RecoContext = New SpeechLib.SpSharedRecoContext
Grammar = RecoContext.CreateGrammar(1)
Grammar.DictationLoad()
End If
Grammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSActive)
SetState(True)
End Sub
Private Sub btnStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnStop.Click
System.Diagnostics.Debug.Assert(m_bRecoRunning, "")
Grammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSInactive)
SetState(False)
End Sub
Private Sub RecoContext_Recognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult) Handles RecoContext.Recognition
Dim strText As String
strText = Result.PhraseInfo.GetText
txtSpeech.SelectionStart = m_cChars
txtSpeech.SelectedText = strText & " "
m_cChars = m_cChars + 1 + Len(strText)
End Sub
Private Sub SetState(ByVal bNewState As Boolean)
m_bRecoRunning = bNewState
btnStart.Enabled = Not m_bRecoRunning
btnStop.Enabled = m_bRecoRunning
End Sub
这段代码如何转为C#呢?
Dim Grammar As SpeechLib.ISpeechRecoGrammar
Dim m_bRecoRunning As Boolean
Dim m_cChars As Short
Private Sub SimpleDict_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
SetState(False)
m_cChars = 0
End Sub
Private Sub btnStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnStart.Click
System.Diagnostics.Debug.Assert(Not m_bRecoRunning, "")
If (RecoContext Is Nothing) Then
RecoContext = New SpeechLib.SpSharedRecoContext
Grammar = RecoContext.CreateGrammar(1)
Grammar.DictationLoad()
End If
Grammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSActive)
SetState(True)
End Sub
Private Sub btnStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnStop.Click
System.Diagnostics.Debug.Assert(m_bRecoRunning, "")
Grammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSInactive)
SetState(False)
End Sub
Private Sub RecoContext_Recognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult) Handles RecoContext.Recognition
Dim strText As String
strText = Result.PhraseInfo.GetText
txtSpeech.SelectionStart = m_cChars
txtSpeech.SelectedText = strText & " "
m_cChars = m_cChars + 1 + Len(strText)
End Sub
Private Sub SetState(ByVal bNewState As Boolean)
m_bRecoRunning = bNewState
btnStart.Enabled = Not m_bRecoRunning
btnStop.Enabled = m_bRecoRunning
End Sub
这段代码如何转为C#呢?
解决方案 »
- 怎样多线程调用同一个EXE,并且只产生一个EXE的进程呢?
- Label背景色设成透明后刷新很慢
- winForm打开关闭界面的问题
- 让.aspx文件为空,用户请求网页后,再在程序里加载网页,应该怎么办?
- MenuStrip_click事件如何得到单击的是菜单的哪个项和他的name属性
- [C# - WinForms] DataGridView 的 Button 列中的"按钮"如何能设置成为按下去不弹起来那种按钮?
- 字符串截取问题
- 关于反射的问题,还请大家帮忙看下
- 菜鸟求助:Http请求连接超时怎么处理啊?能自己设超时的时间吗?
- 精品oa问题集锦[呵呵,是我要问的问题]
- 如何备份windows系统的语音数据库
- 有一些.net问题,非常典型,非常值得测试的!!
SpeechLib.ISpeechRecoGrammar Grammar;
bool m_bRecoRunning;
short m_cChars; private void SimpleDict_Load(object eventSender, System.EventArgs eventArgs)
{
SetState(false);
m_cChars = 0;
} private void btnStart_Click(object eventSender, System.EventArgs eventArgs)
{
System.Diagnostics.Debug.Assert(!m_bRecoRunning, "");
if ((RecoContext == null)) {
RecoContext = new SpeechLib.SpSharedRecoContext();
Grammar = RecoContext.CreateGrammar(1);
Grammar.DictationLoad();
}
Grammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSActive);
SetState(true);
} private void btnStop_Click(object eventSender, System.EventArgs eventArgs)
{
System.Diagnostics.Debug.Assert(m_bRecoRunning, "");
Grammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSInactive);
SetState(false);
}
private void RecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechLib.SpeechRecognitionType RecognitionType, SpeechLib.ISpeechRecoResult Result)
{
string strText;
strText = Result.PhraseInfo.GetText;
txtSpeech.SelectionStart = m_cChars;
txtSpeech.SelectedText = strText + " ";
m_cChars = m_cChars + 1 + Strings.Len(strText);
}
private void SetState(bool bNewState)
{
m_bRecoRunning = bNewState;
btnStart.Enabled = !m_bRecoRunning;
btnStop.Enabled = m_bRecoRunning;
}
Result.PhraseInfo.GetText()
Grammar.DictationLoad();