• R/O
  • SSH

dialog-project: Commit

a dialog project for development version.


Commit MetaInfo

Revision5298508466dd573c39c8128d94114b5115802b96 (tree)
Zeit2010-10-14 18:08:44
AutorTakuya Nishimoto <nishimoto@m.ie...>
CommiterTakuya Nishimoto

Log Message

initial

Ändern Zusammenfassung

Diff

diff -r 000000000000 -r 5298508466dd cafe.vxml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cafe.vxml Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,186 @@
1+<?xml version="1.0" encoding="utf-8" ?>
2+<!--
3+#
4+# $Id: cafe.vxml,v 1.1 2008/10/05 01:33:41 nishimoto Exp $
5+#
6+-->
7+<vxml version="2.0" xml:lang="ja">
8+
9+<!-- *********************************************** -->
10+
11+<form id="form1">
12+
13+<block>
14+<!--
15+<native>to @AM-MCL set AutoEmotionSpeak = 1</native>
16+<native>to @AM-MCL set AutoMove = 1</native>
17+<native>to @AM-MCL set AutoGaze = 1</native>
18+-->
19+<native>to @FS-MCL set Background = woman01 bg3</native>
20+<native>to @AM-MCL set Mask = woman01 HAPPY 100 0 0 0</native>
21+</block>
22+
23+<field name="takeout">
24+
25+ <prompt>
26+ ガラティアカフェにようこそ。テイクアウトですか?
27+ </prompt>
28+
29+ <prompt count="2">
30+ お客様はお持ち帰りでの御利用ですか?
31+ </prompt>
32+
33+ <grammar version="1.0" root="#takeout_rule">
34+ <rule id="takeout_rule">
35+ <one-of>
36+ <item> <token sym="まいくてすと"> マイクテスト </token> </item>
37+
38+ <item> <token sym="はい" slot="takeout" value="y"> はい </token> </item>
39+ <item> <token sym="ていくあうと" slot="takeout" value="y"> テイクアウト </token> </item>
40+ <item> <token sym="ていくあうとです" slot="takeout" value="y"> テイクアウトです </token> </item>
41+
42+ <item> <token sym="もちかえり" slot="takeout" value="y"> 持ち帰り </token> </item>
43+ <item> <token sym="もちかえりです" slot="takeout" value="y"> 持ち帰りです </token> </item>
44+
45+ <item> <token sym="いいえ" slot="takeout" value="n"> いいえ </token> </item>
46+ <item> <token sym="てんない" slot="takeout" value="n"> 店内 </token> </item>
47+ <item> <token sym="てんないです" slot="takeout" value="n"> 店内です </token> </item>
48+ </one-of>
49+ </rule>
50+ </grammar>
51+
52+ <filled>
53+ <if cond="takeout == 'y'">
54+ テイクアウトですね。
55+ <else/>
56+ 店内でのお召し上がりですね。
57+ </if>
58+ <goto next="#form2"/>
59+ </filled>
60+
61+</field>
62+
63+</form>
64+
65+<form id="form2">
66+
67+<field name="drink">
68+
69+ <prompt>
70+ お飲み物は何になさいますか?
71+ </prompt>
72+
73+ <prompt count="2">
74+ お飲み物はコーヒーと紅茶がございます。どちらになさいますか?
75+ </prompt>
76+
77+ <grammar version="1.0" root="#drink_field_rule">
78+ <rule id="drink_field_rule">
79+ <one-of>
80+ <item> <token sym="まいくてすと"> マイクテスト </token> </item>
81+ <item>
82+ <ruleref uri="#etto_rule"/>
83+ <ruleref uri="#drink_order_rule"/>
84+ <ruleref uri="#kudasai_rule"/>
85+ </item>
86+ <item>
87+ <ruleref uri="#drink_order_rule"/>
88+ <ruleref uri="#kudasai_rule"/>
89+ </item>
90+ <item>
91+ <ruleref uri="#etto_rule"/>
92+ <ruleref uri="#drink_order_rule"/>
93+ </item>
94+ </one-of>
95+ </rule>
96+
97+ <rule id="drink_order_rule">
98+ <one-of>
99+ <item> <ruleref uri="#drink_rule"/> </item>
100+ <item> <ruleref uri="#hotice_rule"/> </item>
101+ <item>
102+ <ruleref uri="#hotice_rule"/>
103+ <ruleref uri="#drink_rule"/>
104+ </item>
105+ <item>
106+ <ruleref uri="#drink_rule"/>
107+ <ruleref uri="#no_rule"/>
108+ <ruleref uri="#hotice_rule"/>
109+ </item>
110+ </one-of>
111+ </rule>
112+
113+ <rule id="drink_rule">
114+ <one-of>
115+ <item> <token sym="こーひー" slot="drink"> コーヒー </token> </item>
116+ <item> <token sym="こうちゃ" slot="drink"> 紅茶 </token> </item>
117+ </one-of>
118+ </rule>
119+
120+ <rule id="hotice_rule">
121+ <one-of>
122+ <item> <token sym="ほっと" slot="hotice"> ホット </token> </item>
123+ <item> <token sym="あいす" slot="hotice"> アイス </token> </item>
124+ </one-of>
125+ </rule>
126+
127+ <rule id="etto_rule">
128+ <one-of>
129+ <item> <token sym="えーっと"> えーっと </token> </item>
130+ <item> <token sym="あのー"> あのー </token> </item>
131+ </one-of>
132+ </rule>
133+
134+ <rule id="no_rule">
135+ <one-of>
136+ <item> <token sym="の"> の </token> </item>
137+ <item> <token sym="お"> を </token> </item>
138+ </one-of>
139+ </rule>
140+
141+ <rule id="kudasai_rule">
142+ <one-of>
143+ <item> <token sym="ください"> ください </token> </item>
144+ <item> <token sym="おねがい"> お願い </token> </item>
145+ <item> <token sym="おねがいします"> お願いします </token> </item>
146+ </one-of>
147+ </rule>
148+
149+ </grammar>
150+
151+
152+</field>
153+
154+<field name="hotice">
155+
156+ <prompt>
157+ ホットとアイスのどちらがいいですか?
158+ </prompt>
159+
160+ <grammar version="1.0" root="#hotice_field_rule">
161+ <rule id="hotice_field_rule">
162+ <one-of>
163+ <item> <token sym="まいくてすと"> マイクテスト </token> </item>
164+ <item> <token sym="ほっと" slot="hotice"> ホット </token> </item>
165+ <item> <token sym="ほっとです" slot="hotice" value="ホット"> ホットです </token> </item>
166+
167+ <item> <token sym="あいす" slot="hotice"> アイス </token> </item>
168+ <item> <token sym="あいすです" slot="hotice" value="アイス"> アイスです </token> </item>
169+ </one-of>
170+ </rule>
171+ </grammar>
172+
173+</field>
174+
175+<filled>
176+ <value expr="drink"/>の<value expr="hotice"/>ですね?。
177+ お席までお持ちします。御利用ありがとうございます。
178+ <goto next="#form1"/>
179+</filled>
180+
181+</form>
182+
183+<!-- *********************************************** -->
184+
185+</vxml>
186+
diff -r 000000000000 -r 5298508466dd config/runner.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config/runner.yml Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,6 @@
1+# runner.yml
2+dm:
3+ jar: /lab/common/src/nishi/sfjp/dialog-studio-java/bin/gdm.jar
4+
5+# end of file
6+
diff -r 000000000000 -r 5298508466dd modules/AM-MCL.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/AM-MCL.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,420 @@
1+#!/usr/bin/ruby -Ke -vw
2+# $Id: AM-MCL.rb,v 1.4 2008/12/19 05:40:15 nishimoto Exp $
3+#
4+# by Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
5+
6+# ------------------------------
7+
8+require 'GalateaBase.rb'
9+require 'Agent.rb'
10+require 'thread'
11+require 'optparse'
12+require 'yaml'
13+
14+class AM_MCL < GalateaBase
15+
16+ def initialize
17+ super
18+ @modulename = "AM-MCL"
19+ @debug = false
20+
21+ @useDIM = 0 # use DIM.rb (for AutoGaze)
22+ @useEventViewer = 0 # use GEV (experimental)
23+
24+ #
25+ # sequence for Speak
26+ # state0 : IDLE
27+ # state1 : wait FSM/SSM "rep Speak.stat = READY"
28+ # state2 : wait FSM/SSM "rep Speak.stat = IDLE"
29+ #
30+ # sequence for MouthMove
31+ # state0 : IDLE
32+ # state3 : wait FSM "rep Speak.stat = READY"
33+ # state4 : wait FSM "rep Speak.stat = IDLE"
34+ #
35+ @state = 0
36+
37+ @ready_ssm = false
38+ @ready_fsm = false
39+
40+ # @fsm_wait_time = 0
41+ # @ssm_wait_time = 0
42+
43+ @auto_emotion_speak = 0
44+ print_debug "initializing..."
45+ end
46+
47+ def setup(config_file = nil)
48+ agents_array = nil
49+ @curr_agent = nil
50+ unless config_file.nil?
51+ begin
52+ obj = YAML.load(File.new(config_file))
53+ if obj.key?('agents')
54+ agents_array = obj['agents']
55+ @agents = {}
56+ agents_array.each do |i|
57+ name, mask, speaker = i['name'], i['mask'], i['speaker']
58+ @agents[name] = Agent.new(mask, speaker)
59+ @curr_agent = name if @curr_agent.nil?
60+ end
61+ end
62+ if obj.key?('default_agent')
63+ @curr_agent = obj['default_agent']
64+ end
65+ rescue
66+ print_debug "#{config_file} read error."
67+ end
68+ end
69+ if agents_array.nil?
70+ @agents = {}
71+ @agents["man01"] = Agent.new('man01', 'male01')
72+ @agents["man02"] = Agent.new('man02', 'm001')
73+ @agents["woman01"] = Agent.new('woman01', 'female01')
74+ @curr_agent = "woman01"
75+ end
76+ end
77+
78+ attr_accessor :state, :ready_ssm, :ready_fsm, :agents, :curr_agent, :auto_emotion_speak
79+
80+ #def sendAgentSpeakState
81+ # send_set( "FS-MCL", "AgentSpeakState", self.state )
82+ # if @useEventViewer == 1
83+ # send_set( "GEV", "AgentSpeakState", self.state )
84+ # end
85+ # if @useDIM == 1
86+ # send_set( "DIM", "AgentSpeakState", self.state )
87+ # end
88+ #end
89+
90+ def curr_mouth_scale
91+ self.agents[self.curr_agent].mouth_scale
92+ end
93+
94+
95+ def curr_output_text(arg)
96+ if self.auto_emotion_speak == 1
97+ print_debug "open_tag : #{self.agents[self.curr_agent].open_tag}"
98+ print_debug "close_tag: #{self.agents[self.curr_agent].close_tag}"
99+ return "#{self.agents[self.curr_agent].open_tag}#{arg}#{self.agents[self.curr_agent].close_tag}"
100+ else
101+ return arg
102+ end
103+ end
104+
105+
106+ def do_set_speak(arg)
107+ if arg == "STOP"
108+ self.state = 0
109+ #sendAgentSpeakState
110+ print_out "to \@FSM set Speak = STOP"
111+ print_out "to \@SSM set Speak = STOP"
112+ self.ready_ssm = false
113+ self.ready_fsm = false
114+ print_debug "state: #{self.state}"
115+
116+ else
117+ # if speaking, stop automatically
118+ if self.state != 0
119+ print_out "to \@FSM set Speak = STOP"
120+ print_out "to \@SSM set Speak = STOP"
121+ end
122+
123+ self.state = 1
124+ #sendAgentSpeakState
125+ print_out "to \@FSM set MouthScale = #{curr_mouth_scale}"
126+ print_out "to \@FSM prop Speak.stat = AutoOutput"
127+ print_out "to \@SSM prop Speak.stat = AutoOutput"
128+ print_out "to \@SSM prop Speak.pho = AutoOutput"
129+ print_out "to \@SSM set Text = #{curr_output_text(arg)}"
130+ self.ready_ssm = false
131+ self.ready_fsm = false
132+ print_debug "state: #{self.state}"
133+ end
134+ end
135+
136+
137+ def do_set_move_mouth(arg)
138+ case arg
139+ when "STOP"
140+ self.state = 0
141+ #sendAgentSpeakState
142+ print_out "to \@SSM set Speak = STOP"
143+ self.ready_ssm = false
144+ self.ready_fsm = false
145+ print_debug "state: #{self.state}"
146+ when /scale\s+(\S+)\s+(.*)/
147+ self.state = 3
148+ #sendAgentSpeakState
149+ # print_out "to \@FSM prop Speak.stat = AutoOutput"
150+ print_out "to \@FSM set MouthScale = #{$1}"
151+ print_out "to \@FSM set LipSync.pho = #{$2}"
152+ self.ready_fsm = false
153+ print_debug "state: #{self.state}"
154+ else
155+ self.state = 3
156+ #sendAgentSpeakState
157+ # print_out "to \@FSM prop Speak.stat = AutoOutput"
158+ print_out "to \@FSM set MouthScale = #{curr_mouth_scale}"
159+ print_out "to \@FSM set LipSync.pho = #{arg}"
160+ self.ready_fsm = false
161+ print_debug "state: #{self.state}"
162+ end
163+ end
164+
165+
166+ def curr_speaker
167+ self.agents[self.curr_agent].speaker
168+ end
169+
170+
171+ def do_set_mask(arg)
172+ case arg
173+ when /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
174+ print_out "to \@FS-MCL set Mask = #{$1}"
175+ print_out "to \@FS-MCL set EmotionNow = #{$2} #{$3}"
176+ print_out "to \@FS-MCL set RotNow = #{$4} #{$5} #{$6}"
177+ if self.curr_agent != $1
178+ self.curr_agent = $1
179+ print_out "to \@SSM set Speaker = #{curr_speaker}"
180+ end
181+ set_emotion $2, $3.to_f
182+ when /(\S+)\s+(\S+)\s+([0-9\.\+\-]+)/
183+ if self.curr_agent != $1
184+ self.curr_agent = $1
185+ print_out "to \@SSM set Speaker = #{curr_speaker}"
186+ end
187+ set_emotion $2, $3.to_f
188+ print_out "to \@FS-MCL set Mask = #{$1}"
189+ print_out "to \@FS-MCL set EmotionNow = #{$2} #{$3}"
190+ when /(\S+)\s+(\S+)/
191+ if self.curr_agent != $1
192+ self.curr_agent = $1
193+ print_out "to \@SSM set Speaker = #{curr_speaker}"
194+ end
195+ set_emotion $2
196+ print_out "to \@FS-MCL set Mask = #{$1}"
197+ print_out "to \@FS-MCL set EmotionNow = #{$2}"
198+ when /(\S+)/
199+ if self.curr_agent != $1
200+ self.curr_agent = $1
201+ print_out "to \@SSM set Speaker = #{curr_speaker}"
202+ end
203+ print_out "to \@FS-MCL set Mask = #{$1}"
204+ end
205+ end
206+
207+
208+ def set_emotion(type, level=90, duration=0)
209+ # duration is not used
210+=begin
211+ @mutex.synchronize do
212+ @agents[@curr_agent].set_emotion(type, level)
213+ end
214+=end
215+ self.agents[self.curr_agent].set_emotion(type, level)
216+ end
217+
218+
219+ def do_set_emotion(arg)
220+ print_out "to \@FS-MCL set Emotion = #{arg}"
221+ case arg
222+ when /(.+)\s+([0-9\.\+\-]+)\s+([0-9\.\+\-]+)/
223+ set_emotion($1, $2.to_f, $3.to_f)
224+ when /(.+)\s+([0-9\.\+\-]+)/
225+ set_emotion($1, $2.to_f)
226+ when /(.+)/
227+ set_emotion($1)
228+ end
229+ end
230+
231+
232+ def set_speak_speed(arg)
233+ self.agents[self.curr_agent].ssmspeed = arg.to_f
234+ end
235+
236+
237+ def do_set(slot, arg)
238+ super
239+ begin
240+ case slot
241+ when "Speak"
242+ do_set_speak(arg)
243+ when "MoveMouth"
244+ do_set_move_mouth(arg)
245+ when "SpeakSpeed"
246+ set_speak_speed(arg)
247+ when "AutoMove"
248+ print_out "to \@FS-MCL set AutoMove = #{arg}"
249+ when "AutoGaze"
250+ if @useDIM
251+ print_out "to \@DIM set AutoGaze = #{arg}"
252+ end
253+ when "Mask"
254+ do_set_mask(arg)
255+ when "Emotion"
256+ do_set_emotion(arg)
257+ when "AutoEmotionSpeak"
258+ self.auto_emotion_speak = arg.to_i
259+ end
260+ rescue StandardError => e
261+ print_out "to \@DM From \@AM-MCL tell #{e.to_s}"
262+ end
263+ end
264+
265+
266+ def accept_from_state0(mod, str)
267+ end
268+
269+
270+ def accept_from_state1(mod, str)
271+ # waiting responce of "@SSM set Text = value"
272+ case mod
273+ when "SSM"
274+ case str
275+ when /rep\s+Speak\.pho\s*=\s*(.*)$/
276+ phones = $1
277+ phones.gsub!( /\[/, " " )
278+ phones.gsub!( /\]/, "" )
279+ # sil 10 k 100 o 85 N 90 n 25 i 60 ch 105 i 50 w 50 a 95 sil 10
280+ print_debug phones
281+ # print_out "to \@FSM prop Speak.stat = AutoOutput"
282+ print_out "to \@FSM set LipSync.pho = #{phones}"
283+ print_out "to \@FSM inq Speak.stat"
284+ print_debug "state: #{self.state} speak.pho ready"
285+ when /rep\s+Speak\.stat\s*=\s*READY\s*$/
286+ self.ready_ssm = true
287+ print_debug "state: #{self.state} ready_ssm"
288+ when /rep\s+Speak\.stat\s*=\s*ERROR\s*$/
289+ self.state = 0
290+ #sendAgentSpeakState
291+ self.ready_ssm = false
292+ self.ready_fsm = false
293+ print_debug "state: #{self.state}"
294+ end
295+ when "FSM"
296+ case str
297+ when /rep\s+Speak\.stat\s*=\s*READY\s*$/
298+ self.ready_fsm = true
299+ print_debug "state: #{self.state} ready_fsm"
300+ when /rep\s+Speak\.stat\s*=\s*ERROR\s*$/
301+ self.state = 0
302+ #sendAgentSpeakState
303+ self.ready_ssm = false
304+ self.ready_fsm = false
305+ print_debug "state: #{self.state}"
306+ end
307+ end
308+
309+ if self.ready_fsm && self.ready_ssm
310+ self.state = 2
311+ #sendAgentSpeakState
312+ # print_out "to \@SSM set Save = _speech.raw"
313+ # print_out "to \@SSM set SpeechFile = _speech.raw"
314+ # $ play -t .sw -x -r 16000 ../../SSM/_speech.raw
315+
316+ # print_out "to \@SSM set Speak = +100" # for SSMclient.rb
317+ print_out "to \@SSM set Speak = + 0" #
318+
319+ print_out "to \@FSM set Speak = + 0"
320+ print_debug "state: #{self.state} Speak start"
321+ end
322+ end
323+
324+
325+ def accept_from_state2(mod, str)
326+ #
327+ if mod == "SSM" && /rep\s+Speak\.stat\s*=\s*IDLE\s*$/ =~ str
328+ self.ready_ssm = false
329+ # print_debug "state: #{self.state} ready_ssm = false"
330+
331+ elsif mod == "FSM" && /rep\s+Speak\.stat\s*=\s*IDLE\s*$/ =~ str
332+ self.ready_fsm = false
333+ # print_debug "state: #{self.state} ready_fsm = false"
334+
335+ end
336+
337+ if self.ready_fsm == false && self.ready_ssm == false
338+ self.state = 0
339+ print_debug "state: #{self.state} Speak end"
340+ #sendAgentSpeakState
341+ end
342+ end
343+
344+
345+ def accept_from_state3(mod, str)
346+ if mod == "FSM" && /rep\s+Speak\.stat\s*=\s*READY\s*$/ =~ str
347+ self.state = 4
348+ #sendAgentSpeakState
349+ self.ready_ssm = false
350+ self.ready_fsm = true
351+ print_debug "state: #{self.state} ready_fsm"
352+ print_out "to \@FSM set Speak = + 0"
353+ print_debug "state: #{self.state} Speak start"
354+
355+ elsif mod == "FSM" && /rep\s+Speak\.stat\s*=\s*ERROR\s*$/ =~ str
356+ self.state = 0
357+ #sendAgentSpeakState
358+ self.ready_ssm = false
359+ self.ready_fsm = false
360+ print_debug "state: #{self.state}"
361+ end
362+ end
363+
364+
365+ def accept_from_state4(mod, str)
366+ if mod == "FSM" && /rep\s+Speak\.stat\s*=\s*IDLE\s*$/ =~ str
367+ self.state = 0
368+ print_debug "state: #{self.state} Speak end"
369+ self.ready_fsm = false
370+ #sendAgentSpeakState
371+ end
372+ end
373+
374+
375+ def accept_from(mod, str)
376+ #
377+ # From @XXX set YYY = ZZZ
378+ #
379+ if /^\s*set\s+([^\s=]*)\s*=\s*(.*)$/ =~ str
380+ do_set $1, $2
381+ return
382+ end
383+
384+ #
385+ # lipsync
386+ #
387+ case self.state
388+ when 1
389+ accept_from_state1(mod, str)
390+ when 2
391+ accept_from_state2(mod, str)
392+ when 3
393+ accept_from_state3(mod, str)
394+ when 4
395+ accept_from_state4(mod, str)
396+ end
397+
398+ end
399+
400+ def accept_to(mod, str)
401+ print_out "to \@MON set SysLogText = #{str}"
402+ end
403+
404+end
405+
406+# ------------------------------
407+
408+config_file = nil
409+ARGV.options do |opt|
410+ opt.on('-C am_mcl.conf') do |v|
411+ config_file = v
412+ end
413+ opt.parse!
414+end
415+
416+m = AM_MCL.new
417+m.setup(config_file)
418+m.run
419+
420+# end of file
diff -r 000000000000 -r 5298508466dd modules/Agent.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/Agent.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,312 @@
1+#!/usr/bin/ruby -Ke -w
2+# $Id: Agent.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
3+#
4+# by Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
5+
6+# ------------------------------
7+
8+class Agent
9+
10+ HEAD_ROT_X_MAX = 10
11+ HEAD_ROT_Y_MAX = 10
12+ HEAD_ROT_Z_MAX = 10
13+
14+ EYE_ROT_X_MAX = 20
15+ EYE_ROT_Y_MAX = 10
16+ EYE_ROT_Z_MAX = 20
17+
18+ # (mask, speaker, rot_x, rot_y, trans_x, trans_y, scale)
19+ # rot_z = 0
20+ # @agents["man01"] = Agent.new('man01', 'male01', 5, 3, -0.05, 0, 1.2 )
21+
22+ def initialize(mask, speaker, rot_x=0, rot_y=0, trans_x=0, trans_y=0, scale=1)
23+ # clock
24+ @clock = 0.0
25+ @clock_head = 0.0
26+
27+ # speak
28+ @speaker = speaker
29+ @ssmspeed = 1.0
30+
31+ # mask
32+ @mask = mask
33+
34+ # agent trans
35+ @agent_trans_x_base, @agent_trans_y_base = trans_x, trans_y
36+ @agent_trans_x, @agent_trans_y = trans_x, trans_y
37+
38+ # agent scale
39+ @agent_scale_base = scale
40+ @agent_scale = scale
41+
42+ # agent rot
43+ @agent_rot_x_base, @agent_rot_y_base = rot_x, rot_y
44+ # @agent_rot_z_base = 0
45+
46+ @target_agent_rot_count = 0
47+ @target_agent_rot_dx = 0.0
48+ @target_agent_rot_dy = 0.0
49+ # @target_agent_rot_dz = 0.0
50+
51+ @agent_rot_x, @agent_rot_y = rot_x, rot_y
52+ # @agent_rot_z = 0
53+
54+ # head rot
55+ @head_rot_x_base = 0
56+ @head_rot_y_base = 0
57+ @head_rot_z_base = 0
58+
59+ @target_head_rot_count = 0
60+ @target_head_rot_dx = 0.0
61+ @target_head_rot_dy = 0.0
62+ @target_head_rot_dz = 0.0
63+
64+ @head_rot_x = 0
65+ @head_rot_y = 0
66+ @head_rot_z = 0
67+
68+ # eye rot
69+ @eye_rot_x = 0
70+ @eye_rot_y = 0
71+ @eye_rot_z = 0
72+
73+ # exp
74+ @exp_level = 0.0
75+ @exp_level_base = 0.0
76+ @exp_level_target = 0.0
77+ @exp_level_max = 100.0
78+ @exp_level_range = 10.0
79+ @exp_type = 'NEUTRAL'
80+ @exp_type_target = 'NEUTRAL'
81+
82+ @agentSpeakState = 0
83+
84+ @nodding_range = 0.0
85+ @nodding_range_delta = 0.0
86+ @nodding_count = 0
87+ @nodding_head_x = 0.0
88+
89+ end
90+
91+
92+ def calc
93+ calc_head_movement
94+ calc_agent_movement
95+ calc_emotion_change
96+ end
97+
98+ def calc_head_movement
99+ if @target_head_rot_count > 0
100+ @head_rot_x_base += @target_head_rot_dx
101+ @head_rot_y_base += @target_head_rot_dy
102+ @head_rot_z_base += @target_head_rot_dz
103+ @target_head_rot_count -= 1
104+ end
105+
106+ # x:up/down y:left/right z:rotate
107+ @head_rot_x = @head_rot_x_base + Math.cos(@clock_head * 0.4) * 1.10 + Math.cos(@clock_head * 5.0 ) * 0.50
108+ @head_rot_y = @head_rot_y_base + Math.cos(@clock_head * 0.1) * 0.05 + Math.cos(@clock_head * 4.0 ) * 0.02
109+ @head_rot_z = @head_rot_z_base + Math.cos(@clock_head * 0.9) * 0.15 + Math.cos(@clock_head * 3.0 ) * 0.07
110+
111+ # nodding
112+ calc_nodding()
113+ @head_rot_x += self.nodding_head_x
114+
115+ if @head_rot_x < -HEAD_ROT_X_MAX then @head_rot_x = -HEAD_ROT_X_MAX end
116+ if @head_rot_y < -HEAD_ROT_Y_MAX then @head_rot_y = -HEAD_ROT_Y_MAX end
117+ if @head_rot_z < -HEAD_ROT_Z_MAX then @head_rot_z = -HEAD_ROT_Z_MAX end
118+
119+ if @head_rot_x > HEAD_ROT_X_MAX then @head_rot_x = HEAD_ROT_X_MAX end
120+ if @head_rot_y > HEAD_ROT_Y_MAX then @head_rot_y = HEAD_ROT_Y_MAX end
121+ if @head_rot_z > HEAD_ROT_Z_MAX then @head_rot_z = HEAD_ROT_Z_MAX end
122+ end
123+
124+ def calc_agent_movement
125+ if @target_agent_rot_count > 0
126+ @agent_rot_x_base += @target_agent_rot_dx
127+ @agent_rot_y_base += @target_agent_rot_dy
128+ # @agent_rot_z_base += @target_agent_rot_dz
129+ @target_agent_rot_count -= 1
130+ end
131+
132+ @agent_rot_x = @agent_rot_x_base + Math.cos(@clock * 1.6) * 0.20
133+ @agent_rot_y = @agent_rot_y_base + Math.cos(@clock * 1.2) * 0.10
134+ # @agent_rot_z = @agent_rot_z_base + Math.cos(@clock * 1.3) * 0.05
135+ @agent_trans_x = @agent_trans_x_base + Math.cos(@clock * 2.5) * 0.001
136+ @agent_trans_y = @agent_trans_y_base + Math.cos(@clock * 1.5) * 0.001
137+ @agent_scale = @agent_scale_base + Math.cos(@clock * 0.2) * 0.005
138+ end
139+
140+ def set_emotion(type, level)
141+ @exp_type_target = type
142+ @exp_level_target = level
143+ @exp_level_max = level
144+ end
145+
146+ def set_emotion_now(type, level)
147+ @exp_type_target = type
148+ @exp_level_target = level
149+ @exp_level_max = level
150+
151+ @exp_type = type
152+ @exp_level = level
153+ end
154+
155+ def calc_emotion_change
156+ if @exp_type != @exp_type_target
157+ if @exp_level_base < 10
158+ @exp_level_base = 0
159+ @exp_type = @exp_type_target
160+ else
161+ @exp_level_base -= 20
162+ end
163+ else
164+ @exp_level_base += (@exp_level_target - @exp_level_base) * 0.5
165+ end
166+
167+ @exp_level = @exp_level_base + Math.cos(@clock * 5) * @exp_level_range
168+
169+ if @exp_level > @exp_level_max then @exp_level = @exp_level_max end
170+ if @exp_level < 0 then @exp_level = 0 end
171+
172+ end
173+
174+ def set_target_rot(target_x, target_y, target_z)
175+ set_target_agent_rot(target_x, target_y, target_z)
176+ set_target_head_rot(target_x, target_y, target_z)
177+ set_target_eye_rot(target_x, target_y, target_z)
178+ end
179+
180+ def set_rot_now(target_x, target_y, target_z)
181+ @agent_rot_x_base, @agent_rot_y_base = target_x, target_y
182+ @head_rot_x_base, @head_rot_y_base, @head_rot_z_base = target_x, target_y, target_z
183+ set_target_rot(target_x, target_y, target_z)
184+ end
185+
186+ def set_target_head_rot(target_x, target_y, target_z)
187+ @target_head_rot_count = 3
188+ @target_head_rot_dx = (target_x - @head_rot_x_base) / @target_head_rot_count
189+ @target_head_rot_dy = (target_y - @head_rot_y_base) / @target_head_rot_count
190+ @target_head_rot_dz = (target_z - @head_rot_z_base) / @target_head_rot_count
191+ end
192+
193+ def set_target_agent_rot(target_x, target_y, target_z)
194+ @target_agent_rot_count = 5
195+ @target_agent_rot_dx = (target_x - @agent_rot_x_base) / @target_agent_rot_count
196+ @target_agent_rot_dy = (target_y - @agent_rot_y_base) / @target_agent_rot_count
197+ end
198+
199+ def set_target_eye_rot(target_x, target_y, target_z)
200+ @eye_rot_x, @eye_rot_y, @eye_rot_z = target_x, target_y, target_z
201+
202+ if @eye_rot_x < -EYE_ROT_X_MAX then @eye_rot_x = -EYE_ROT_X_MAX end
203+ if @eye_rot_y < -EYE_ROT_Y_MAX then @eye_rot_y = -EYE_ROT_Y_MAX end
204+ if @eye_rot_z < -EYE_ROT_Z_MAX then @eye_rot_z = -EYE_ROT_Z_MAX end
205+
206+ if @eye_rot_x > EYE_ROT_X_MAX then @eye_rot_x = EYE_ROT_X_MAX end
207+ if @eye_rot_y > EYE_ROT_Y_MAX then @eye_rot_y = EYE_ROT_Y_MAX end
208+ if @eye_rot_z > EYE_ROT_Z_MAX then @eye_rot_z = EYE_ROT_Z_MAX end
209+ end
210+
211+ def open_tag
212+ rate_speed = @ssmspeed
213+ volume_level = 0.5
214+ pitch_level = 1.0
215+ pitch_range = 1.0
216+ if @exp_type_target == "HAPPY"
217+ volume_level = 0.55
218+ pitch_level = 1.1
219+ pitch_range = 1.0
220+ elsif @exp_type_target == "DISGUSTED"
221+ pitch_level = 0.9
222+ pitch_range = 0.8
223+ elsif @exp_type_target == "SAD"
224+ pitch_level = 0.9
225+ pitch_range = 0.8
226+ rate_speed *= 1.1
227+ elsif @exp_type_target == "ANGRY"
228+ volume_level = 0.75
229+ pitch_level = 1.2
230+ pitch_range = 1.5
231+ elsif @exp_type_target == "SURPRISED"
232+ volume_level = 0.75
233+ pitch_level = 1.2
234+ pitch_range = 0.6
235+ rate_speed *= 0.8
236+ elsif @exp_type_target == "FEARED"
237+ volume_level = 0.75
238+ pitch_level = 1.4
239+ pitch_range = 0.7
240+ rate_speed *= 1.3
241+ end
242+ return "<RATE SPEED=\"#{rate_speed}\"><VOLUME LEVEL=\"#{volume_level}\"><PITCH LEVEL=\"#{pitch_level}\" RANGE=\"#{pitch_range}\">"
243+ end
244+
245+ def close_tag
246+ return "</PITCH></VOLUME></RATE>"
247+ end
248+
249+ def mouth_scale
250+ if @exp_type_target == "HAPPY"
251+ return "40"
252+ elsif @exp_type_target == "DISGUSTED"
253+ return "20"
254+ elsif @exp_type_target == "SAD"
255+ return "20"
256+ elsif @exp_type_target == "ANGRY"
257+ return "40"
258+ elsif @exp_type_target == "SURPRISED"
259+ return "10"
260+ elsif @exp_type_target == "FEARED"
261+ return "10"
262+ end
263+ return "30"
264+ end
265+
266+ def add_clock(delta, nospeak = 1.0, speak = 0.3)
267+ @clock += delta
268+ if @agentSpeakState != 2
269+ @clock_head += delta * nospeak
270+ else
271+ @clock_head += delta * speak
272+ end
273+ end
274+
275+ def start_nodding(size)
276+ self.nodding_range = size
277+ self.nodding_count = 100
278+ self.nodding_range_delta = -(size / 100)
279+ end
280+
281+ def calc_nodding
282+ if self.nodding_count > 0
283+ self.nodding_head_x = Math.cos(self.clock * 0.3) * size * 10.0
284+ self.nodding_count -= 1
285+ self.nodding_range += self.nodding_range_delta
286+ else
287+ self.nodding_head_x = 0.0
288+ end
289+ end
290+
291+ attr_reader :head_rot_x, :head_rot_y, :head_rot_z
292+ attr_reader :eye_rot_x, :eye_rot_y, :eye_rot_z
293+ attr_reader :trans_x, :trans_y
294+ attr_reader :agent_rot_x, :agent_rot_y
295+ # attr_reader :agent_rot_z
296+ attr_reader :agent_trans_x, :agent_trans_y
297+ attr_reader :agent_scale
298+ attr_reader :mask, :speaker
299+
300+ attr_accessor :exp_type, :exp_level
301+ attr_accessor :ssmspeed
302+ attr_accessor :clock
303+ attr_accessor :clock_head
304+ attr_accessor :agentSpeakState
305+
306+ attr_accessor :nodding_range, :nodding_range_delta, :nodding_count
307+ attr_accessor :nodding_head_x
308+
309+end
310+
311+
312+# end of file
diff -r 000000000000 -r 5298508466dd modules/AgentManager-gdm-memo.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/AgentManager-gdm-memo.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,14 @@
1+AgentManager-gdm.pl について
2+
3+西本卓也
4+
5+AgentManager.pl (1.5.1) に下記の拡張をしている。
6+
7+従来: 各モジュールからの出力 (From @xxx) は broadcast & print_out される
8+
9+修正: 各モジュールからの出力 (From @xxx) は
10+ to @yyy From @xxx であれば yyy に送る
11+ to がない場合は broadcastされる
12+ print_out はしない
13+
14+[end of file]
diff -r 000000000000 -r 5298508466dd modules/AgentManager-gdm.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/AgentManager-gdm.pl Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,484 @@
1+#!/usr/bin/perl -w
2+#----------------------------------------------------------------------
3+# AgentManager for Galatea Dialog Manager
4+# by Takuya Nishimoto (nishi@hil.t.u-tokyo.ac.jp)
5+#
6+# below is the original header:
7+#----------------------------------------------------------------------
8+# AgentManager ver 1.5.1 by Shin-ichi Kawamoto (skawa@jaist.ac.jp)
9+# based on AgentManager.pl (s-tamura/skawa)
10+#
11+# options:
12+# -C ファイル名 : モジュール設定ファイルの指定
13+# -d : debug mode
14+#
15+# below is the original header:
16+#----------------------------------------------------------------------
17+# AgentManager ver 1.5 by Matsushita Yoshinori (matsuy@jaist.ac.jp)
18+# based on AgentManager.pl (s-tamura/skawa)
19+#
20+# care on open2. option $broadcast. Thu Aug 2 05:25:05 JST 2001
21+# SIGCHLD concidered version. Tue Jul 31 03:09:42 JST 2001
22+# include sysreadline() in main_AgentManager(). Tue Jul 31 18:55:53 JST 2001
23+# added by Shin-ichi KAWAMOTO(skawa@jaist.ac.jp)
24+# - logfile output.
25+#
26+# options:
27+# -d debug mode
28+#
29+# below is the original header:
30+#----------------------------------------------------------------------
31+# Filename : AgentManager.pl
32+#
33+# 複数の子プロセスを起動して、その標準入出力をPerlのファイルハンドルに
34+# 結合する。(rshを利用してremoteとの標準入出力を結合)
35+#
36+# coded by Sayuki TAMURA (s-tamura@jaist.ac.jp) ... Jun 4, 2001.
37+# Shin-ichi KAWAMOTO(skawa@jaist.ac.jp)
38+#
39+##################################################################
40+#----------------------------------------------------------------------
41+
42+# 標準モジュールの取り込み
43+use strict;
44+use IPC::Open2;
45+use IO::Handle '_IONBF';
46+use IO::Select;
47+use Fcntl;
48+# use sigtrap;
49+# use sigtrap qw(stack-trace old-interface-signals);
50+
51+#- config -------------------------------------------------------------
52+#----------------------------------------------------------------------
53+
54+#my $debug = grep(/^-d$/, @ARGV);
55+my $debug = undef;
56+my $BaseDir = './';
57+my $logfile = './AgentManager.log';
58+my $logfp;
59+my $configfile = './modules.conf';
60+my $configfp;
61+
62+# if you would to add module, add line in %module
63+# 'modulename', 'modulepath',
64+my %module = ( );
65+my %broadcast = ( );
66+my @broadcast2;
67+my %pid; # hold sub process's id
68+my(%IN_SUB, %OUT_SUB); # hold references of sub process's IN/OUT file handle
69+my %FH2MN; # convert from file-handle to module-name
70+my %MultiLineBufferCom; # input buffer for multi-line(Command)
71+my %MultiLineBufferEndMark; # input buffer for multi-line(End Marker)
72+my %MultiLineBufferSlot; # input buffer for multi-line(Slot)
73+my %MultiLineBufferValue; # input buffer for multi-line(Value)
74+my $read_set = new IO::Select;
75+my $write_set = new IO::Select;
76+my $error_set = new IO::Select;
77+#my $timeout = 0.1;
78+my $timeout = 1;
79+#my $timeout = undef;
80+my $f_flag = '';
81+my ($r_ready, $w_ready, $e_ready);
82+#my (@r_ready, @w_ready, @e_ready);
83+my $handlename;
84+
85+arg_proc(); # analyze argument
86+read_config_file(); # read module configuration file
87+initialize(); # open sub process and set signal handler
88+main_AgentManager(); # the main routine of Agent manager
89+finalize(); # kill sub processes handled in %pid
90+exit 0;
91+
92+#- subroutines --------------------------------------------------------
93+#----------------------------------------------------------------------
94+
95+#- usage --------------------------------------------------------------
96+sub usage{
97+ STDERR->print("Usage:\n");
98+ STDERR->print("%% \n");
99+ STDERR->print("\n");
100+ STDERR->print("\n");
101+ STDERR->print("\n");
102+ exit(-1);
103+}
104+
105+#- command argument analysis-------------------------------------------
106+sub arg_proc{
107+ my $i;
108+ for ($i=0;$i<=$#ARGV;$i++) {
109+ if ($ARGV[$i] =~ /^-C$/) {
110+ $i++;
111+ if ($i<=$#ARGV) {
112+ $configfile = $ARGV[$i];
113+ } else {
114+ STDERR->print("invalid option!!\n");
115+ usage();
116+ }
117+ } elsif ($ARGV[$i] =~ /^-d$/) {
118+ $debug = 1;
119+ } else {
120+ usage();
121+ }
122+ }
123+}
124+
125+#- read module configuration file -------------------------------------
126+sub read_config_file{
127+ $configfp = IO::Handle->new();
128+ open($configfp,$configfile);
129+ while (<$configfp>) {
130+ chomp;
131+ s;#.*$;; ; # delete comment
132+ if ( /^\s*module:\s*(\S+)\s+commands:\s*(.+)/) {
133+ $module{$1}="$2";
134+ } elsif ( /^\s*broadcast:\s*(.*)/) {
135+ $_=$1;
136+ foreach my $key (split) {
137+ $broadcast{$key}=$key;
138+ }
139+ }
140+ }
141+ close($configfp);
142+ push(@broadcast2,(sort(keys(%broadcast))));
143+
144+ foreach (sort(keys(%broadcast))) {
145+ STDERR->print(sprintf("set broadcast = %s\n",$_));
146+ }
147+}
148+
149+#- initialize ---------------------------------------------------------
150+sub initialize{
151+ $SIG{'CHLD'} = 'finalize_CHLD'; # if caught 'SIGCHLD', and exit AgentManager by finalize()
152+ $SIG{'PIPE'} = 'finalize_PIPE';
153+ $SIG{'KILL'} = 'finalize_KILL';
154+ $SIG{'TERM'} = 'finalize_TERM';
155+ $SIG{'BUS'} = 'finalize_BUS';
156+ $SIG{'QUIT'} = 'finalize_QUIT';
157+ $SIG{'INT'} = 'finalize_INT';
158+
159+ if ($debug) {
160+ $logfp = IO::Handle->new();
161+ open($logfp,">$logfile");
162+ }
163+ foreach (keys %module) { # open subprocess listed in %module
164+ STDERR->print(sprintf("LOG: START %s\n",$_));
165+ $IN_SUB{$_} = IO::Handle->new(); # subprocess's STDOUT
166+ $OUT_SUB{$_} = IO::Handle->new(); # subprocess's STDIN
167+ $FH2MN{$IN_SUB{$_}} = $_;
168+ $FH2MN{$OUT_SUB{$_}} = $_;
169+ $pid{$_} = open2($IN_SUB{$_}, $OUT_SUB{$_}, $module{$_}); # pipe subprocess
170+ if (! $pid{$_}) {
171+ warn("$! can't excute $_ ($module{$_}).\n");
172+ delete($pid{$_});
173+ delete($IN_SUB{$_});
174+ delete($OUT_SUB{$_});
175+ delete($broadcast{$_});
176+ next;
177+ }
178+# else{
179+# $pid{$_}++;
180+# }
181+ print_debug("$_ opened. pid is $pid{$_}\n");
182+
183+# by nishi
184+# open(FH,">/var/tmp/$_.pid");
185+# print FH "$pid{$_}";
186+# close(FH);
187+# by nishi end
188+
189+ $IN_SUB{$_}->autoflush();
190+ $OUT_SUB{$_}->autoflush();
191+ # $IN_SUB{$_}->setvbuf(undef, _IONBF, 0);
192+ # $OUT_SUB{$_}->setvbuf(undef, _IONBF, 0);
193+ # $f_flag = '';
194+ # fcntl($OUT_SUB{$_},F_GETFL(),$f_flag);
195+ # $f_flag |= O_NONBLOCK();
196+ # fcntl($OUT_SUB{$_},F_SETFL(),$f_flag);
197+ # fcntl($OUT_SUB{$_},F_SETFL(),O_NONBLOCK());
198+ $read_set->add($IN_SUB{$_});
199+ $write_set->add($OUT_SUB{$_});
200+ $error_set->add($IN_SUB{$_});
201+ $error_set->add($OUT_SUB{$_});
202+
203+ # by nishi
204+ # TODO: この sleep を削っても不具合が起きないようにする
205+ # sleep(1);
206+ }
207+ $IN_SUB{'STDIN'} = *STDIN;
208+ $OUT_SUB{'STDOUT'} = *STDOUT;
209+ $read_set->add(*STDIN);
210+ $write_set->add(*STDOUT);
211+ $error_set->add(*STDIN);
212+ $error_set->add(*STDOUT);
213+ $FH2MN{*STDIN} = "STDIN";
214+ $FH2MN{*STDOUT} = "STDOUT";
215+}
216+
217+#- main roop ----------------------------------------------------------
218+sub main_AgentManager{
219+ my $start = time();
220+ my %string;
221+ my $read_bits = '';
222+ my $err_bits = '';
223+ my $count = 0;
224+ while (1) {
225+ $count ++;
226+ $r_ready = undef;
227+ $w_ready = undef;
228+ $e_ready = undef;
229+ ($r_ready, $w_ready, $e_ready) =
230+ IO::Select->select($read_set,undef,$error_set,undef);
231+ if ( $#$e_ready >= 0 ) { # detect error handles
232+ STDERR->print(sprintf("LOG: e(%d)\n",$#$e_ready+1));
233+ foreach my $handle (@$e_ready) {
234+ $handlename = $FH2MN{$handle};
235+ print STDERR "ERROR($handlename)\n";
236+ }
237+ finalize();
238+ exit(1);
239+ }
240+
241+ foreach my $handle (@$r_ready) { # readable handles
242+ my ($char, $moduleStr); # $char:
243+ $handlename = $FH2MN{$handle};
244+ # $handle->sysread($char, 1) or die("read-net:$!");
245+ if ( ! $handle->sysread($char, 1) ) {
246+ # warn("read-net:$!");
247+ # finalize();
248+ #
249+ # by nishi
250+ warn("read-net:$! $moduleStr");
251+ }
252+ $string{$handlename} .= $char;
253+ # $string{$handlename} = $handle->getline or die("read-net:$!");
254+ # $char = "\n";
255+ if ($char =~ /\n/) {
256+ $moduleStr = $string{$handlename};
257+ $string{$handlename} = undef;
258+ print_debug("from'$handlename': $moduleStr");
259+ if ($moduleStr =~ /^\s*\n$/) {
260+ } elsif ($moduleStr =~ /^AM\s+quit/) {
261+ finalize();
262+ } elsif ( (exists $broadcast{$handlename}) || $handlename =~ /STDIN/ ) {
263+ print_debug("read $handlename: $moduleStr");
264+ cut_to($moduleStr,$handlename);
265+ # STDERR->print("cut to ( $handlename )\n");
266+ } else {
267+ print_debug($moduleStr);
268+ add_from($handlename, $moduleStr);
269+ # STDERR->print("add from ( $handlename )\n");
270+ }
271+ $moduleStr = '';
272+ }
273+ }
274+
275+ }
276+}
277+
278+#----------------------------------------------------------------------
279+# distribute to specified module
280+sub cut_to{
281+ my($str,$module) = @_;
282+ my($dest, $content, @dests);
283+
284+ $_ = $str;
285+ if (m;\bto\b;) {
286+ if (m;^\s*to\s*\@(\S+)\s+(.*)\s*$;) {
287+ $dest = $1;
288+ $content = $2;
289+ @dests = $dest =~ m;\.;? split(/\./, $dest): $dest;
290+ foreach $dest (@dests) {
291+ print_debug("select_module '$dest': $content\n"); # \n added by nishi
292+ select_module($dest, $content);
293+ }
294+ }
295+ } else {
296+ # AM-MCLへの入力
297+ if (m;^\s*set\s+(\S+)\s+\<\<\s*(.*)\s*$;) {
298+ # 複数行入力の開始点
299+ $MultiLineBufferCom{$module} = "set";
300+ $MultiLineBufferValue{$module} = "";
301+ $MultiLineBufferSlot{$module} = $1;
302+ $MultiLineBufferEndMark{$module} = $2;
303+ }
304+ elsif(exists($MultiLineBufferEndMark{$module})){
305+ # 複数行入力中
306+ if (m;^\s*$MultiLineBufferEndMark{$module}\s*$;) {
307+ # 終端記号
308+ $MultiLineBufferValue{$module} =~ s/\r//g;
309+ $MultiLineBufferValue{$module} =~ s/\n//g;
310+ # 「set Speak = なんとか」という形に整形して出力
311+ select_module('AM-MCL', sprintf("%s %s = %s",$MultiLineBufferCom{$module},$MultiLineBufferSlot{$module},$MultiLineBufferValue{$module}));
312+ delete($MultiLineBufferCom{$module});
313+ delete($MultiLineBufferSlot{$module});
314+ delete($MultiLineBufferValue{$module});
315+ delete($MultiLineBufferEndMark{$module});
316+
317+ }
318+ else{
319+ # 非終端記号
320+ $MultiLineBufferValue{$module} .= $_;
321+ }
322+
323+ }
324+ else{ # その他の入力
325+ select_module('AM-MCL', $_);
326+ if(exists($MultiLineBufferCom{$module})){
327+ # $MultiLineBufferCom{$module} = "";
328+ delete($MultiLineBufferCom{$module});
329+ }
330+ if(exists($MultiLineBufferValue{$module})){
331+ # $MultiLineBufferValue{$module} = "";
332+ delete($MultiLineBufferValue{$module});
333+ }
334+ if(exists($MultiLineBufferSlot{$module})){
335+ # $MultiLineBufferSlot{$module} = "";
336+ delete($MultiLineBufferSlot{$module});
337+ }
338+ if(exists($MultiLineBufferEndMark{$module})){
339+ # $MultiLineBufferEndMark{$module} = "";
340+ delete($MultiLineBufferEndMark{$module});
341+ }
342+ }
343+ }
344+}
345+
346+#----------------------------------------------------------------------
347+# by nishi
348+# 従来: 各モジュールからの出力 (From @xxx) はbroadcast & print_out される
349+#
350+# 修正: 各モジュールからの出力 (From @xxx) は
351+# From @xxx to @yyy であれば yyy に送る
352+# From @xxx to @yyy,zzz であれば yyy,zzz に送る
353+# to がない場合は broadcastされる
354+# print_out はしない
355+#
356+# sub add_from{ # send to module 'From @SRM ...'
357+# my($modulename, $string) = @_;
358+#
359+# $_ = $string;
360+# my($out) = sprintf('From @'.$modulename." $string");
361+# print_out($out);
362+# print_debug($out);
363+# foreach (keys %broadcast) {
364+# $OUT_SUB{$_}->print($out);
365+# $OUT_SUB{$_}->flush();
366+# }
367+# }
368+#
369+sub add_from{ # send to module 'From @SRM ...'
370+ my($modulename, $string) = @_;
371+
372+ $_ = $string;
373+ if (m;\bto\b;) {
374+ if (m;^\s*to\s*\@(\S+)\s+(.*)\s*$;) {
375+ my $dest = $1;
376+ my $content = $2;
377+ my @dests = $dest =~ m;\.;? split(/\./, $dest): $dest;
378+ foreach $dest (@dests) {
379+ print_debug("select_module '$dest': $content\n"); # \n added by nishi
380+ select_module($dest, $content);
381+ }
382+ }
383+ } else {
384+ my($out) = sprintf('From @'.$modulename." $string");
385+ # print_out($out);
386+ print_debug($out);
387+ foreach (keys %broadcast) {
388+ $OUT_SUB{$_}->print($out);
389+ $OUT_SUB{$_}->flush();
390+ }
391+ }
392+}
393+
394+sub select_module{
395+ my ($dest, $data) = @_;
396+
397+# $OUT_SUB{$dest}->print("$data\n");
398+# $OUT_SUB{$dest}->flush();
399+
400+ if (exists($OUT_SUB{$dest})) {
401+ $OUT_SUB{$dest}->print("$data\n");
402+ $OUT_SUB{$dest}->flush();
403+ } else {
404+ warn("$dest : module not found");
405+ }
406+
407+ print_debug("to'$dest': $data\n"); # \n added by nishi
408+}
409+
410+#- utilities ----------------------------------------------------------
411+#----------------------------------------------------------------------
412+sub print_out{
413+ $OUT_SUB{'STDOUT'}->print(@_);
414+ $OUT_SUB{'STDOUT'}->flush();
415+}
416+
417+sub print_debug{
418+ if ($debug) {
419+ print STDERR "dout:@_";
420+ $logfp->print("@_");
421+ $logfp->flush();
422+ }
423+}
424+
425+#----------------------------------------------------------------------
426+sub finalize{ # close FILEHANDLE and kill childprocess
427+ STDERR->print("LOG: AM: finalize()\n");
428+ foreach (keys %module) {
429+ print_debug(sprintf("kill(%s) : pid=%d\n",$_,$pid{$_}));
430+
431+ if($_ ne "AM-MCL"){
432+ $OUT_SUB{$_}->print("set Run = EXIT\n");
433+ $OUT_SUB{$_}->flush();
434+ }
435+ close($OUT_SUB{$_});
436+ close($IN_SUB{$_});
437+ kill('TERM', $pid{$_});
438+ kill('KILL', $pid{$_});
439+ # kill(9, $pid{$_});
440+ }
441+ foreach (keys %module) {
442+ print_debug(sprintf("wait(%s) : pid=%d\n",$_,$pid{$_}));
443+ # wait();
444+ waitpid($pid{$_},1);
445+ }
446+ if ($debug) {
447+ close($logfp);
448+ }
449+ exit 0;
450+}
451+#----------------------------------------------------------------------
452+# signal
453+sub finalize_CHLD {
454+ warn("finalize_CHLD"); # by nishi
455+ finalize();
456+}
457+sub finalize_PIPE {
458+ warn("finalize_PIPE"); # by nishi
459+ finalize();
460+}
461+sub finalize_KILL {
462+ warn("finalize_KILL"); # by nishi
463+ finalize();
464+}
465+sub finalize_TERM {
466+ warn("finalize_TERM"); # by nishi
467+ finalize();
468+}
469+sub finalize_BUS {
470+ warn("finalize_BUS"); # by nishi
471+ finalize();
472+}
473+sub finalize_QUIT {
474+ warn("finalize_QUIT"); # by nishi
475+ finalize();
476+}
477+sub finalize_INT {
478+ warn("finalize_INT"); # by nishi
479+ finalize();
480+}
481+
482+
483+#- end of script ------------------------------------------------------
484+#----------------------------------------------------------------------
diff -r 000000000000 -r 5298508466dd modules/DIM.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/DIM.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,216 @@
1+#!/usr/bin/ruby -Ke
2+# $Id: DIM.rb,v 1.2 2008/10/11 11:40:52 nishimoto Exp $
3+#
4+# DIM = Dynamic Interaction Manager
5+# used for AutoGaze
6+#
7+# by Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
8+#
9+
10+require 'GalateaBase.rb'
11+
12+class DIM < GalateaBase
13+ def initialize
14+ super
15+ @modulename = "DIM"
16+ @debug = false
17+
18+ @useEventViewer = 0
19+
20+ @mutex = Mutex.new
21+ @clockPrev = 0.0
22+ @clockCurr = 0.0
23+
24+ @autoGaze = 0
25+
26+ @agentSpeakState = 0
27+ # managed by AM-MCL
28+ # 0: not-speaking
29+ # 1: preparing
30+ # 2: speaking
31+
32+ @userSpeakState = 0
33+ # 0: not-speaking
34+ # 1: startrec .. endrec
35+
36+ @agentAttentionState = 0
37+ # -1: busy
38+ # 0: not-gazing & not-speaking
39+ # 1: gazing & not-speaking
40+ # 2: gazing & speaking
41+
42+ @isAgentTurn = 0
43+
44+ @userAnxiety = 0.0
45+ @userAnxietyMax = 1.0
46+
47+ @visualAmount = 0.0
48+ @visualMin = 1.0
49+ @visualCapacity = 5.0
50+
51+ Thread.start do
52+ while true
53+ @mutex.synchronize do
54+ doStepCalc
55+ if @userSpeakState == 0
56+ doInputVisualResponse
57+ end
58+ end
59+ sleep 0.1
60+ @clockPrev = @clockCurr
61+ @clockCurr += 0.1
62+ sendToEventViewer( "Blink", 0 )
63+ end
64+ end
65+
66+ end
67+
68+ def sendToEventViewer(slot, val)
69+ if @useEventViewer == 1
70+ sendToEventViewer( slot, val )
71+ end
72+ end
73+
74+ def doStepCalc
75+ # agentAttentionState
76+ if @agentAttentionState == 0 && @userSpeakState != 0
77+ @agentAttentionState = 1
78+ end
79+
80+ # visualAmount
81+
82+ if @agentAttentionState == 0
83+ # 0: not-gazing & not-speaking
84+ @visualAmount -= 5.0 * (@clockCurr - @clockPrev)
85+ elsif @agentAttentionState == 1
86+ # 1: gazing & not-speaking
87+ @visualAmount += 1.5 * (@clockCurr - @clockPrev)
88+ elsif @agentAttentionState == 2
89+ # 2: gazing & speaking
90+ @visualAmount += 1.0 * (@clockCurr - @clockPrev)
91+ end
92+
93+ if @visualAmount < 0 then @visualAmount = 0 end
94+ if @visualAmount > 10 then @visualAmount = 10 end
95+
96+ # user anxiety
97+
98+ if @isAgentTurn == 1
99+ @userAnxiety += 3.0 * (@clockCurr - @clockPrev)
100+ else
101+ @userAnxiety -= 2.0 * (@clockCurr - @clockPrev)
102+ end
103+
104+ if @userAnxiety < 0 then @userAnxiety = 0 end
105+ if @userAnxiety > 10 then @userAnxiety = 10 end
106+
107+ # output
108+ sendToEventViewer( "AgentAttentionState", @agentAttentionState.to_s )
109+ sendToEventViewer( "VisualAmount", @visualAmount.to_s )
110+ sendToEventViewer( "UserAnxiety", @userAnxiety.to_s )
111+ sendToEventViewer( "AgentTurn", @isAgentTurn.to_s )
112+ end
113+
114+ def doInputVisualResponse
115+ if @visualAmount < @visualMin
116+ doMoreVisual
117+ elsif @visualCapacity < @visualAmount
118+ doLessVisual
119+ end
120+ end
121+
122+ def doBlink
123+ sendToEventViewer( "Blink", 1 )
124+ send_set( "FS-MCL", "Action", "Blink" )
125+ @visualAmount -= 4.0
126+ end
127+
128+ def doWithdrawGaze
129+ if @agentAttentionState != 0
130+ send_set( "FS-MCL", "Action", "Thinking" )
131+ @agentAttentionState = 0
132+ end
133+ end
134+
135+ def doGaze
136+ if @agentAttentionState != 1
137+ send_set( "FS-MCL", "Action", "InfoRequest" )
138+ @agentAttentionState = 1
139+ end
140+ end
141+
142+ def setBusy
143+ send_set( "FS-MCL", "Action", "Busy" )
144+ end
145+
146+ def doMoreVisual
147+ doGaze
148+ end
149+
150+ def doLessVisual
151+ if @agentAttentionState == 0
152+ if rand(50) == 0 then doBlink end
153+ elsif @agentAttentionState == 1
154+ if @userAnxiety < @userAnxietyMax
155+ if rand(3) == 0
156+ doWithdrawGaze
157+ else
158+ doBlink
159+ end
160+ else
161+ doBlink
162+ end
163+ elsif @agentAttentionState == 2
164+ if rand(30) == 0 then doBlink end
165+ end
166+ end
167+
168+ def do_set(slot, arg)
169+ super
170+ if slot == "AgentSpeakState"
171+ @agentSpeakState = arg.to_i
172+ if @agentSpeakState == 2 then
173+ @isAgentTurn = 0
174+ send_set( "FS-MCL", "Action", "Speaking" )
175+ end
176+
177+ if @agentAttentionState == 1 then
178+ if @autoGaze == 1
179+ send_set( "FS-MCL", "Action", "InfoRequest" )
180+ end
181+ @agentAttentionState = 2
182+ elsif @agentAttentionState == 2
183+ if @agentSpeakState == 0 && @autoGaze == 1 then
184+ doGaze
185+ end
186+ end
187+
188+ elsif slot == "UserSpeakState"
189+ @userSpeakState = arg.to_i
190+ if @userSpeakState == 1 then @isAgentTurn = 1 end
191+ # if user begin speaking then agent start gazing
192+ if @agentAttentionState == 0 && @userSpeakState == 1 && @autoGaze == 1
193+ doGaze
194+ end
195+
196+ elsif slot == "Busy"
197+ busy = arg.to_i
198+ if busy == 1
199+ @agentAttentionState = -1
200+ setBusy
201+ elsif busy == 0 && @agentAttentionState == -1
202+ @agentAttentionState = 0
203+ end
204+
205+ elsif slot == "AutoGaze"
206+ @autoGaze = arg.to_i
207+
208+ end
209+
210+ end
211+
212+end
213+
214+DIM.new.run
215+
216+# end of file
diff -r 000000000000 -r 5298508466dd modules/FSMdummy.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/FSMdummy.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,89 @@
1+#!/usr/bin/ruby -Ke
2+#
3+# (c)2003 Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
4+#
5+# $Id: FSMdummy.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
6+#
7+# DummyFSM
8+#
9+
10+require 'GalateaBase.rb'
11+
12+$tk_thread_safe = TRUE
13+require 'tk'
14+
15+class FSM < GalateaBase
16+ def initialize(modulename, debug)
17+ super
18+ @myslot["Run"] = "LIVE"
19+ end
20+
21+ def add_text(str)
22+ day = Time.now
23+ ds = day.strftime("%M:%S")
24+ $syslog.insert 'end', format("%s %s", ds, str)
25+ $syslog.yview 'end'
26+ end
27+
28+ def do_prop(prop, arg)
29+ super
30+
31+ # prop Speak.stat = AutoOutput
32+ add_text "prop #{prop} = #{arg}\n"
33+ end
34+
35+ def do_set(slot, arg)
36+ super
37+
38+ # set LipSync.pho = sil 340 w 60 a 55 t 65 a 65 sh 125 i 55 sil 340
39+ # set Speak = + 100
40+ if slot == "LipSync.pho" && @myprop["Speak.stat"] == "AutoOutput"
41+ print_rep "Speak.stat = PROCESSING"
42+ print_rep "Speak.stat = READY"
43+
44+ elsif slot == "Speak" && @myprop["Speak.stat"] == "AutoOutput"
45+ print_rep "Speak.stat = SPEAKING"
46+ sleep 1.0
47+ print_rep "Speak.stat = IDLE"
48+
49+ end
50+
51+ if slot != "FaceExp" && slot != "EyeRot" && slot != "HeadRotAbs.1"
52+ add_text "set #{slot} = #{arg}\n"
53+ end
54+
55+ end
56+
57+end
58+
59+Thread.start do
60+ FSM.new("FSM", true).run
61+end
62+
63+# ---------------------------
64+# Tk is from here
65+# ---------------------------
66+
67+$frame1 = TkFrame.new do
68+ pack('side' =>'top', 'fill'=>'both', 'expand'=>'true')
69+end
70+
71+$bar1 = TkScrollbar.new($frame1) do
72+ pack('side'=>'right', 'fill'=>'y')
73+ command proc { |args| $syslog.yview(*args) }
74+end
75+
76+sleep 1.0
77+
78+$syslog = TkText.new($frame1) do
79+ width 60
80+ height 10
81+ wrap 'none'
82+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'true')
83+ yscrollcommand proc { |first, last| $bar1.set(first, last) }
84+end
85+
86+Tk.root.title("FSM")
87+Tk.mainloop
88+
89+# end of file
diff -r 000000000000 -r 5298508466dd modules/GUI.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/GUI.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,245 @@
1+#!/usr/bin/ruby -Ke
2+#
3+# (c)2003 Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
4+#
5+# $Id: GUI.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
6+#
7+# GUI for end-user
8+#
9+# based on Thread sample:
10+# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/5321
11+#
12+# set Text = message
13+# set F1 = 5分 ゴフン
14+#
15+# F1 F2 F3 F4 F5
16+# F6 F7 F8 F9 F10
17+#
18+# set WebBrowser.url = http://www.mozilla.org/
19+# >> mozilla -remote "openurl(http://www.mozilla.org)"
20+# set WebBrowser.url = file:/home/hil/nishi/public_html/index.shtml
21+# >> mozilla -remote "openurl(file:/home/hil/nishi/public_html/index.shtml)"
22+#
23+# set Canvas.photo = earth.gif
24+#
25+
26+# -------------
27+
28+require 'GalateaBase.rb'
29+$tk_thread_safe = TRUE
30+require 'tk'
31+require 'open3'
32+
33+# -------------
34+
35+$tktext = nil
36+
37+class GUI < GalateaBase
38+ def initialize
39+ super
40+ @modulename = "GUI"
41+ @debug = false
42+
43+ @myslot["Run"] = "LIVE"
44+ end
45+
46+ def do_set(slot, arg)
47+ super
48+
49+ if slot == "Text"
50+ unless $tktext.nil?
51+ $tktext.text arg
52+ end
53+
54+# elsif $use_canvas && slot == "Canvas.photo"
55+# image = TkPhotoImage.new('file' => arg, 'width' => 128, 'height' => 128)
56+# TkcImage.new($tkcanvas, 145, 100, 'image' => image)
57+# $tkcanvas.pack('fill'=>'both', 'expand' => true)
58+
59+ elsif slot == "WebBrowser.url"
60+# Open3.popen3("mozilla -remote \"openurl(#{arg})\"")
61+
62+ elsif slot == "Run" && arg =="EXIT"
63+ Process.exit!(0)
64+
65+ elsif /(\S+)\s+(.*)/ =~ arg
66+ set_button slot, $1, $2
67+
68+ end
69+
70+ end
71+
72+end
73+
74+Thread.start do
75+ GUI.new.run
76+end
77+
78+# -------------
79+
80+class FuncButton
81+ def initialize(parent, lbl, ev)
82+ @label = lbl
83+ @event = ev
84+ @button = TkButton.new(parent) {
85+ pack('side' => 'left')
86+ }
87+ @button.configure('text', @label)
88+ @button.bind("Button-1", proc { send_button_pressed(@event) })
89+
90+ if /[0-9]/ =~ @label
91+ $root.bind("Key-#{@label}", proc { send_button_pressed(@event) })
92+ end
93+
94+ end
95+
96+ def label(str)
97+ @label = str
98+ @button.configure('text', @label)
99+ end
100+
101+ def event(str)
102+ @event = str
103+ end
104+
105+end
106+
107+# -------------
108+def send_button_pressed(name)
109+ print_out "to \@SIM set ButtonPressed = " + name
110+ print_out "to \@MON set AppLogText = pressed " + name
111+end
112+
113+# -------------
114+def set_button(name, label, event)
115+ if name == 'F1' then
116+ $f1.label label
117+ $f1.event event
118+
119+ elsif name == 'F2' then
120+ $f2.label label
121+ $f2.event event
122+
123+ elsif name == 'F3' then
124+ $f3.label label
125+ $f3.event event
126+
127+ elsif name == 'F4' then
128+ $f4.label label
129+ $f4.event event
130+
131+ elsif name == 'F5' then
132+ $f5.label label
133+ $f5.event event
134+
135+ elsif name == 'F6' then
136+ $f6.label label
137+ $f6.event event
138+
139+ elsif name == 'F7' then
140+ $f7.label label
141+ $f7.event event
142+
143+ elsif name == 'F8' then
144+ $f8.label label
145+ $f8.event event
146+
147+ elsif name == 'F9' then
148+ $f9.label label
149+ $f9.event event
150+
151+ elsif name == 'F10' then
152+ $f10.label label
153+ $f10.event event
154+
155+ end
156+end
157+
158+# -------------
159+
160+$root = TkRoot.new
161+
162+# -------------
163+
164+#if $use_canvas
165+# $tkcanvas = TkCanvas.new {
166+# pack
167+# }
168+#end
169+
170+# -------------
171+
172+$tktext = TkLabel.new {
173+ relief 'sunken'
174+ width 35
175+ pady 10
176+ borderwidth 3
177+ pack
178+}
179+
180+# -------------
181+
182+frame_bool = TkFrame.new {
183+ pack
184+}
185+
186+fy = FuncButton.new(frame_bool, 'はい', 'はい')
187+fn = FuncButton.new(frame_bool, 'いいえ', 'いいえ')
188+
189+# -------------
190+
191+frame_f1 = TkFrame.new {
192+ pack
193+}
194+
195+$f1 = FuncButton.new(frame_f1, 'F1', 'F1')
196+$f2 = FuncButton.new(frame_f1, 'F2', 'F2')
197+$f3 = FuncButton.new(frame_f1, 'F3', 'F3')
198+$f4 = FuncButton.new(frame_f1, 'F4', 'F4')
199+$f5 = FuncButton.new(frame_f1, 'F5', 'F5')
200+
201+# -------------
202+
203+frame_f2 = TkFrame.new {
204+ pack
205+}
206+
207+$f6 = FuncButton.new(frame_f2, 'F6', 'F6')
208+$f7 = FuncButton.new(frame_f2, 'F7', 'F7')
209+$f8 = FuncButton.new(frame_f2, 'F8', 'F8')
210+$f9 = FuncButton.new(frame_f2, 'F9', 'F9')
211+$f10 = FuncButton.new(frame_f2, 'F10', 'F10')
212+
213+# -------------
214+
215+frame_num1 = TkFrame.new {
216+ pack
217+}
218+
219+n1 = FuncButton.new(frame_num1, '1', '1')
220+n2 = FuncButton.new(frame_num1, '2', '2')
221+n3 = FuncButton.new(frame_num1, '3', '3')
222+n4 = FuncButton.new(frame_num1, '4', '4')
223+n5 = FuncButton.new(frame_num1, '5', '5')
224+
225+# -------------
226+
227+frame_num2 = TkFrame.new {
228+ pack
229+}
230+
231+n6 = FuncButton.new(frame_num2, '6', '6')
232+n7 = FuncButton.new(frame_num2, '7', '7')
233+n8 = FuncButton.new(frame_num2, '8', '8')
234+n9 = FuncButton.new(frame_num2, '9', '9')
235+nzero = FuncButton.new(frame_num2, '0', '0')
236+
237+# nstar = FuncButton.new(frame_num4, '*', 'star-key')
238+# nsharp = FuncButton.new(frame_num4, '#', 'sharp-key')
239+
240+# -------------
241+
242+Tk.root.title("GUI")
243+Tk.mainloop
244+
245+# end of file
diff -r 000000000000 -r 5298508466dd modules/GalateaBase.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/GalateaBase.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,215 @@
1+#!/usr/bin/ruby
2+# $Id: GalateaBase.rb,v 1.3 2008/12/19 04:53:47 nishimoto Exp $
3+#
4+# Galatea Submodule base class
5+# by Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
6+#
7+
8+require 'thread'
9+require 'timeout'
10+
11+# grobal method
12+
13+def print_out(str)
14+ puts str
15+ STDOUT.flush
16+end
17+
18+# class def.
19+
20+class GalateaBase
21+ def initialize
22+ @modulename = "GalateaBase"
23+ @debug = false
24+ @myslot = {}
25+ @mymacro = {}
26+ @myprop = {}
27+ @mycount = {}
28+ #
29+ @myslot["Run"] = "DEAD" # or "LIVE"
30+ @myslot["ProtocolVersion"] = "ProtocolVersion 1.0"
31+ @myslot["ModuleVersion"] = "ModuleVersion 1.0"
32+ @alive_count = 1
33+ @check_alive = false
34+ end
35+
36+ attr_accessor :modulename, :debug
37+ attr_accessor :check_alive
38+
39+ def send_set(mod, slot, str)
40+ puts "to \@#{mod} set #{slot} = #{str}"
41+ STDOUT.flush
42+ end
43+
44+ def print_out(str)
45+ puts str
46+ STDOUT.flush
47+ end
48+
49+ def print_debug(str)
50+ if @debug
51+ #STDERR.puts @modulename + ": " + str
52+ #STDERR.flush
53+ print_out "to \@MON set SysLogText = #{modulename} #{str}"
54+ end
55+ end
56+
57+ def print_tell(str)
58+ puts "tell " + str
59+ STDOUT.flush
60+ end
61+
62+ def print_rep(str)
63+ puts "rep " + str
64+ STDOUT.flush
65+ end
66+
67+ def do_gets(rs = $/)
68+ if @check_alive
69+ s = nil
70+ while s == nil
71+ begin
72+ timeout(5.0) do
73+ s = $stdin.gets(rs)
74+ end
75+ rescue TimeoutError
76+ print_debug("alive_count #{@alive_count}")
77+ @alive_count += 1
78+ end
79+ end
80+ return s
81+ else
82+ $stdin.gets(rs)
83+ end
84+ end
85+
86+ def run
87+ while true
88+ while cmd = do_gets
89+ case cmd
90+ when /^\s*set\s+([^\s=]*)\s*=\s*(.*)$/
91+ # set XXX = xxxx
92+ @myslot[$1] = $2
93+ do_set $1, $2
94+ when /^\s*prop\s+([^\s=]*)\s*=\s*(.*)$/
95+ # prop XXX.attr = xxx
96+ @myprop[$1] = $2
97+ do_prop $1, $2
98+ when /^\s*inq\s+(.*)$/
99+ # inq
100+ print_rep "#{$1} = #{@myslot[$1]}"
101+ when /^\s*From\s+\@(\S+)\s(.*)$/
102+ # (broadcast only) From @(XXX) (xxxxxxxx)
103+ accept_from $1, $2
104+ when /^\s*to\s+\@(\S+)\s(.*)$/
105+ # (broadcast only) to @(XXX) (xxxxxxxx)
106+ accept_to $1, $2
107+ end
108+ # not implemented:
109+ #
110+ # set XXX < filename
111+ #
112+ # set XXX << END
113+ # xxxx
114+ # END
115+ end
116+ end
117+ end
118+
119+ def do_set(slot, arg)
120+ if slot == "Run"
121+ if arg == "INIT"
122+ @myslot["Run"] = "LIVE"
123+ end
124+ if arg == "EXIT"
125+ @myslot["Run"] = "DEAD"
126+ end
127+ end
128+ end
129+
130+ def do_prop(prop, arg)
131+ end
132+
133+ def accept_from(mod, str)
134+ end
135+
136+ def accept_to(mod, str)
137+ end
138+
139+end
140+
141+#############################################################
142+
143+class GalateaBaseThread < GalateaBase
144+ def initialize
145+ super
146+ @modulename = "GalateaBaseThread"
147+ @mutex = Mutex.new
148+ @input_queue = Array.new
149+ end
150+
151+ attr_accessor :modulename, :debug
152+
153+ def run
154+ Thread.start do
155+ while true
156+ sleep 0.0001
157+ while @input_queue.length > 0 do
158+ cmd = nil
159+ @mutex.synchronize do
160+ cmd = @input_queue.delete_at(0)
161+ end
162+
163+ # set XXX = xxxx
164+ if /^\s*set\s+([^\s=]*)\s*=\s*(.*)$/ =~ cmd
165+ @myslot[$1] = $2
166+ do_set $1, $2
167+ end
168+
169+ # set XXX < filename
170+ # not implemented
171+
172+ # prop XXX.attr = xxx
173+ if /^\s*prop\s+([^\s=]*)\s*=\s*(.*)$/ =~ cmd
174+ @myprop[$1] = $2
175+ do_prop $1, $2
176+ end
177+
178+ # set XXX << END
179+ # xxxx
180+ # END
181+ # not implemented
182+
183+ # inq
184+ if /^\s*inq\s+(.*)$/ =~ cmd
185+ print_rep "#{$1} = #{@myslot[$1]}"
186+ end
187+
188+ # (broadcast only) From @(XXX) (xxxxxxxx)
189+ if /^\s*From\s+\@(\S+)\s(.*)$/ =~ cmd
190+ accept_from $1, $2
191+ end
192+
193+ # (broadcast only) to @(XXX) (xxxxxxxx)
194+ if /^\s*to\s+\@(\S+)\s(.*)$/ =~ cmd
195+ accept_to $1, $2
196+ end
197+ end
198+ end
199+ end
200+
201+ while true
202+ while gets do
203+ @mutex.synchronize do
204+ @input_queue.push($_)
205+ end
206+ sleep 0.0001
207+ end
208+ end
209+
210+ end
211+
212+end
213+
214+
215+# end of file
diff -r 000000000000 -r 5298508466dd modules/MON.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/MON.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,607 @@
1+#!/usr/bin/ruby -Ke
2+#
3+# (c)2003 Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
4+#
5+# $Id: MON.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
6+#
7+# Galatea Monitor
8+#
9+# to @MON set SysLogText = message
10+# to @MON set AppLogText = message
11+# to @MON set Run = EXIT
12+
13+require 'GalateaBase.rb'
14+
15+# -------------
16+
17+$tk_thread_safe = true
18+require 'tk'
19+require 'open3'
20+
21+$applog_height = 3
22+$syslog_height = 3
23+
24+
25+# -------------
26+
27+menubar = TkFrame.new {
28+ relief 'raised'
29+ borderwidth 1
30+ pack('fill' => 'x')
31+}
32+
33+# -------------
34+
35+TkMenubutton.new(menubar) { |mb|
36+ text "File"
37+ menu TkMenu.new(mb) {
38+ add 'command', 'label' => 'xmixer', 'command' => proc{
39+ Open3.popen3("xmixer")
40+ }
41+
42+ add 'command', 'label' => 'gmix', 'command' => proc{
43+ Open3.popen3("gmix")
44+ }
45+
46+ add 'command', 'label' => 'Pause', 'command' => proc{
47+ send_cmd "GDM_PAUSE"
48+ }
49+ add 'command', 'label' => 'Resume', 'command' => proc{
50+ send_cmd "GDM_RESUME"
51+ }
52+ add 'command', 'label' => 'Restart', 'command' => proc{
53+ send_cmd "GDM_RESTART"
54+ }
55+
56+ add 'command', 'label' => 'Open VXML File', 'command' => proc{
57+ filename = Tk.getOpenFile
58+ if filename != "" then
59+ send_restart_doc filename
60+ end
61+ }
62+
63+ add 'command', 'label' => 'default', 'command' => proc{
64+ send_restart_doc "../lib/default.vxml"
65+ }
66+
67+ add 'command', 'label' => '蟹の小噺', 'command' => proc{
68+ send_restart_doc "../demo/kani.vxml"
69+ }
70+
71+ add 'command', 'label' => '自動車教習所', 'command' => proc{
72+ send_restart_doc "../tests/conte01.vxml"
73+ }
74+
75+ add 'command', 'label' => '天気', 'command' => proc{
76+ send_restart_doc "../tests/weather.vxml"
77+ }
78+
79+ }
80+ pack('side' => 'left', 'padx' => '1m')
81+}
82+
83+def send_cmd(cmd)
84+ puts "to \@SIM set ButtonPressed = <ev src=\"GUI\" type=\"COMMAND\"><interpreted><text>#{cmd}</text></interpreted></ev>"
85+ STDOUT.flush
86+end
87+
88+def send_restart_doc(filename)
89+ puts "to \@SIM set ButtonPressed = <ev src=\"GUI\" type=\"COMMAND\"><interpreted><text>GDM_RESTART</text><script>$restart_document = '#{filename}';</script></interpreted></ev>"
90+ STDOUT.flush
91+end
92+
93+
94+# -------------
95+
96+TkMenubutton.new(menubar) { |mb|
97+ text "FSM1"
98+ menu TkMenu.new(mb) {
99+ add 'command', 'label' => 'bg1', 'command' => proc{
100+ puts "to \@FSM set Background = bg1"; STDOUT.flush
101+ }
102+ add 'command', 'label' => 'bg2', 'command' => proc{
103+ puts "to \@FSM set Background = bg2"; STDOUT.flush
104+ }
105+ add 'command', 'label' => 'bg3', 'command' => proc{
106+ puts "to \@FSM set Background = bg3"; STDOUT.flush
107+ }
108+ add 'command', 'label' => 'bg4', 'command' => proc{
109+ puts "to \@FSM set Background = bg4"; STDOUT.flush
110+ }
111+
112+ add 'command', 'label' => 'slab01', 'command' => proc{
113+ puts "to \@FSM set Background = slab01"; STDOUT.flush
114+ }
115+ add 'command', 'label' => 'slab02', 'command' => proc{
116+ puts "to \@FSM set Background = slab02"; STDOUT.flush
117+ }
118+ add 'command', 'label' => 'slab03', 'command' => proc{
119+ puts "to \@FSM set Background = slab03"; STDOUT.flush
120+ }
121+ add 'command', 'label' => 'slab04', 'command' => proc{
122+ puts "to \@FSM set Background = slab04"; STDOUT.flush
123+ }
124+ add 'command', 'label' => 'slab05', 'command' => proc{
125+ puts "to \@FSM set Background = slab05"; STDOUT.flush
126+ }
127+
128+ add 'command', 'label' => 'AgentEnable', 'command' => proc{
129+ puts "to \@FSM set AgentEnable = ENABLE"; STDOUT.flush
130+ }
131+ add 'command', 'label' => 'AgentDisable', 'command' => proc{
132+ puts "to \@FSM set AgentEnable = DISABLE"; STDOUT.flush
133+ }
134+
135+ add 'command', 'label' => 'ViewMode TEXTURE', 'command' => proc{
136+ puts "to \@FSM set ViewMode = TEXTURE"; STDOUT.flush
137+ }
138+ add 'command', 'label' => 'ViewMode TEXTURE_WITH_WIREFRAME', 'command' => proc{
139+ puts "to \@FSM set ViewMode = TEXTURE_WITH_WIREFRAME"; STDOUT.flush
140+ }
141+ add 'command', 'label' => 'ViewMode WIREFRAME', 'command' => proc{
142+ puts "to \@FSM set ViewMode = WIREFRAME"; STDOUT.flush
143+ }
144+
145+ add 'command', 'label' => 'Blink', 'command' => proc{
146+ puts "to \@FSM set FaceMot = BLINK 1"; STDOUT.flush
147+ }
148+ add 'command', 'label' => 'Nod', 'command' => proc{
149+ puts "to \@FSM set FaceMot = NOD 1"; STDOUT.flush
150+ }
151+ add 'command', 'label' => 'Refuse', 'command' => proc{
152+ puts "to \@FSM set FaceMot = REFUSE 1"; STDOUT.flush
153+ }
154+ add 'command', 'label' => 'Listen', 'command' => proc{
155+ puts "to \@FSM set FaceMot = LISTEN 1"; STDOUT.flush
156+ }
157+
158+ add 'command', 'label' => 'FS-MCL Nod', 'command' => proc{
159+ puts "to \@FS-MCL set Nod = 1"; STDOUT.flush
160+ }
161+
162+ }
163+ pack('side' => 'left', 'padx' => '1m')
164+}
165+
166+# -------------
167+
168+TkMenubutton.new(menubar) { |mb|
169+ text "FSM2"
170+ menu TkMenu.new(mb) {
171+ add 'command', 'label' => 'MouthScale 0', 'command' => proc{
172+ puts "to \@FSM set MouthScale = 0"; STDOUT.flush
173+ }
174+ add 'command', 'label' => 'MouthScale 20', 'command' => proc{
175+ puts "to \@FSM set MouthScale = 20"; STDOUT.flush
176+ }
177+ add 'command', 'label' => 'MouthScale 25', 'command' => proc{
178+ puts "to \@FSM set MouthScale = 25"; STDOUT.flush
179+ }
180+ add 'command', 'label' => 'MouthScale 30 (normal)', 'command' => proc{
181+ puts "to \@FSM set MouthScale = 30"; STDOUT.flush
182+ }
183+ add 'command', 'label' => 'MouthScale 35', 'command' => proc{
184+ puts "to \@FSM set MouthScale = 35"; STDOUT.flush
185+ }
186+
187+ add 'command', 'label' => 'AgentRot Init', 'command' => proc{
188+ puts "to \@FSM set AgentRot = 0.0 0.0 0.0"; STDOUT.flush
189+ }
190+ add 'command', 'label' => 'AgentRot Up', 'command' => proc{
191+ puts "to \@FSM set AgentRot = -5.0 0.0 0.0"; STDOUT.flush
192+ }
193+ add 'command', 'label' => 'AgentRot Down', 'command' => proc{
194+ puts "to \@FSM set AgentRot = 5.0 0.0 0.0"; STDOUT.flush
195+ }
196+ add 'command', 'label' => 'AgentRot Left', 'command' => proc{
197+ puts "to \@FSM set AgentRot = 0.0 -5.0 0.0"; STDOUT.flush
198+ }
199+ add 'command', 'label' => 'AgentRot Right', 'command' => proc{
200+ puts "to \@FSM set AgentRot = 0.0 5.0 0.0"; STDOUT.flush
201+ }
202+
203+ add 'command', 'label' => 'AgentTrans None', 'command' => proc{
204+ puts "to \@FSM set AgentTrans = 0.0 0.0"; STDOUT.flush
205+ }
206+ add 'command', 'label' => 'AgentTrans Up', 'command' => proc{
207+ puts "to \@FSM set AgentTrans = 0.0 0.2"; STDOUT.flush
208+ }
209+ add 'command', 'label' => 'AgentTrans Down', 'command' => proc{
210+ puts "to \@FSM set AgentTrans = 0.0 -0.2"; STDOUT.flush
211+ }
212+ add 'command', 'label' => 'AgentTrans Left', 'command' => proc{
213+ puts "to \@FSM set AgentTrans = -0.2 0.0"; STDOUT.flush
214+ }
215+ add 'command', 'label' => 'AgentTrans Right', 'command' => proc{
216+ puts "to \@FSM set AgentTrans = 0.2 0.0"; STDOUT.flush
217+ }
218+
219+ add 'command', 'label' => 'AgentScale 0.7', 'command' => proc{
220+ puts "to \@FSM set AgentScale = 0.7"; STDOUT.flush
221+ }
222+ add 'command', 'label' => 'AgentScale 1.0', 'command' => proc{
223+ puts "to \@FSM set AgentScale = 1.0"; STDOUT.flush
224+ }
225+ add 'command', 'label' => 'AgentScale 1.2', 'command' => proc{
226+ puts "to \@FSM set AgentScale = 1.2"; STDOUT.flush
227+ }
228+
229+ }
230+ pack('side' => 'left', 'padx' => '1m')
231+}
232+
233+# -------------
234+
235+TkMenubutton.new(menubar) { |mb|
236+ text "Mask"
237+ menu TkMenu.new(mb) {
238+ add 'command', 'label' => 'man01', 'command' => proc{
239+ puts "to \@AM-MCL set Mask = man01"; STDOUT.flush
240+ }
241+ add 'command', 'label' => 'man02', 'command' => proc{
242+ puts "to \@AM-MCL set Mask = man02"; STDOUT.flush
243+ }
244+ add 'command', 'label' => 'koizumi', 'command' => proc{
245+ puts "to \@AM-MCL set Mask = koizumi"; STDOUT.flush
246+ }
247+ add 'command', 'label' => 'woman01', 'command' => proc{
248+ puts "to \@AM-MCL set Mask = woman01"; STDOUT.flush
249+ }
250+
251+ }
252+ pack('side' => 'left', 'padx' => '1m')
253+}
254+
255+# -------------
256+
257+TkMenubutton.new(menubar) { |mb|
258+ text "FaceExp"
259+ menu TkMenu.new(mb) {
260+ add 'command', 'label' => 'AutoMove ON', 'command' => proc{
261+ puts "to \@FS-MCL set AutoMove = 1"; STDOUT.flush
262+ }
263+ add 'command', 'label' => 'AutoMove OFF', 'command' => proc{
264+ puts "to \@FS-MCL set AutoMove = 0"; STDOUT.flush
265+ }
266+
267+ add 'command', 'label' => 'Neutral', 'command' => proc{
268+ puts "to \@FS-MCL set Emotion = NEUTRAL"; STDOUT.flush
269+ }
270+ add 'command', 'label' => 'Happy', 'command' => proc{
271+ puts "to \@FS-MCL set Emotion = HAPPY 90"; STDOUT.flush
272+ }
273+ add 'command', 'label' => 'Disgusted', 'command' => proc{
274+ puts "to \@FS-MCL set Emotion = DISGUSTED 90"; STDOUT.flush
275+ }
276+ add 'command', 'label' => 'Sad', 'command' => proc{
277+ puts "to \@FS-MCL set Emotion = SAD 90"; STDOUT.flush
278+ }
279+ add 'command', 'label' => 'Angry', 'command' => proc{
280+ puts "to \@FS-MCL set Emotion = ANGRY 90"; STDOUT.flush
281+ }
282+ add 'command', 'label' => 'Surprised', 'command' => proc{
283+ puts "to \@FS-MCL set Emotion = SURPRISED 30"; STDOUT.flush
284+ }
285+ add 'command', 'label' => 'Feared', 'command' => proc{
286+ puts "to \@FS-MCL set Emotion = FEARED 90"; STDOUT.flush
287+ }
288+
289+ }
290+ pack('side' => 'left', 'padx' => '1m')
291+}
292+
293+# -------------
294+
295+TkMenubutton.new(menubar) { |mb|
296+ text "FaceRotate"
297+ menu TkMenu.new(mb) {
298+ add 'command', 'label' => 'Center', 'command' => proc{
299+ puts "to \@FS-MCL set Rot = 0 0 0"; STDOUT.flush
300+ }
301+
302+ add 'command', 'label' => 'Up', 'command' => proc{
303+ puts "to \@FS-MCL set Rot = -5 0 0"; STDOUT.flush
304+ }
305+ add 'command', 'label' => 'Down', 'command' => proc{
306+ puts "to \@FS-MCL set Rot = 5 0 0"; STDOUT.flush
307+ }
308+
309+ add 'command', 'label' => 'Left+', 'command' => proc{
310+ puts "to \@FS-MCL set Rot = 0 -15 0"; STDOUT.flush
311+ }
312+ add 'command', 'label' => 'Left', 'command' => proc{
313+ puts "to \@FS-MCL set Rot = 0 -7 0"; STDOUT.flush
314+ }
315+ add 'command', 'label' => 'Right', 'command' => proc{
316+ puts "to \@FS-MCL set Rot = 0 7 0"; STDOUT.flush
317+ }
318+ add 'command', 'label' => 'Right+', 'command' => proc{
319+ puts "to \@FS-MCL set Rot = 0 15 0"; STDOUT.flush
320+ }
321+ add 'command', 'label' => 'EyeRot Left', 'command' => proc{
322+ puts "to \@FS-MCL set EyeRot = 0 -10 0"; STDOUT.flush
323+ }
324+ add 'command', 'label' => 'EyeRot Center', 'command' => proc{
325+ puts "to \@FS-MCL set EyeRot = 0 0 0"; STDOUT.flush
326+ }
327+ add 'command', 'label' => 'EyeRot Right', 'command' => proc{
328+ puts "to \@FS-MCL set EyeRot = 0 10 0"; STDOUT.flush
329+ }
330+
331+ }
332+ pack('side' => 'left', 'padx' => '1m')
333+}
334+
335+# -------------
336+
337+TkMenubutton.new(menubar) { |mb|
338+ text "Demo"
339+ menu TkMenu.new(mb) {
340+ add 'command', 'label' => 'MoveMouth', 'command' => proc{
341+ puts 'to @AM-MCL set MoveMouth = scale 100 k 100 o 85 N 90 n 25 i 60 ch 105 i 50 w 50 a 95'; STDOUT.flush
342+ }
343+ add 'command', 'label' => 'Say Hello', 'command' => proc{
344+ puts 'to @AM-MCL set Speak = こんにちは。'; STDOUT.flush
345+ }
346+ add 'command', 'label' => 'Say Bye', 'command' => proc{
347+ puts 'to @AM-MCL set Speak = さようなら。'; STDOUT.flush
348+ }
349+ add 'command', 'label' => 'Use PAR', 'command' => proc{
350+ puts 'to @PAR set Init = 1'
351+ puts 'to @PAR set Cmd = sleep 1.0'
352+ puts 'to @PAR set Cmd = to @FS-MCL set Emotion = HAPPY'
353+ puts 'to @PAR set Cmd = sleep 1.4'
354+ puts 'to @PAR set Cmd = to @FS-MCL set Emotion = SAD'
355+ puts 'to @PAR set Cmd = sleep 2.0'
356+ puts 'to @PAR set Cmd = to @FS-MCL set Emotion = NEUTRAL'
357+ puts 'to @PAR set Cmd = to @FSM set FaceMot = NOD 1'
358+ puts 'to @AM-MCL set Speak = 私には、うれしいことも、悲しいことも、いろいろあります。'
359+ STDOUT.flush
360+ }
361+ add 'command', 'label' => 'Use SND', 'command' => proc{
362+ puts "to \@SND set Play = /usr/share/sndconfig/sample.au"
363+ STDOUT.flush
364+ }
365+ add 'command', 'label' => 'SSM 12345', 'command' => proc{
366+ puts "to \@SSM set Text = 12345"
367+ puts "to \@SSM set Speak = NOW"
368+ STDOUT.flush
369+ }
370+
371+
372+ }
373+ pack('side' => 'left', 'padx' => '1m')
374+}
375+
376+# -------------
377+
378+$gram = '<grammar version="1.0">'
379+
380+$gram += '<rule id="S"> <ruleref uri="NS_B"/> <ruleref uri="root"/> <ruleref uri="NS_E"/> </rule>'
381+$gram += '<rule id="NS_B"><token phoneme="silB;">silB:</token></rule>'
382+$gram += '<rule id="NS_E"><token phoneme="silE;">silE:</token></rule>'
383+$gram += '<rule id="SP"><token phoneme="sp;">sp:</token></rule>'
384+
385+$gram += '<rule id="root">'
386+$gram += ' <ruleref uri="sent"/>'
387+$gram += '</rule>'
388+$gram += '<rule id="root">'
389+$gram += ' <ruleref uri="pre"/> <ruleref uri="SP"/> <ruleref uri="sent"/>'
390+$gram += '</rule>'
391+$gram += '<rule id="root">'
392+$gram += ' <ruleref uri="pre"/> <ruleref uri="SP"/> <ruleref uri="sent"/> <ruleref uri="post"/>'
393+$gram += '</rule>'
394+$gram += '<rule id="root">'
395+$gram += ' <ruleref uri="sent"/> <ruleref uri="post"/>'
396+$gram += '</rule>'
397+
398+$gram += '<rule id="pre"> <ruleref uri="pre1"/> </rule>'
399+$gram += '<rule id="pre"> <ruleref uri="pre2"/> </rule>'
400+$gram += '<rule id="post"> <ruleref uri="post1"/> </rule>'
401+$gram += '<rule id="post"> <ruleref uri="post2"/> </rule>'
402+
403+$gram += '<rule id="pre1"><token phoneme="a:;">あー:</token></rule>'
404+$gram += '<rule id="pre2"><token phoneme="e:;">えー:</token></rule>'
405+$gram += '<rule id="post1"><token phoneme="d;e;s;">です:</token></rule>'
406+$gram += '<rule id="post2"><token phoneme="o;n;e;g;a;i;sh;i;m;a;s;u;">お願いします:</token></rule>'
407+
408+$gram += '<rule id="sent"><ruleref uri="g1"/></rule>'
409+$gram += '<rule id="sent"><ruleref uri="g2"/></rule>'
410+$gram += '<rule id="sent"><ruleref uri="rule_coffee"/></rule>'
411+$gram += '<rule id="sent"><ruleref uri="rule_tea"/></rule>'
412+
413+$gram += '<rule id="g1"> <token phoneme="h;a;i;" sym="はい">はい</token> </rule>'
414+$gram += '<rule id="g2"> <token phoneme="i:;e;" sym="いいえ">いいえ</token> </rule>'
415+$gram += '<rule id="rule_coffee"> <token phoneme="k;o:;h;i:;" sym="こーひー">コーヒー</token> </rule>'
416+$gram += '<rule id="rule_tea"> <token phoneme="k;o:;ch;a;" sym="こうちゃ">紅茶</token> </rule>'
417+
418+$gram += '</grammar>'
419+
420+TkMenubutton.new(menubar) { |mb|
421+ text "SRM"
422+ menu TkMenu.new(mb) {
423+
424+ add 'command', 'label' => 'Response ON', 'command' => proc{
425+ puts "set RecogResponse = 1"; STDOUT.flush
426+ }
427+
428+ add 'command', 'label' => 'Recsponse OFF', 'command' => proc{
429+ puts "set RecogResponse = 0"; STDOUT.flush
430+ }
431+
432+ add 'command', 'label' => 'Start', 'command' => proc{
433+ puts "to \@SIM set SRM_Recog = START"
434+ puts "to \@SIM set SRM_XML_String = " + $gram
435+ STDOUT.flush
436+ }
437+
438+ add 'command', 'label' => 'XML renraku', 'command' => proc{
439+ puts "to \@SIM set SRM_XML_File = GramXML/renraku/renraku.xml"
440+ STDOUT.flush
441+ # 発話「甲斐さんの連絡先を教えて下さい」
442+ }
443+ add 'command', 'label' => 'XML string', 'command' => proc{
444+ puts "to \@SIM set SRM_XML_String = " + $gram
445+ STDOUT.flush
446+ # 発話「はい」
447+ }
448+ add 'command', 'label' => 'Julian vfr', 'command' => proc{
449+ puts "to \@SIM set SRM_Julian = GramJulian/vfr/vfr"
450+ STDOUT.flush
451+ # 発話「上着を白にしてください」
452+ }
453+ add 'command', 'label' => 'Julian name', 'command' => proc{
454+ puts "to \@SIM set SRM_Julian = GramJulian/attendant/name"
455+ STDOUT.flush
456+ # 発話「小泉さんお願いします」
457+ }
458+
459+ add 'command', 'label' => 'Pause', 'command' => proc{
460+ puts "to \@SRM set Run = PAUSE"
461+ STDOUT.flush
462+ }
463+ add 'command', 'label' => 'Resume', 'command' => proc{
464+ puts "to \@SRM set Run = RESUME"
465+ STDOUT.flush
466+ }
467+ add 'command', 'label' => 'Stop', 'command' => proc{
468+ puts "to \@SRM set Run = STOP"
469+ STDOUT.flush
470+ }
471+
472+ add 'command', 'label' => 'AddGram', 'command' => proc{
473+ puts "to \@SIM set AddGramName = hello"
474+ puts "to \@SIM set AddGram = " + $gram
475+ STDOUT.flush
476+ }
477+
478+ add 'command', 'label' => 'DeactivateGram', 'command' => proc{
479+ puts "to \@SIM set DeactivateGram = hello"
480+ STDOUT.flush
481+ }
482+
483+ add 'command', 'label' => 'ActivateGram', 'command' => proc{
484+ puts "to \@SIM set ActivateGram = hello"
485+ STDOUT.flush
486+ }
487+
488+ }
489+ pack('side' => 'left', 'padx' => '1m')
490+}
491+
492+# -------------
493+
494+frame_toolbar = TkFrame.new {
495+ pack('fill' => 'x')
496+}
497+
498+# -------------
499+
500+$syslog = nil
501+$applog = nil
502+$start_day = Time.now.to_f
503+
504+class MON < GalateaBase
505+ def initialize
506+ super
507+ @modulename = "MON"
508+ @debug = false
509+
510+ @myslot["Run"] = "LIVE"
511+
512+ @applog_disp = Array.new
513+ @syslog_disp = Array.new
514+ end
515+
516+ def add_applog(arg)
517+ @applog_disp.push(arg)
518+ if @applog_disp.length > $applog_height then @applog_disp.delete_at(0) end
519+ str = ''
520+ @applog_disp.each do |i| str += i; str += "\n" end
521+ unless $applog.nil? then
522+ $applog.delete '1.0', 'end'
523+ $applog.insert 'end', str
524+ end
525+ end
526+
527+
528+ def add_syslog(arg)
529+ @syslog_disp.push(arg)
530+ if @syslog_disp.length > $syslog_height then @syslog_disp.delete_at(0) end
531+ str = ''
532+ @syslog_disp.each do |i| str += i; str += "\n" end
533+ unless $syslog.nil? then
534+ $syslog.delete '1.0', 'end'
535+ $syslog.insert 'end', str
536+ end
537+ end
538+
539+
540+ def do_set(slot, arg)
541+ super
542+
543+ if slot == "AppLogText"
544+# add_applog(arg)
545+ elsif slot == "SysLogText"
546+# add_syslog(arg)
547+ elsif slot == "Run" && arg =="EXIT"
548+ Process.exit!(0)
549+
550+ end
551+
552+ end
553+
554+end
555+
556+# -------------
557+
558+begin
559+ Thread.start do
560+ MON.new.run
561+ end
562+
563+ # -------------
564+
565+# frame1 = TkFrame.new {
566+# pack('side'=>'top', 'fill'=>'both', 'expand'=>'true')
567+# }
568+#
569+# #$bar1 = TkScrollbar.new(frame1) {
570+# # pack('side'=>'right', 'fill'=>'y')
571+# #}
572+# $applog = TkText.new(frame1) {
573+# wrap 'none'
574+# height $applog_height
575+# pack('side'=>'left', 'fill'=>'both', 'expand'=>'true')
576+# # insert 'end', "[AppLog]\n"
577+# }
578+# #$applog.yscrollbar($bar1)
579+
580+ # -------------
581+
582+# frame2 = TkFrame.new {
583+# pack('side'=>'top', 'fill'=>'both', 'expand'=>'true')
584+# }
585+#
586+# #$bar2 = TkScrollbar.new(frame2) {
587+# # pack('side'=>'right', 'fill'=>'y')
588+# #}
589+# $syslog = TkText.new(frame2) {
590+# wrap 'none'
591+# height $syslog_height
592+# pack('side'=>'left', 'fill'=>'both', 'expand'=>'true')
593+# # insert 'end', "[SysLog]\n"
594+# }
595+# #$syslog.yscrollbar($bar2)
596+
597+ # -------------
598+
599+ Tk.root.title("MON")
600+ Tk.mainloop
601+
602+ # -------------
603+rescue
604+ Process.exit!(1)
605+end
606+
607+# end of file
diff -r 000000000000 -r 5298508466dd modules/PAR.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/PAR.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,84 @@
1+#!/usr/bin/ruby
2+# $Id: PAR.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
3+#
4+# Parallel command handling module for Galatea
5+# by Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
6+#
7+# set Init = 1 [Queue ID : only 1 is supported now]
8+# set Cmd = sleep 3
9+# set Cmd = to @FSM set FaceExp = HAPPY 1 100 1000
10+#
11+# rep Speak.stat = hogehoge
12+# or
13+# set Run = NOW
14+#
15+# TODO:
16+# multi-thread (non-blocking command handling)
17+# multiple-queue (needed?)
18+# better synchronization mechanism
19+#
20+
21+require 'GalateaBase.rb'
22+
23+class PAR < GalateaBase
24+
25+ def initialize
26+ super
27+ @modulename = "PAR"
28+ @debug = false
29+ @id = 0
30+ @queue1 = Array.new
31+ end
32+
33+
34+ def exec_queue()
35+ while @queue1.length > 0 do
36+ print_debug("queue1.length=" + @queue1.length.to_s)
37+ cmd = @queue1.delete_at(0)
38+ print_debug("cmd=" + cmd)
39+ cmd =~ /(.*)\s+(.*)$/
40+ if $1 == "sleep" then
41+ print_debug("sleeping " +$2)
42+ sleep $2.to_f
43+ else
44+ print_out(cmd)
45+ print_debug(cmd)
46+ end
47+ end
48+ print_debug("queue1 done.")
49+ end
50+
51+
52+ def do_set(slot, arg)
53+ super
54+ if slot == "Init"
55+ @id = arg.to_i
56+ @queue1 = []
57+ elsif slot == "Cmd"
58+ # set Cmd = sleep 5
59+ # set Cmd = to @FSM set FaceExp = HAPPY 1 100 0
60+ @queue1.push(arg)
61+ elsif slot == "Run" && arg == "NOW"
62+ # set Run = NOW
63+ exec_queue()
64+ end
65+ end
66+
67+
68+ def accept_from(mod, str)
69+ if mod == "SSM" && /rep\s+Speak\.stat\s*=\s*(.*)$/ =~ str
70+ exec_queue()
71+ elsif mod == "FSM" && /rep\s+Speak\.stat\s*=\s*(.*)$/ =~ str
72+ exec_queue()
73+ elsif mod == "SND" && /tell start/ =~ str
74+ exec_queue()
75+ end
76+ end
77+
78+end
79+
80+# ------------------------------
81+
82+PAR.new.run
83+
84+# end of file
diff -r 000000000000 -r 5298508466dd modules/SND.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/SND.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,61 @@
1+#!/usr/bin/ruby -Ke
2+# $Id: SND.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
3+#
4+# by Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
5+#
6+# set Play = /usr/share/sndconfig/sample.au
7+# set Play = STOP
8+# set Play = /data/video/kani030611.mpg
9+
10+require 'GalateaBase.rb'
11+
12+class SND < GalateaBase
13+
14+ def initialize
15+ super
16+ @modulename = "SND"
17+ @debug = false
18+
19+ @cmd = nil
20+ @arg = nil
21+ Thread.start do
22+ while true
23+ if @cmd != nil
24+ print_tell "start #{@arg}"
25+ system @cmd
26+ print_tell "end #{@arg}"
27+ @cmd = nil
28+ end
29+ sleep 0.001
30+ end
31+ end
32+ end
33+
34+ def do_set(slot, arg)
35+ super
36+
37+ if slot == "Play"
38+ if arg == "STOP" && @pid.to_i != 0
39+ print_debug "killing #{@pid}"
40+ Process.kill "SIGTERM", @pid
41+ # not working...
42+
43+ else
44+ arg.gsub!( /^file:/, "" )
45+ @arg = arg
46+ if /\.mpg$/ =~ arg
47+ @cmd = "/usr/bin/gmplayer -fs -really-quiet #{arg}"
48+ else
49+ # @cmd = "/usr/bin/play -v 0.2 #{arg}"
50+ @cmd = "/usr/bin/play -v 1.0 #{arg}"
51+ end
52+ print_debug "#{@cmd} #{@arg}"
53+ end
54+ end
55+ end
56+
57+end
58+
59+SND.new.run
60+
61+# end of file
diff -r 000000000000 -r 5298508466dd modules/SRMdummy.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/SRMdummy.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,71 @@
1+#!/usr/bin/ruby
2+#
3+# (c)2003 Takuya NISHIMOTO (nishi@hil.t.u-tokyo.ac.jp)
4+#
5+# $Id: SRMdummy.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
6+#
7+
8+$tk_thread_safe = TRUE
9+require 'tk'
10+
11+# -------------
12+
13+Thread.start {
14+
15+ while gets
16+ add_text $_
17+
18+ if /^set\s+([^\s]+)\s+=\s+(.*)$/ =~ $_ then
19+ name = $1
20+ value = $2
21+ if name == 'Set' && value == 'Grammar' then
22+ puts "tell grammar send complete"
23+ puts "tell grammar conversion complete"
24+ STDOUT.flush
25+ elsif name == 'Run' && value == 'START' then
26+ puts "tell <INPUT STATUS=\"LISTEN\" TIME=\"0\"/>"
27+ STDOUT.flush
28+ elsif name == 'Run' && value == 'RESUME' then
29+ puts "tell <INPUT STATUS=\"LISTEN\" TIME=\"0\"/>"
30+ STDOUT.flush
31+ elsif name == 'Run' && value == 'EXIT' then
32+ Process.exit!(0)
33+ else
34+ STDOUT.flush
35+ end
36+ end
37+ end
38+}
39+
40+# -------------
41+
42+def add_text(str)
43+ day = Time.now
44+ ds = day.strftime("%M:%S")
45+ $syslog.insert 'end', format("%s %s", ds, str)
46+ $syslog.yview 'end'
47+end
48+
49+frame1 = TkFrame.new {
50+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'true')
51+}
52+
53+$bar1 = TkScrollbar.new(frame1) {
54+ pack('side'=>'right', 'fill'=>'y')
55+ command proc { |args| $syslog.yview(*args) }
56+}
57+
58+$syslog = TkText.new(frame1) {
59+ width 60
60+ height 10
61+ wrap 'none'
62+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'true')
63+ yscrollcommand proc { |first, last| $bar1.set(first, last) }
64+}
65+
66+# -------------
67+
68+Tk.root.title("SRM")
69+Tk.mainloop
70+
71+# end of file
diff -r 000000000000 -r 5298508466dd modules/SSM-espeak.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/SSM-espeak.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,69 @@
1+#!/usr/bin/ruby -Ke
2+# $Id: SSM-espeak.rb,v 1.1 2008/10/05 01:33:42 nishimoto Exp $
3+#
4+# by Takuya NISHIMOTO (nishimoto@m.ieice.org)
5+#
6+
7+require 'GalateaBase.rb'
8+
9+class SSM < GalateaBase
10+
11+ def initialize
12+ super
13+ @modulename = 'SSM'
14+ @debug = true
15+ @text = ''
16+ @pho = 'a[100] u[100] a[100] u[100] a[100] u[100] a[100] u[100] a[100] u[100]'
17+ @len = 1000
18+
19+ @cmd = nil
20+ @arg = nil
21+ @stat = nil
22+ Thread.start do
23+ while true
24+ if @cmd != nil
25+ print_rep "Speak.stat = SPEAKING"
26+ print_rep "Speak.len = #{@len.to_s}"
27+ print_rep "Speak.utt = #{@pho}"
28+ system @cmd
29+ print_rep "Speak.stat = IDLE"
30+ @cmd = nil
31+ end
32+ if @stat != nil
33+ print_rep "Speak.stat = #{@stat}"
34+ @stat = nil
35+ end
36+ sleep 0.001
37+ end
38+ end
39+ sleep 1
40+ print_rep "Run = LIVE"
41+ end
42+
43+ def do_set(slot, arg)
44+ super
45+ case slot
46+ when 'Text'
47+ @text = arg
48+ print_rep "Speak.stat = PROCESSING"
49+ print_rep "Text.text = #{@text}"
50+ print_rep "Speak.text = #{@text}"
51+ print_rep "Text.pho = #{@pho}"
52+ print_rep "Speak.pho = #{@pho}"
53+ print_rep "Text.dur = #{@len.to_s}"
54+ print_rep "Speak.dur = #{@len.to_s}"
55+ sleep 0.0001
56+ @stat = 'READY'
57+ when 'Speak'
58+ if (arg == 'NOW' or arg == '+ 0') and @text != nil
59+ @cmd = "/usr/bin/espeak '#{@text}'"
60+ @text = nil
61+ end
62+ end
63+ end
64+
65+end
66+
67+SSM.new.run
68+
69+# end of file
diff -r 000000000000 -r 5298508466dd modules/ssm-chasen-proxy.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ssm-chasen-proxy.rb Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,97 @@
1+#!/usr/bin/ruby -Ke
2+# ssm-chasen-proxy.rb by Takuya Nishimoto
3+# since 2008-08-26
4+#
5+# - depends on mecab + ipadic
6+# -- tested with Ubuntu 8.04.1
7+# -- sudo apt-get install mecab mecab-ipadic
8+# - works as chasen-2.4.x-istc + unidic-chasen-1.3.9
9+# - called from gtalk
10+#
11+
12+require 'rexml/parsers/streamparser'
13+require 'rexml/parsers/baseparser'
14+require 'rexml/streamlistener'
15+require 'nkf'
16+
17+class MeCab
18+ def initialize
19+ @io = IO.popen("/usr/bin/mecab","r+")
20+ end
21+ def parse(input)
22+ @io.puts(input)
23+ word_list = []
24+ str = @io.gets.chomp
25+ while str != 'EOS' do
26+ word_list << str.split("\t")
27+ str = @io.gets.chomp
28+ end
29+ word_list
30+ end
31+end
32+
33+class MyListener
34+ include REXML::StreamListener
35+ def initialize
36+ super
37+ @mecab = MeCab.new
38+ end
39+ def tag_start(name, attrs)
40+ x = name.dup
41+ attrs.each_pair do |k,v|
42+ x += ' ' + k
43+ x += '="' + v + '"'
44+ end
45+ s = NKF.nkf('-e', x)
46+ puts "<#{s}>"
47+ end
48+ def tag_end s
49+ puts "</#{s}>"
50+ end
51+ def text x
52+ s = NKF.nkf('-e', x)
53+ @mecab.parse(s).each do |w|
54+ orth = w[0]
55+ a = w[1].split(',')
56+ kana = a[7]
57+ pron = a[8]
58+ pos = a[0]
59+ kanaBase = a[6]
60+ kana = orth if kana == nil
61+ pron = orth if pron == nil
62+ goshu = '和'
63+ case a[0]
64+ when '名詞' then pos = '名詞-普通名詞-一般'
65+ when '動詞' then pos = '動詞-一般'
66+ when '助詞' then pos = '動詞-格助詞'
67+ end
68+ puts <<EOS
69+<W1 orth="#{orth}" kana="#{kana}" pron="#{pron}" pos="#{pos}" orthBase="#{orth}"
70+ kanaBase="#{kana}" pronBase="#{pron}" lForm="#{kana}" lemma="#{orth}" form="#{kana}"
71+ aType="1" aConType="C1" goshu="#{goshu}">#{orth}</W1>
72+EOS
73+ end
74+ end
75+end
76+
77+listener = MyListener.new
78+
79+until STDIN.eof? do
80+ str = STDIN.gets
81+ if str != nil
82+ puts "<S>"
83+ source = NKF.nkf('-w', str.chomp)
84+ REXML::Parsers::StreamParser.new(source, listener).parse
85+ puts "</S>"
86+ STDOUT.flush
87+ end
88+end
89+
90+
91+
92+
93+
94+
95+
96+
97+
diff -r 000000000000 -r 5298508466dd script/runner
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/runner Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,12 @@
1+#!/usr/bin/ruby -Ku
2+$runner_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3+$skel_dir = File.expand_path(File.join(File.dirname(__FILE__), '../skel'))
4+$tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), '../tmp'))
5+$generator_dir = "/usr/local/galatea-dialog"
6+[ $runner_dir, $generator_dir ].each do |d|
7+ f = File.join(d, 'lib', 'galatea_runner.rb')
8+ if File.exist?(f)
9+ $library_dir = File.join(d , 'lib')
10+ load(f)
11+ end
12+end
diff -r 000000000000 -r 5298508466dd script/vumonitor
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/vumonitor Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,4 @@
1+#!/bin/sh
2+pavucontrol &
3+padsp -M wavesurfer &
4+
diff -r 000000000000 -r 5298508466dd skel/am.conf.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/am.conf.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,28 @@
1+# am.conf
2+<%
3+classpath = p('javascript.jar') + ":" + p('dm.jar')
4+java_bin = p('java.bin')
5+ruby_bin = p('ruby.bin')
6+am_commands_dm = "#{java_bin} -cp #{classpath} galatea.dialog.DialogManager -c #{@runner_tmp_dir}/gdm.conf" + " " + @dm_options
7+am_commands_fsm = "cd #{p('fsm.galateafsm.engine_dir')}; ./fsm -C #{@runner_tmp_dir}/fsm.conf"
8+am_commands_fs_mcl = "#{java_bin} -cp #{classpath} galatea.agent.BehaviorManager -c #{@runner_tmp_dir}/gdm.conf"
9+am_commands_ssm = "cd #{p('ssm.gtalk.engine_dir')}; /usr/bin/padsp ./gtalk -C #{@runner_tmp_dir}/ssm.conf"
10+my_fsm_dir = "/lab/common/src/nishi/github/facesynthesizer/bin"
11+my_module_dir = @runner_tmp_dir + "/../modules"
12+%>
13+#------------------------------------------------------------------
14+broadcast: AM-MCL FS-MCL PAR DM
15+#------------------------------------------------------------------
16+# control
17+module:DM commands: <%= am_commands_dm %>
18+#------------------------------------------------------------------
19+# input
20+# module:SRM commands:
21+#------------------------------------------------------------------
22+# output
23+module:FSM commands: cd <%= my_fsm_dir %>; ./fsm -C <%= @runner_tmp_dir %>/fsm.conf
24+module:SSM commands: <%= am_commands_ssm %>
25+module:AM-MCL commands: cd <%= my_module_dir %>;<%= ruby_bin %> AM-MCL.rb -C <%= @runner_tmp_dir %>/am_mcl.conf
26+module:PAR commands: cd <%= my_module_dir %>;<%= ruby_bin %> PAR.rb
27+module:FS-MCL commands: <%= java_bin %> -cp <%= classpath %> galatea.agent.BehaviorManager -c <%= @runner_tmp_dir %>/gdm.conf
28+#----- EOF --------------------------------------------------------
diff -r 000000000000 -r 5298508466dd skel/am_mcl.conf.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/am_mcl.conf.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,11 @@
1+# $Id: am_mcl.conf.txt,v 1.3 2009/08/24 13:19:48 nishimoto Exp $
2+
3+default_agent : <%= p('default_agent') %>
4+agents:
5+<% p('agents').each do |o| -%>
6+ - name : <%= o['name'] %>
7+ mask : <%= o['mask'] %>
8+ speaker : <%= o['speaker'] %>
9+<% end -%>
10+
11+# eof
diff -r 000000000000 -r 5298508466dd skel/chasenrc-euc-jp.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/chasenrc-euc-jp.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,29 @@
1+;;
2+;; chasenrc for unidic / chaOne
3+;;
4+(GRAMMAR <%= param('ssm.gtalk.unidic_dir') %>)
5+(DADIC chadic)
6+
7+(UNKNOWN_POS (名詞 普通名詞 一般))
8+
9+(OUTPUT_FORMAT "<W1 orth=\"%m\" kana=\"%?U/%m/%y0/\" pron=\"%?U/%m/%a0/\" pos=\"%U(%P-)\"%?T/ cType=\"%T \"//%?F/ cForm=\"%F \"//%?I/ %i0//>%m</W1>\n")
10+
11+(OUTPUT_COMPOUND "SEG")
12+
13+(BOS_STRING "<S>\n")
14+(EOS_STRING "</S>\n")
15+
16+(DEF_CONN_COST 10000)
17+(POS_COST
18+ ((*) 1)
19+ ((UNKNOWN) 30000)
20+)
21+
22+(CONN_WEIGHT 1)
23+(MORPH_WEIGHT 1)
24+(COST_WIDTH 0)
25+
26+(ANNOTATION
27+ (("<" ">") "%m\n")
28+ (("\"") "<cha:W1 orth=\"&#x22;\" kana=\"&#x22;\" pron=\"&#x22;\" pos=\"%U(%P-)\"%?T/ cType=\"%T \"//%?F/ cForm=\"%F \"//%?I/ %i//>%m</cha:W1>\n")
29+)
diff -r 000000000000 -r 5298508466dd skel/fsm.conf.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/fsm.conf.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,74 @@
1+<%
2+sample = "../sample"
3+data = "../data"
4+%>
5+
6+MaxFrameRate 30
7+SetViseme JP
8+DEF_WINDOW_WIDTH 512
9+DEF_WINDOW_HEIGHT 512
10+DEF_WINDOW_POS_X 0
11+DEF_WINDOW_POS_Y 0
12+EXPRESSION_DURATION 100
13+EYEMOVE_DURATION 70
14+
15+MaskFile woman01 <%= sample %>/woman01.rgb <%= sample %>/woman01.pnt
16+MaskFile man01 <%= sample %>/man01.rgb <%= sample %>/man01.pnt
17+MaskFile man02 <%= sample %>/man02.bmp <%= sample %>/man02.pnt
18+
19+MaskEye woman01 <%= sample %>/woman01_eye.bmp <%= sample %>/woman01_eye.def_e
20+MaskEye man01 <%= sample %>/man01_eye.bmp <%= sample %>/man01_eye.def_e
21+MaskEye man02 <%= sample %>/man02_eye.bmp <%= sample %>/man02_eye.def_e
22+
23+MaskTeeth woman01 <%= sample %>/woman01_teeth.def_t
24+MaskTeeth man01 <%= sample %>/man01_teeth.def_t
25+MaskTeeth man02 <%= sample %>/man02_teeth.def_t
26+
27+BackgroundFile bg1 <%= sample %>/BG/bg1.png
28+BackgroundFile bg2 <%= sample %>/BG/bg2.png
29+BackgroundFile bg3 <%= sample %>/BG/bg3.png
30+BackgroundFile bg4 <%= sample %>/BG/bg4.png
31+<% dir = p('fsm.galateafsm.tests_dir') -%>
32+<% if File.exists?("#{dir}/castle01.bmp") -%>
33+BackgroundFile castle01 <%= dir %>/castle01.bmp
34+BackgroundFile castle02 <%= dir %>/castle02.bmp
35+BackgroundFile castle03 <%= dir %>/castle03.bmp
36+BackgroundFile castle04 <%= dir %>/castle04.bmp
37+BackgroundFile clab01 <%= dir %>/clab01.bmp
38+<% end -%>
39+
40+FaceMotNod <%= sample %>/motion/FaceMot_Nod_1.dat
41+FaceMotNod <%= sample %>/motion/FaceMot_Nod_2.dat
42+FaceMotNod <%= sample %>/motion/FaceMot_Nod_3.dat
43+
44+FaceMotRefuse <%= sample %>/motion/FaceMot_Refuse_1.dat
45+FaceMotRefuse <%= sample %>/motion/FaceMot_Refuse_2.dat
46+FaceMotRefuse <%= sample %>/motion/FaceMot_Refuse_3.dat
47+
48+FaceMotListen <%= sample %>/motion/FaceMot_Listen_1.dat
49+FaceMotListen <%= sample %>/motion/FaceMot_Listen_2.dat
50+FaceMotListen <%= sample %>/motion/FaceMot_Listen_3.dat
51+
52+FaceMotBlink 100
53+FaceMotBlink 200
54+FaceMotBlink 400
55+FaceMotBlink 600
56+
57+AutonomousBlink 1 1
58+AutonomousBlink 1 2
59+AutonomousBlink 1 3
60+AutonomousBlink 1 4
61+AutonomousBlink 2 1
62+AutonomousBlink 2 3
63+
64+AutonomousMove <%= sample %>/motion/autonomous_move1.dat
65+AutonomousUserdef <%= sample %>/motion/autonomous_userdef1.dat
66+
67+U_TEETH_OBJ_NAME <%= data %>/teethUpper.obj
68+L_TEETH_OBJ_NAME <%= data %>/teethLower.obj
69+M_WALL_OBJ_NAME <%= data %>/mouthwall.obj
70+EYE_OBJ_NAME <%= data %>/eye.obj
71+M_WALL_TEXTURE <%= data %>/mouthwall.bmp
72+DEF_WFM_PNT <%= data %>/fheadv2.pnt
73+DEF_WFM_LNK <%= data %>/fheadv2.lnk
74+
diff -r 000000000000 -r 5298508466dd skel/gdm.conf.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/gdm.conf.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,59 @@
1+# Galatea Dialog Studio configuration skelton
2+# (c) Takuya NISHIMOTO
3+# $Id: gdm.conf.txt,v 1.4 2009/08/24 13:19:48 nishimoto Exp $
4+<%
5+dm_lang = p('dm.lang')
6+srm_lang = p('dm.lang')
7+grammar_mkdfa_dir = p('srm.julius.engine_dir') + "/bin"
8+grammar_mkdfa_exe = "mkdfa.pl"
9+
10+julius_server_runner_dir = p('srm.julius.engine_dir')
11+julius_server_runner_arg = "-C #{@runner_tmp_dir}/julius.conf"
12+julius_server_runner_exe = p('srm.julius.bin') || p('srm.julius.engine_dir') + "/bin/julius"
13+%>
14+
15+# awt.useSystemAAFontSettings :on
16+
17+DM.Language :<%= dm_lang %>
18+DM.CondidenceMeasureThres :0.5
19+
20+AMThread.StartupWait :0
21+
22+Logger.IC :0
23+Logger.RecogInterpreter :0
24+Logger.SubProcess :0
25+Logger.AMThread :0
26+Logger.JuliusClient :1
27+Logger.JuliusServerRunner :0
28+Logger.JuliusSubModule :0
29+Logger.GrammarSubModule :0
30+
31+# built-in GRM
32+Grammar.Mkdfa.Dir : <%= grammar_mkdfa_dir %>
33+Grammar.Mkdfa.Exe : <%= grammar_mkdfa_exe %>
34+Grammar.Mkdfa.Perl : <%= p('perl.bin') %>
35+Grammar.WorkDir : <%= @runner_tmp_dir %>
36+Grammar.TemplateResourcePath : /res/grammar/grammar-<%= srm_lang %>.xml
37+Grammar.UseMkdfaExe : 0
38+
39+# switch SRM
40+DM.UseWrapper.SRM : 0
41+JuliusServerRunner.Dir : <%= julius_server_runner_dir %>
42+JuliusServerRunner.Arg : <%= julius_server_runner_arg %>
43+JuliusServerRunner.Exe : <%= julius_server_runner_exe %>
44+
45+# switch SSM
46+DM.UseWrapper.SSM : 1
47+
48+# for Dialog Studio GUI
49+user.dir.suffix : /../
50+
51+# for BehaviorManager
52+Behavior.DefaultAgent : <%= p('default_agent') %>
53+Behavior.NumAgent : <%= p('agents').count %>
54+<% p('agents').each_with_index do |o,i| -%>
55+Behavior.Agent.<%= i+1 %> : <%= o['name'] %> <%= o['mask'] %> <%= o['speaker'] %> <%= o['bg'] %> <%= o['scale'] %>
56+<% end -%>
57+
58+# End of file
59+
diff -r 000000000000 -r 5298508466dd skel/julius.conf.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/julius.conf.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,28 @@
1+<%
2+gram_dir = p('srm.julius.engine_dir') + '/GramJulian'
3+am_dir = p('srm.julius.engine_dir') + '/AcousticModel'
4+%>
5+-dfa <%= gram_dir %>/vfr/vfr.dfa
6+-v <%= gram_dir %>/vfr/vfr.dict
7+-gmmreject "noise,laugh,cough"
8+-gmm <%= am_dir %>/gmmdefs.binhmm
9+-hlist <%= am_dir %>/logicalTri
10+-h <%= am_dir %>/hmmdefs,ptm,gid.binhmm
11+-spsegment
12+-looktrellis
13+-input alsa
14+-b 600
15+-b2 40
16+-lookuprange 5
17+-gmmnum 10
18+-proginterval 300
19+-outcode WLPSC
20+-zmeanframe
21+-tmix 2
22+-m 1000
23+-s 500
24+-n 1
25+-output 1
26+-lv 2000
27+-rejectshort 200
28+-module 10500
diff -r 000000000000 -r 5298508466dd skel/ssm.conf.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/skel/ssm.conf.txt Thu Oct 14 18:08:44 2010 +0900
@@ -0,0 +1,64 @@
1+# configuratiuon file for gtalk (GalateaTalk)
2+
3+#AUDIODEV: <%= p('ssm.gtalk.audiodev') %>
4+
5+CHASEN: <%= p('ssm.gtalk.chasen_dir') %>/bin/chasen
6+CHAONE: <%= p('ssm.gtalk.chaone_dir') %>/chaone -s gtalk
7+CHASEN-RC: <%= @runner_tmp_dir %>/chasenrc-euc-jp
8+
9+# default for numbers and alphabets
10+NUMBER: DECIMAL
11+ALPHABET: WORD
12+DATE: YMD
13+TIME: hms
14+
15+# dictionary
16+DICTIONARY: <%= p('ssm.dir') %>/gtalk/gtalk-eucjp.dic
17+
18+# automatic play of synthesized speech
19+AUTO-PLAY: NO
20+
21+# time delay [msec] for autuomatic play
22+AUTO-PLAY-DELAY: 250
23+
24+# file of phoneme list
25+PHONEME-LIST: <%= p('ssm.dir') %>/gtalk/mono.lst
26+
27+# parameter files for each speaker
28+SPEAKER-ID: female01
29+GENDER: female
30+DUR-TREE-FILE: <%= p('ssm.dir') %>/speakers/female01/tree-dur.inf
31+PIT-TREE-FILE: <%= p('ssm.dir') %>/speakers/female01/tree-lf0.inf
32+MCEP-TREE-FILE: <%= p('ssm.dir') %>/speakers/female01/tree-mcep.inf
33+DUR-MODEL-FILE: <%= p('ssm.dir') %>/speakers/female01/duration.pdf
34+PIT-MODEL-FILE: <%= p('ssm.dir') %>/speakers/female01/lf0.pdf
35+MCEP-MODEL-FILE: <%= p('ssm.dir') %>/speakers/female01/mcep.pdf
36+
37+# parameter files for each speaker
38+SPEAKER-ID: male01
39+GENDER: male
40+DUR-TREE-FILE: <%= p('ssm.dir') %>/speakers/male01/tree-dur.inf
41+PIT-TREE-FILE: <%= p('ssm.dir') %>/speakers/male01/tree-lf0.inf
42+MCEP-TREE-FILE: <%= p('ssm.dir') %>/speakers/male01/tree-mcep.inf
43+DUR-MODEL-FILE: <%= p('ssm.dir') %>/speakers/male01/duration.pdf
44+PIT-MODEL-FILE: <%= p('ssm.dir') %>/speakers/male01/lf0.pdf
45+MCEP-MODEL-FILE: <%= p('ssm.dir') %>/speakers/male01/mcep.pdf
46+
47+# parameter files for each speaker
48+SPEAKER-ID: male02
49+GENDER: male
50+DUR-TREE-FILE: <%= p('ssm.dir') %>/speakers/male02/tree-dur.inf
51+PIT-TREE-FILE: <%= p('ssm.dir') %>/speakers/male02/tree-lf0.inf
52+MCEP-TREE-FILE: <%= p('ssm.dir') %>/speakers/male02/tree-mcep.inf
53+DUR-MODEL-FILE: <%= p('ssm.dir') %>/speakers/male02/duration.pdf
54+PIT-MODEL-FILE: <%= p('ssm.dir') %>/speakers/male02/lf0.pdf
55+MCEP-MODEL-FILE: <%= p('ssm.dir') %>/speakers/male02/mcep.pdf
56+
57+SPEAKER-ID: m001
58+GENDER: male
59+DUR-TREE-FILE: <%= p('ssm.dir') %>/speakers/m001/tree-dur.inf
60+PIT-TREE-FILE: <%= p('ssm.dir') %>/speakers/m001/tree-lf0.inf
61+MCEP-TREE-FILE: <%= p('ssm.dir') %>/speakers/m001/tree-mcep.inf
62+DUR-MODEL-FILE: <%= p('ssm.dir') %>/speakers/m001/duration.pdf
63+PIT-MODEL-FILE: <%= p('ssm.dir') %>/speakers/m001/lf0.pdf
64+MCEP-MODEL-FILE: <%= p('ssm.dir') %>/speakers/m001/mcep.pdf
Show on old repository browser