Unity角色不响应IBM Watson语音到文本语音命令

时间:2018-08-04 16:58:08

标签: unity3d speech-to-text ibm-watson

我实现了IBM Watson的“语音转文本”,因此当我说“跳转” /“愤怒”时,我的角色将播放特定的音频剪辑。一切似乎都正常,但是我的角色对我的语音命令没有反应。 我的CharacterController.cs

   using UnityEngine;

    public class CharacterController : MonoBehaviour
    {

        // Use this for initialization

        public Animator anim;

        public AudioSource[] _audio;

        void Start()
        {       
        }

        // Update is called once per frame
        void Update()
        {      
            anim = GetComponent<Animator>();
            _audio = GetComponents<AudioSource>();
        }

        public void CharacterActions(string ActionCommands)
        {
            ActionCommands = ActionCommands.Trim();
            switch (ActionCommands)
            {
                case "jump":
                    anim.Play("jump", -1, 0f);
                    _audio[0].Play();
                    break;
                case "anger":
                    anim.Play("rage", -1, 0f);
                    _audio[1].Play();
                    break;

                default:
                    anim.Play("idle", -1, 0f);
                    break;

            }
        }
    }

0 个答案:

没有答案