Timer variables

March 29, 2013

A special type of variable called “timer variable” can be used in a dialog scenario file (.fst) as a countdown timer.  When a duration time is set to a timer variable in seconds by using the TIMER_START command, the variable starts counting down from that specified value in units of 0.1 seconds.  When it reaches a value which is below or equal to zero, a TIMER_EVENT_STOP event will be emitted.  In the following example, the system is told to wait three minutes and then synthesize the utterance.

    1  11   RECOG_EVENT_STOP|三分     TIMER_START|timer|180.0
    11 12   TIMER_EVENT_STOP|timer   SYNTH_START|mei|mei_voice_normal|三分経ちました.
    12  2   SYNTH_EVENT_STOP|mei      <eps>
    ("三分" means three minutes, 
    and "三分経ちました." is the Japanese sentence for "three minutes have elapsed".)

=== Japanese ========================================

音声対話スクリプト(.fst)では,通常の変数の他に,時間経過でカウントダウンされる「タイマー変数」を利用できます.TIMER_START コマンドによりタイマー変数に値をセットすると,その代入した秒数から0へ向かって0.1秒単位でカウントダウンが開始されます.値が 0 に達すると TIMER_EVENT_STOP イベントが発行されます.以下は 3 分待ってから「三分経ちました.」と喋る例です.

    1  11   RECOG_EVENT_STOP|三分     TIMER_START|timer|180.0
    11 12   TIMER_EVENT_STOP|timer   SYNTH_START|mei|mei_voice_normal|三分経ちました.
    12  2   SYNTH_EVENT_STOP|mei      <eps>

Random numbers

March 8, 2013

Random values can be set to a variable by specifying maximum and minimum values to the VALUE_SET command.  At execution time, one random number will be chosen inside the specified range and applied to the variable. The following is an example of a rock-paper-scissors game, where one out of the three options is outputted at a time with equal probability.

    1  11   RECOG_EVENT_STOP|じゃんけん      VALUE_SET|x|0|3
    11 12   VALUE_EVENT_SET|x              VALUE_EVAL|x|LE|1
    12 14   VALUE_EVENT_EVAL|x|LE|1|TRUE   SYNTH_START|mei|mei_voice_normal|グー
    12 13   VALUE_EVENT_EVAL|x|LE|1|FALSE  VALUE_EVAL|x|LE|2
    13 14   VALUE_EVENT_EVAL|x|LE|2|TRUE   SYNTH_START|mei|mei_voice_normal|チョキ
    13 14   VALUE_EVENT_EVAL|x|LE|2|FALSE  SYNTH_START|mei|mei_voice_normal|パー
    14  2   SYNTH_EVENT_STOP|mei           <eps>
    ("じゃんけん" means scissors-paper-stone, "グー" is for stone, 
     "チョキ" is for scissors and "パー" is for paper)

In this example, a random value between zero and three will be stored to the variable “x” .  These values are then evaluated by the VALUE_EVENT_EVAL command at each turn and the current value stored in the variable is outputted.

=== Japanese ========================================

音声対話スクリプト (.fst) では変数に乱数を代入することができます.乱数の利用の際には, VALUE_SET コマンドで最大値と最小値を指定します.なお,乱数の値は値を代入した際に固定され,参照・評価には同じ値が使われます.以下にじゃんけんを行う例を示します.

    1  11   RECOG_EVENT_STOP|じゃんけん      VALUE_SET|x|0|3
    11 12   VALUE_EVENT_SET|x              VALUE_EVAL|x|LE|1
    12 14   VALUE_EVENT_EVAL|x|LE|1|TRUE   SYNTH_START|mei|mei_voice_normal|グー
    12 13   VALUE_EVENT_EVAL|x|LE|1|FALSE  VALUE_EVAL|x|LE|2
    13 14   VALUE_EVENT_EVAL|x|LE|2|TRUE   SYNTH_START|mei|mei_voice_normal|チョキ
    13 14   VALUE_EVENT_EVAL|x|LE|2|FALSE  SYNTH_START|mei|mei_voice_normal|パー
    14  2   SYNTH_EVENT_STOP|mei           <eps>

この例では,まず変数 x に 0以上 3 以下の乱数を代入しています.そして, VALUE_EVAL コマンドにより変数に代入された値の評価を行うことで,x の値によってじゃんけんの手を出力します.