Ejemplo n.º 1
0
 private void Start()
 {
     voiceTrans    = transform.Find("/Game_UI/Fixed_UI/Voices/");
     micToggle     = voiceTrans.transform.Find("Mic").GetComponent <Toggle>();
     speakerToggle = voiceTrans.transform.Find("horn").GetComponent <Toggle>();
     txt           = voiceTrans.transform.Find("Text").GetComponent <Text>();
     m_roomName    = GameInfo.room_id + "";
     if (m_voiceengine == null)
     {
         txt.text     += "开始";
         m_voiceengine = GCloudVoice.GetEngine();
         txt.text     += "调用了,设置openid";
         m_voiceengine.SetAppInfo("1981614680", "829b1c3747cd948f6dad1e9b151692ef", GameInfo.OpenID);
         txt.text += "设置openID了,开始init";
         m_voiceengine.Init();
         txt.text += "init结束,设置实时语音";
         m_voiceengine.SetMode(GCloudVoiceMode.RealTime);
         txt.text += "设置实时语音";
     }
     micToggle.onValueChanged.AddListener(
         delegate(bool isOn)
     {
         OnMicToggleClick(isOn);
     }
         );
     speakerToggle.onValueChanged.AddListener(delegate(bool isOn) { OnSpeakerToggleClick(isOn); });
     JoinRoomBtn_Click();
 }
Ejemplo n.º 2
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     m_voiceengine = GCloudVoice.GetEngine();
 }
Ejemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            m_voiceengine = GCloudVoice.GetEngine();
            TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            string   strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();

            m_voiceengine.SetAppInfo(appId, appKey, strTime);
            int ccc = m_voiceengine.Init();
        }
Ejemplo n.º 4
0
 public void InitGVoice(string appID, string appKey, string openID, string udpUrl)
 {
     if (m_voiceengine == null)
     {
         m_voiceengine = GCloudVoice.GetEngine();
         m_voiceengine.SetAppInfo(appID, appKey, openID);
         m_voiceengine.SetServerInfo(udpUrl);
         m_voiceengine.Init();
     }
 }
Ejemplo n.º 5
0
    //初始化Team
    public int InitTeam(string gameId, string gameKey, string openId, int msTimeout, int type = 0)
    {
        mVoiceengine = GCloudVoice.GetEngine();
        mVoiceengine.SetAppInfo(gameId, gameKey, openId);
        int initResult = mVoiceengine.Init();

        mVoiceengine.ApplyMessageKey(msTimeout);
        mVoiceengine.SetMode((GCloudVoiceMode)type);

        return(initResult);
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     if (m_voiceengine == null)
     {
         m_voiceengine = GCloudVoice.GetEngine();
         System.TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
         string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();
         //m_voiceengine.SetAppInfo("932849489","d94749efe9fce61333121de84123ef9b",strTime);
         m_voiceengine.SetAppInfo("1902660741", "a45efbd6ba436c4c286a9989d49ba69a", strTime);
         m_voiceengine.Init();
     }
 }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     if (m_voiceengine == null)
     {
         m_voiceengine = GCloudVoice.GetEngine();
         System.TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
         string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();
         //m_voiceengine.SetAppInfo("932849489","d94749efe9fce61333121de84123ef9b",strTime);
         m_voiceengine.SetAppInfo("gcloud.test", "test_key", strTime);
         m_voiceengine.Init();
     }
 }
Ejemplo n.º 8
0
    //初始化语音
    public void Init(string gameId, string gameKey, string openId, int msTimeout)
    {
        if (mVoiceengine == null)
        {
            mVoiceengine = GCloudVoice.GetEngine();
        }
        mVoiceengine.SetAppInfo(gameId, gameKey, openId);
        mVoiceengine.Init();
        mVoiceengine.ApplyMessageKey(msTimeout);
        mVoiceengine.SetMode(GCloudVoiceMode.Messages);
        int ret1 = mVoiceengine.SetMaxMessageLength(60000);

        Debug.Log("SetMaxMessageLength ret==" + ret1);
    }
Ejemplo n.º 9
0
    public void Stop()
    {
        if (IsStarted)
        {
            IGCloudVoice engine = _Manager.Gcloud_VoiceMan.VoiceEngine;

            engine.OnApplyMessageKeyComplete    -= OnApplyMessageKeyComplete;
            engine.OnUploadReccordFileComplete  -= OnUploadReccordFileComplete;
            engine.OnDownloadRecordFileComplete -= OnDownloadRecordFileComplete;
            engine.OnPlayRecordFilComplete      -= PlayRecordFileComplete;

            IsStarted = false;
        }
    }
Ejemplo n.º 10
0
 void Start()
 {
     if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
     {
         Debug.Log("GVoiceManager 事件初始化");
         if (mVoiceengine == null)
         {
             mVoiceengine = GCloudVoice.GetEngine();
         }
         mVoiceengine.OnApplyMessageKeyComplete    += OnApplyMessageKeyComplete;
         mVoiceengine.OnUploadReccordFileComplete  += OnUploadReccordFileComplete;
         mVoiceengine.OnDownloadRecordFileComplete += OnDownloadRecordFileComplete;
         mVoiceengine.OnPlayRecordFilComplete      += OnPlayRecordFilComplete;
     }
 }
Ejemplo n.º 11
0
    void Start()
    {
        if (m_voiceengine == null)
        {
            m_voiceengine = GCloudVoice.GetEngine();
            TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            string   strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();
            // TODO: 这里用时间模拟了一个openId,在正式项目中应该把这里的strTime换成用户唯一ID
            m_voiceengine.SetAppInfo(appId, appKey, strTime);
            m_voiceengine.Init();

            // 注册SDK常用回调监听
            m_voiceengine.OnJoinRoomComplete += OnJoinRoom;
            m_voiceengine.OnQuitRoomComplete += OnExitRoom;
            m_voiceengine.OnMemberVoice      += OnMemberVoice;
        }
    }
Ejemplo n.º 12
0
    public void InitGvoice()
    {
        if (Application.platform == RuntimePlatform.OSXEditor)
        {
            //Debug.LogError("OSXEditor 不初始化:");
            return;
        }
        m_voiceengine = GCloudVoice.GetEngine();
        if (!System.IO.Directory.Exists(VoiceDataPath))
        {
            System.IO.Directory.CreateDirectory(VoiceDataPath);
        }

        Engine.JsonNode root = Engine.RareJson.ParseJsonFile(GVOICE_FILE);
        if (root == null)
        {
            Engine.Utility.Log.Error("GVoiceManger 解析{0}文件失败!", GVOICE_FILE);
            return;
        }
        m_strAppId  = root["appid"];
        m_strAppkey = root["appkey"];


        if (Application.platform == RuntimePlatform.Android)
        {
            // Debug.LogError("InitGvoice:");
            AndroidJavaClass jc = new AndroidJavaClass("com.hxll.gvoice.Gvoice");
            if (jc != null)
            {
                initRet = jc.CallStatic <int>("InitGVoiceEngine");
            }
            //Debug.LogError("InitGvoice ret :" + initRet);
        }

        m_voiceengine.OnApplyMessageKeyComplete    += OnApplyMessageKeyCompleteHandler;
        m_voiceengine.OnUploadReccordFileComplete  += OnUploadReccordFileCompleteHandler;
        m_voiceengine.OnDownloadRecordFileComplete += OnDownloadRecordFileCompleteHandler;
        m_voiceengine.OnPlayRecordFilComplete      += OnPlayRecordFilCompletehandler;
        m_voiceengine.OnSpeechToText += OnSpeechToTextHandler;

        m_voiceengine.OnJoinRoomComplete += OnJoinRoomCompleteHandler;
        m_voiceengine.OnQuitRoomComplete += OnQuitRoomComplete;
        m_voiceengine.OnMemberVoice      += OnMemberVoiceHandler;
    }
Ejemplo n.º 13
0
    public override void Init()
    {
        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
        {
            return;
        }
        m_voiceengine = GCloudVoice.GetEngine();
        m_voiceengine.OnApplyMessageKeyComplete    += onApplyMessageKeyComplete;
        m_voiceengine.OnUploadReccordFileComplete  += onUploadReccordFileComplete;
        m_voiceengine.OnDownloadRecordFileComplete += onDownloadReccordFileComplete;
        m_voiceengine.OnPlayRecordFilComplete      += onPlayRecordFilComplete;
        System.TimeSpan ts      = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
        string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();

        m_voiceengine.SetAppInfo("932849489", "d94749efe9fce61333121de84123ef9b", strTime);
        m_voiceengine.Init();
        m_voiceengine.SetMode(GCloudVoiceMode.Messages);
        base.Init();
    }
Ejemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     m_voiceengine         = GCloudVoice.GetEngine();
     _voicePlayerSwitch    = true;
     _fileIDDicUUid        = new Dictionary <string, string>();
     isCanPlayRecordedFile = true;
     isCanSay   = true;
     _fileIDArr = new ArrayList();
     EventDispatcher.GetInstance().MainEventManager.AddEventListener <ArrayList>(EventId.Server_Chat_msg, OnGetStr);
     // m_voiceengine.SetMode(GCloudVoiceMode.RealTime);
     if (!bIsStart)
     {
         bIsStart = true;
         m_voiceengine.OnUploadReccordFileComplete  += OnUploadReccordFileCompleteHandle;
         m_voiceengine.OnDownloadRecordFileComplete += OnDownloadRecordFileCompleteHandle;
         m_voiceengine.OnPlayRecordFilComplete      += OnPlayRecordFilCompleteHandle;
     }
     m_recordpath   = Application.persistentDataPath + "/" + "recording.dat";
     m_downloadpath = Application.persistentDataPath + "/" + "download.dat";
 }
Ejemplo n.º 15
0
    public bool Start()
    {
        if (!IsStarted)
        {
            IGCloudVoice engine = _Manager.Gcloud_VoiceMan.VoiceEngine;

            engine.OnApplyMessageKeyComplete    += OnApplyMessageKeyComplete;
            engine.OnUploadReccordFileComplete  += OnUploadReccordFileComplete;
            engine.OnDownloadRecordFileComplete += OnDownloadRecordFileComplete;
            engine.OnPlayRecordFilComplete      += PlayRecordFileComplete;

            if (!_bIsGetAuthKey)
            {
                engine.ApplyMessageKey(15000);
            }

            IsStarted = true;
        }

        return(IsStarted);
    }
Ejemplo n.º 16
0
        public void Init(string appId, string appKey)
        {
            if (VoiceState.UnInited != State)
            {
                return;
            }
            if (m_voiceengine == null)
            {
                m_voiceengine = GCloudVoice.GetEngine();
                System.TimeSpan ts      = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();


                m_voiceengine.SetAppInfo(appId, appKey, strTime);
                Debug.Log("GVoiceManager appId={0}" + appId + "\nappKey=" + appKey);
                m_voiceengine.Init();
            }

            m_voiceengine.OnJoinRoomComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string roomName, int memberID) =>
            {
                Debug.Log("OnJoinRoomComplete ret=" + code + " roomName:" + roomName + " memberID:" + memberID);
                if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_JOINROOM_SUCC)
                {
                    State = VoiceState.InRoom;

                    RoomName = roomName;
                    if (IsAnchor)
                    {
                        m_voiceengine.OpenMic();
                    }

                    m_voiceengine.OpenSpeaker();

                    EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(301038));

                    SoundManager.Instance.VoicePlaying = true;
                }
                else
                {
                    State = VoiceState.Inited;
                    EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(GameUtils.GetDictionaryText(301038) + GameUtils.GetDictionaryText(1033)));
                }
            };
            //}
            m_voiceengine.OnQuitRoomComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string roomName, int memberID) =>
            {
                Debug.Log("OnQuitRoomComplete ret=" + code + " roomName:" + roomName + " memberID:" + memberID);
                //UIManager.m_Instance.OnJoinRoomDone(code);

                if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_QUITROOM_SUCC)
                {
                    State = VoiceState.Inited;
                    //SoundManager.Instance.SetBgmPause(false);

                    SoundManager.Instance.VoicePlaying = false;

                    EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(301039));
                    RoomName = "";
                }
                else
                {
                    EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(GameUtils.GetDictionaryText(301039) + GameUtils.GetDictionaryText(1033)));
                }
            };

            m_voiceengine.OnMemberVoice += (int[] members, int count) =>
            {
                //PrintLog ("OnMemberVoice");
                //s_logstr +="\r\ncount:"+count;
                //          for (int i = 0; i < count && (i + 1) < members.Length; ++i)
                //          {
                //              Debug.Log("OnMemberVoice " + members[i]);
                //              ++i;
                //          }
                //UIManager.m_Instance.UpdateMemberState(members, length, usingCount);
            };

            State = VoiceState.Inited;
            Debug.Log("GVoiceManager.Init----------------ok");
        }
Ejemplo n.º 17
0
    void Awake()
    {
        if (m_voiceengine == null && Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            m_voiceengine = GCloudVoice.GetEngine();
            System.TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();
            //m_voiceengine.SetAppInfo("932849489","d94749efe9fce61333121de84123ef9b",strTime);
            var info = m_voiceengine.SetAppInfo("1753605946", "445aec6d7d557ace513bc45ec3adc77e", strTime);
            m_voiceengine.SetServerInfo("udp://cn.voice.gcloudcs.com:10001");

            m_voiceengine.Init();
            m_voiceengine.SetMode(GCloudVoiceMode.Messages);
            m_voiceengine.OnApplyMessageKeyComplete += (IGCloudVoice.GCloudVoiceCompleteCode code) =>
            {
                PlayLog("OnApplyMessageKeyComplete c# callback");
                if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_MESSAGE_KEY_APPLIED_SUCC)
                {
                    PlayLog("OnApplyMessageKeyComplete succ11");
                }
                else
                {
                    PlayLog("OnApplyMessageKeyComplete error");
                }
            };
            m_voiceengine.OnUploadReccordFileComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid) =>
            {
                PlayLog("OnUploadReccordFileComplete c# callback");
                if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_UPLOAD_RECORD_DONE)
                {
                    m_fileid = fileid;
                    if (upLoadScuccessCall != null)
                    {
                        upLoadScuccessCall(m_fileid);
                    }
                    //UserTalk talk = new UserTalk();
                    //talk.type = 2;
                    //talk.msg = m_fileid;
                    //talk.subtype = 1;
                    //SocketClient.Instance.AddSendMessageQueue(new C2GMessage
                    //{
                    //    msgid = MessageId.C2G_UserTalk,
                    //    UserTalk = talk

                    //});
                    PlayLog("发送语音消息");
                    PlayLog("OnUploadReccordFileComplete succ, filepath:" + filepath + " fileid len=" + fileid.Length + " fileid:" + fileid + " fileid len=" + fileid.Length);
                }
                else
                {
                    PlayLog("OnUploadReccordFileComplete error");
                }
            };
            m_voiceengine.OnDownloadRecordFileComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid) =>
            {
                PlayLog("OnDownloadRecordFileComplete c# callback");
                if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_DOWNLOAD_RECORD_DONE)
                {
                    PlayLog("OnDownloadRecordFileComplete succ, filepath:" + filepath + " fileid:" + fileid);
                    if (downCall != null)
                    {
                        downCall();
                        downCall = null;
                    }
                    Click_btnPlayReocrdFile();
                }
                else
                {
                    PlayLog("OnDownloadRecordFileComplete error");
                }
            };
            m_voiceengine.OnPlayRecordFilComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string filepath) =>
            {
                PlayLog("OnPlayRecordFilComplete c# callback");
                if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_PLAYFILE_DONE)
                {
                    PlayLog("OnPlayRecordFilComplete succ, filepath:" + filepath);
                    if (playCall != null)
                    {
                        playCall();
                        playCall = null;
                    }
                }
                else
                {
                    PlayLog("OnPlayRecordFilComplete error");
                }
            };
        }
        m_recordpath   = Application.persistentDataPath + "/" + "recording.dat";
        m_downloadpath = Application.persistentDataPath + "/" + "download.dat";
    }
Ejemplo n.º 18
0
        public void Init()
        {
            if (!mIsStart)
            {
                mIsStart = true;

                try
                {
                    mVoiceEngine = GCloudVoice.GetEngine();
                }
                catch (Exception e)
                {
                    GameDebug.Log(e.Message);
                    return;
                }

                System.TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();
#if !TEST_HOST && !CMPT_RELEASE
                if (Const.Region == RegionType.CHINA)
                {
                    mVoiceEngine.SetAppInfo("1075242022", "b24dbcfef34b73475b81f47df5edc172", strTime);
                    mVoiceEngine.SetServerInfo("udp://cn.voice.gcloudcs.com:10001");
                }
                else if (Const.Region == RegionType.HKTW)
                {
                    mVoiceEngine.SetAppInfo("1529889908", "f4655f1fb599ef6b9ac2fe52e49c9ef2", strTime);
                    mVoiceEngine.SetServerInfo("udp://hk.voice.gcloudcs.com:10013");
                }
                else if (Const.Region == RegionType.KOREA)
                {
                    mVoiceEngine.SetAppInfo("1614396342", "3fc91371164d69fdb3c9bfc911aec845", strTime);
                    mVoiceEngine.SetServerInfo("udp://kr.voice.gcloudcs.com:8700");
                }
                else if (Const.Region == RegionType.SEASIA)
                {
                    mVoiceEngine.SetAppInfo("1338975937", "e293bba813c9d4782b67695da54c75af", strTime);
                    mVoiceEngine.SetServerInfo("udp://sg.voice.gcloudcs.com:8700");
                }
#else
                mVoiceEngine.SetAppInfo("gcloud.test", "test_key", strTime);
#endif
                mVoiceEngine.Init();
                int setModedRet = mVoiceEngine.SetMode(GCloudVoiceMode.Translation);
                GameDebug.Log("setModedRet =" + setModedRet);
                mVoiceEngine.EnableLog(true);
                mVoiceEngine.OnApplyMessageKeyComplete += (IGCloudVoice.GCloudVoiceCompleteCode code) =>
                {
                    //Debug.LogError("OnApplyMessageKeyComplete c# callback code = " + code);
                    if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_MESSAGE_KEY_APPLIED_SUCC)
                    {
                        //GameDebug.Log("OnApplyMessageKeyComplete succ");
                    }
                    else
                    {
                        //GameDebug.Log("OnApplyMessageKeyComplete error");
                        VoiceManager.Instance.ReqAuthKey();
                    }
                };
                mVoiceEngine.OnUploadReccordFileComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid) =>
                {
                    //Debug.LogError("OnUploadReccordFileComplete c# callback");
                    if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_UPLOAD_RECORD_DONE)
                    {
                        //Debug.LogError("OnUploadReccordFileComplete succ, filepath:" + filepath + " fileid len=" + fileid.Length + " fileid:" + fileid + " fileid len=" + fileid.Length);

                        FileInfo file_info = new FileInfo(filepath);
                        var      path      = GenFilePathByFileId(fileid);
                        if (!File.Exists(path))
                        {
                            file_info.CopyTo(path);
                        }

                        mUploadReccordFileId = fileid;
                        if (Const.Region == RegionType.CHINA)
                        {
                            VoiceManager.Instance.SpeechToText(fileid);
                        }
                        else
                        {
                            uint second = VoiceManager.Instance.GetRecFileSecond(fileid);
                            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_GVOICE_SPEECH_TO_TEXT_COMPLETE, new CEventGVoiceArgs(fileid, "", second));
                            IsUnloading = false;
                        }
                    }
                    else
                    {
                        IsUnloading = false;
                        Debug.LogError("OnUploadReccordFileComplete error");
                    }
                };
                mVoiceEngine.OnDownloadRecordFileComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid) =>
                {
                    //Debug.LogError("OnDownloadRecordFileComplete c# callback");
                    if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_DOWNLOAD_RECORD_DONE)
                    {
                        //Debug.LogError("OnDownloadRecordFileComplete succ, filepath:" + filepath + " fileid:" + fileid);

                        FileInfo file_info = new FileInfo(filepath);
                        var      path      = GenFilePathByFileId(fileid);
                        if (!File.Exists(path))
                        {
                            file_info.CopyTo(path);
                        }

                        OnlyPlayRecordFile(fileid);
                    }
                    else
                    {
                        Debug.LogError("OnDownloadRecordFileComplete error");
                    }
                };
                mVoiceEngine.OnPlayRecordFilComplete += (IGCloudVoice.GCloudVoiceCompleteCode code, string filepath) =>
                {
                    //Debug.LogError("OnPlayRecordFilComplete c# callback");
                    string file_id;
                    if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_PLAYFILE_DONE && VoiceManager.Instance.FilePathToFileId.TryGetValue(filepath, out file_id))
                    {
                    }
                    else
                    {
                        Debug.LogError("OnPlayRecordFilComplete error");
                    }

                    if (mPlayingFileQueue.Count > 0)
                    {
                        ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_GVOICE_RECORD_PLAY_DONE, new CEventGVoiceArgs(mPlayingFileQueue[0], "", 0));
                        mPlayingFileQueue.RemoveAt(0);
                    }

                    if (mPlayingFileQueue.Count == 0) // 最后一个播放完毕才重新播放背景音乐
                    {
                        AudioManager.Instance.SetMusicVolume(GlobalSettings.Instance.MusicVolume);
                        AudioManager.Instance.SetSFXVolume(GlobalSettings.Instance.SFXVolume);
                    }
                    else
                    {
                        PlayOrDownload(mPlayingFileQueue[0]);
                    }
                };
                mVoiceEngine.OnSpeechToText += (IGCloudVoice.GCloudVoiceCompleteCode code, string fileID, string result) =>
                {
                    //Debug.LogError("OnSpeechToText c# callback");
                    if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_STT_SUCC)
                    {
                        //Debug.LogError("OnSpeechToText succ, result:" + result);
                        uint second = VoiceManager.Instance.GetRecFileSecond(fileID);
                        ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_GVOICE_SPEECH_TO_TEXT_COMPLETE, new CEventGVoiceArgs(fileID, result, second));
                    }
                    else if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_STT_TIMEOUT)
                    {
                        Debug.LogError("OnSpeechToText error," + code);

                        if (mUploadReccordFileId.Length > 0)
                        {
                            uint second = VoiceManager.Instance.GetRecFileSecond(mUploadReccordFileId);
                            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_GVOICE_SPEECH_TO_TEXT_COMPLETE, new CEventGVoiceArgs(mUploadReccordFileId, result, second));
                        }
                    }
                    else
                    {
                        Debug.LogError("OnSpeechToText error," + code);

                        Init();//重现初始化,尝试清除上一次翻译失败
                    }
                    IsUnloading = false;
                };
                if (Directory.Exists(mSaveDir))
                {
                    Directory.Delete(mSaveDir, true);
                }

                Directory.CreateDirectory(mSaveDir);

                mRecordPath   = mSaveDir + "/recording.dat";
                mDownloadPath = mSaveDir + "/download.dat";
            }

            IsUnloading          = false;
            IsCanSendByGameLogic = false;
            mStartUploadingTime  = 0;
            mUploadReccordFileId = "";
            mPlayingFileQueue.Clear();

            VoiceManager.Instance.ReqAuthKey();
        }