Julianで音声コマンダ for Squeak(linux) その2

Julian設定ファイル

-gram /cdrom/julius/julian-kit/sample_grammars/vfr
 →-gram /home/kawa90/work/julian/Samples/Smalltalk
-h /cdrom/phone_m/jnas/mono-mix16/gid/hmmdefs.gz	# HTK形式
 →-h /home/kawa90/work/julian/julian-kit-v3.1/model/phone_m/hmmdefs_monof_mix16_gid.binhmm
#-input mic		# マイクから直接入力
 →-input mic		# マイクから直接入力
  • gramオプションでは前記dfa,dict,termファイルがあるディレクトリを指定
  • hオプションではjulianキット同梱のデータを指定
  • 入力をマイクにする場合に、コメントアウトされている-input micの行で'#'をとる

Squeakで取り込み確認

SqueakでOSProcessを使い認識結果を取り込めるか実験するためのコードを次に示す。実際動かしたところ問題なく認識結果が取りこめた。ただし、このコードは単にJulianを起動して標準出力を得るため、julianプロセスの終了などは行わない。

'From Squeakland 3.8-05 of 7 September 2005 [latest update: #527] on 4 January 2007 at 9:40:44 pm'!
StringMorph subclass: #JulianMorph
	instanceVariableNames: 'process stdoutStream'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Julian'!

!JulianMorph methodsFor: 'proc' stamp: 'hkawa 1/4/2007 21:38'!
createProcess
	| pipe2 output desc args |
	pipe2 _ OSPipe nonBlockingPipe.
	output _ pipe2 writer.
	stdoutStream _ pipe2 reader.
	desc _ Array
				with: nil
				with: output
				with: nil.
	args := Array
				with: '-quiet'
				with: '-C'
				with: '/home/kawa90/work/julian/julius-3.5.3/k.jconf'.
	process _ OSProcess thisOSProcess
				forkJob: '/home/kawa90/work/julian/julius-3.5.3/julius/julian'
				arguments: args
				environment: nil
				descriptors: desc.
	output close.! !


!JulianMorph methodsFor: 'initialization' stamp: 'hkawa 1/4/2007 21:28'!
initialize
	super initialize.
	self createProcess.
! !


!JulianMorph methodsFor: 'stepping and presenter' stamp: 'hkawa 1/4/2007 21:33'!
step
	| str |
	str := stdoutStream upToEnd.
	(str size > 0) ifTrue: [
		self contents: str.
	].! !


!JulianMorph methodsFor: 'testing' stamp: 'hkawa 1/4/2007 21:30'!
stepTime
	^ 200.! !