#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- Python -*-
## @Rh2Voice_ctrl

import sys
import time
import os

sys.path.append("..")
from set_env import *  

sys.path.append(".")
save_path = sys.path[:]
#sys.path.append(RtmToolsDir+'/rtc_handle')
sys.path.append(Rh2LibDir)
from rtc_handle import *
sys.path = save_path

from message import *

# import stub files
sys.path.append(Rh2IdlDir)
import _GlobalIDL

##
#
def assign_variables(env) :
  global sound, openjtalk, pulseaudiooutput
  openjtalk = env.name_space[Rh2VoiceNS].rtc_handles['OpenJTalkRTC0.rtc']
  pulseaudiooutput = env.name_space[Rh2VoiceNS].rtc_handles['PulseAudioOutput0.rtc']
  sound  = env.name_space[Rh2VoiceNS].rtc_handles['SoundPlayer0.rtc']
  sound.services['PlaySoundProv'].provided['PlaySound'].narrow_ref(globals())


##
#
def activate() :
  sound.activate()
  openjtalk.activate()
  pulseaudiooutput.activate()

##
#
def deactivate() :
  sound.deactivate()
  openjtalk.deactivate()
  pulseaudiooutput.deactivate()

##
#
def talk(sentence) :
  openjtalk.inports['text'].write(sentence)

##
#
def beep() :
  sound.services['PlaySoundProv'].provided['PlaySound'].ref.play()

##
# initialization when this is imported.
#env = RtmEnv(sys.argv,[Rh2VoiceNS])
#for ns in env.name_space :
#  env.name_space[Rh2VoiceNS].list_obj()
#assign_variables(env)
