[Top Page][All Pages][Recent Changes]

Edit History:Diff

Changes of 音声認識エンジンを使って文字を入力してみる since Epoch

  • + added lines
  • - deleted lines

Return to the edit history

- 
- 音声認識エンジンを使って文字を入力してみる。
- 
- 
- [[$$toc]]
- - →[[HSP3・サンプルスクリプト]]に戻る
- 
- ----
- 
- HSP3.1β1 XPsp2 で動作確認 (3.0a以降です。)~%
- オートメーションに対応していてイベントも取れます。
- サンプルもコンパクトに書けました。・・・~%
- が、しかし 色々とセットアップしなければいけません。~%
- 
- '''Microsoft SpeechSDK5.1'''(68MB) ~%
- '''5.1Language Pack'''(81.5 MB)~%
- (これに音声認識エンジンが含まれている訳ですが、両方インストールしないといけないそうです・・)~%
- 
- 二つとも無料で入手できます。下記のリンクからダウンロードできます。~%
- http://www.microsoft.com/speech/download/old/sapi5.asp~%
- (興味のある方は、がんばってダウンロードしてください。orz)
- 
- '''*注意*'''~%
- '''Microsoft SpeechSDK5.1'''からインストールしてください。~%
- その次に、'''5.1Language Pack''' をインストールしてください。~%
- (オフィスなどを持っている方は、インストール不要。)
- 
- インストール後、コントロールパネルの音声認識のプロパティーで~%
- '''Microsoft Japanese Recognizer v5.1'''を選択します。~%
- (ついでにプロファイルトレーニングをしておくと認識率がアップします。)~%
- 
- '''**マイクも必要です**'''~%
- 
- * スクリプト
- {{{
- ; <<<< HSP 3.1β1 サンプル >>>>
- ;
- ; 音声認識エンジンを使ってみる。
- ;
- 
- onexit gosub *exit
- 
- #define DIID__ISpeechRecoContextEvents "{7B8FCB42-0E9D-4F00-A048-7B04D6179D3D}"
- 
- 	screen 0,480,320
- 
- 	sdim buf,5000
- 	pos 10,10 :mesbox buf,300,300,0: boxid=objinfo(stat,2)
- 
- 	newcom RContext,"SAPI.SpSharedRecoContext"
-  
- 	Grammar= RContext("CreateGrammar", 0)
- 
- 	Grammar->"DictationLoad"
- 
- 	Grammar->"DictationSetState" 1
- 
- 	comevent Context_event, RContext,DIID__ISpeechRecoContextEvents,*event 
- stop
- 
- *event 
- 	dispid = comevdisp(Context_event)
- 	if dispid=7 {gosub *OnRecognition}
- 	if dispid=8 {gosub *OnHypothesis}
- return 
- 
- *OnRecognition
- 	
- 	comevarg RecoResult,Context_event,3,0
- 	
- 	PhraseInfo=RecoResult("PhraseInfo")
- 	
- 	tmp=PhraseInfo("GetText",0,-1,-1)
- 
- //	#define EM_REPLACESEL	$000000C2
- 	sendmsg  boxid, $000000C2,0,varptr(tmp)
- 
- 	//delcomする
- 	delcom PhraseInfo : PhraseInfo=0
- 	delcom RecoResult : RecoResult=0
- 
- return
- 
- *OnHypothesis
- 	
- 	comevarg RecoResult,Context_event,2,0
- 	
- 	PhraseInfo=RecoResult("PhraseInfo")
- 	
- 	title ""+PhraseInfo("GetText",0,-1,-1)
- 	
- 	delcom PhraseInfo : PhraseInfo=0
- 	delcom RecoResult : RecoResult=0
- 
- return
- 
- *exit
- 	Context_event=0
- 	Grammar=0
- 	RContext=0
- end
- 
- }}}
- * 解説
- 
- Recognition Event ( 認識文字が確定した時に通知されるイベントです。)~%
- {{{
- *OnRecognition ; dispid=7
- /*
-      StreamNumber As Long,                     ;comevarg   0
-      StreamPosition As Variant,                ;comevarg   1
-      RecognitionType As SpeechRecognitionType, ;comevarg   2  
-      Result As ISpeechRecoResult               ;comevarg   3
- */
- }}}
- 
- Hypothesis Event ( 認識候補が通知された事を表すイベントです。)~%
- {{{
- *OnHypothesis ; dispid=8
- /*
-      StreamNumber As Long,       ;comevarg   0
-      StreamPosition As Variant,  ;comevarg   1
-      Result As ISpeechRecoResult ;comevarg   2
- */
- }}}
- 
- イベントIDです。
- {{{
- ; _ISpeechRecoContextEvents ID
- #define StartStream                     1
- #define EndStream                       2
- #define Bookmark                        3
- #define SoundStart                      4
- #define SoundEnd                        5
- #define PhraseStart                     6
- #define Recognition                     7
- #define Hypothesis                      8
- #define PropertyNumberChange            9
- #define PropertyStringChange           10
- #define FalseRecognition               11
- #define Interference                   12
- #define RequestUI                      13
- #define RecognizerStateChange          14
- #define Adaptation                     15
- #define RecognitionForOtherContextxt   16
- #define AudioLevel                     17
- #define EnginePrivate                  18
- 
- }}}
- * メモ
- 2006/02/07 17:34:16 JST~%
- グーグルで、「SpeechSDK 5.1」で検索すると~%
- SDK5.1のセットアップ方法が詳しく説明してあるページが見つかります。
- 
- 2006/02/08 19:17:49 JST~%
- こちらに少し説明が載っています~%
- http://www.microsoft.com/japan/windowsxp/tabletpc/using/devtips/voice_reco.asp
- 
- 何気に'''mesbox'''のカーソルの位置が変ですね(笑
- 
- 2006/02/16 22:09:19 JST~%
- '''mesbox'''のカーソルの位置が気になってしょうがなかったので~%
- '''EM_REPLACESEL''' メッセージに変更 (XPsp2以外は試してません。)
- 
- 2006/04/08 13:46:34 JST~%
- 変更~%
- onexit *exit -> onexit gosub *exit