private void Start()
 {
     _allSearch         = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/InsertAllPath/InputAllPath").GetComponent <AllSearch>();
     _currentSearch     = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/InsertCurrentPath/InputCurrentPath").GetComponent <CurrentSearch>();
     _scrollRect        = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/Scroll View").GetComponent <ScrollRect>();
     _startDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
 }
Ejemplo n.º 2
0
    public void MoveVoiceFile(string path, string title)
    {
        StartDBController _sd = _startDBController;
        DirectoryInfo     dir = new DirectoryInfo(path);

        /* 생성되는 파일을 옮길 경로 및 이름 표기 */
        string loadDir  = dir_path + "/Resources/Voice";
        string modelDir = null;

        foreach (FileInfo file in dir.GetFiles())
        {
            /* 메타 파일이 생성됬을 때 지우도록! */
            DeleteFile(path, file.Name, ".meta");

            /* 생성된 음성 파일 -> 각 모델 디렉토리 이동 */
            if (file.Extension.ToLower().CompareTo(".wav") == 0)
            {
                // 여기 수정
                if (_sd._now > 0 && modelDir == null)
                {
                    modelDir = _sd.directoryPath[_sd._now].Substring(1, _sd.directoryPath[_sd._now].Length - 1);
                    loadDir += modelDir + "/" + title + ".wav";
                }

                /* 같은 이름을 가진 파일이 있으면, 덮어 씌우도록 설정. */
                if (ExistSameNameFile(loadDir))
                {
                    file.CopyTo(@loadDir, true);
                    file.Delete();
                    /* 유니티 Slot에도 덮어 씌울 수 있도록 코드 수정 필요 */
                }
                else // 새 파일 생성 시 버튼도 같이 생성!
                {
                    file.MoveTo(loadDir);
                    string   tmp       = file.LastWriteTime.ToString();
                    string[] lastWrite = tmp.Split(' ');

#if UNITY_EDITOR
                    /* 동적으로 폴더에 있는 데이터 임포트! -> 유니티 상에서 바로 사용 할 수 있도록
                     * 에디터 모드에만 적용되는 소스를 전처리기 적용 우회시켜 빌드 모드에서도 적용할 수 있도록 설정!
                     */
                    ImportAsset.NewImportAsset_Dic("Assets/Resources/Voice" + modelDir);
#endif
                    // 여기 수정
                    /* 음성 Slot을 만들어준다. */
                    StartCoroutine(_startDBController.CreateFile(title, ".wav", lastWrite[0]));
                }
                //
            }

            //냅두고
            /* 생성된 그래프 파일 -> 삭제 */
            else if (file.Extension.ToLower().CompareTo(".png") == 0)
            {
                file.Delete(); // 파일 삭제
            }
        }//foreach
    }
    /**
     * @date : 2019.11.11
     * @author : Day
     * @desc : TotalTable.sqlite 는 모든 DB파일의
     *         이름과 실행횟수 시나리오번호를 저장.
     **/
    /*
     * HiddenMenu Start(코루틴)에서만 시작
     */
    public override void TotalStart(string sql)
    {
        try
        {
            Open();

            using (IDbCommand cmd = connection.CreateCommand())
            {
                List <string> tmp = new List <string>();

                cmd.CommandText = sql;
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string sfile  = reader.GetString(0);
                        int    key    = reader.GetInt32(1);
                        int    played = reader.GetInt32(2);
                        string time   = reader.GetString(3);

                        tmp.Add(sfile);
                        if (!keyDic.ContainsKey(sfile))
                        {
                            keyDic.Add(sfile, key);
                        }
                        if (!playedDic.ContainsKey(sfile))
                        {
                            playedDic.Add(sfile, played);
                        }
                        if (!timeDic.ContainsKey(sfile))
                        {
                            timeDic.Add(sfile, time);
                        }
                    }
                }

                /*
                 * temp ==> 파일 이름
                 * playedDic ==> 실행횟수
                 * keyDic ==> 시나리오번호
                 */
                _StartDBController              = GameObject.Find("StartDBController").GetComponent <StartDBController>();
                _StartDBController.playedDic    = playedDic;
                _StartDBController.keyDic       = keyDic;
                _StartDBController.timeDic      = timeDic;
                _StartDBController.saveFileName = tmp;
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
        }

        Close();
    }
Ejemplo n.º 4
0
    /* 외부 프로세서를 이용해 동적으로 문장 만들어주는 함수. */
    public void MakingVoice()
    {
        if (_isMakingVoice) // 만들고 있을 때 누름 -> 취소해야 된다
        {
            CancelClick();
            return;
        }

        UnityEngine.Debug.Log(_title.text);

        StartDBController _sd     = _startDBController;
        string            dirPath = _sd.directoryPath[_sd._now].Substring(1, _sd.directoryPath[_sd._now].Length - 1);
        string            model   = dirPath.Contains("Woman") || dirPath.Contains("woman") ? "yuinna" : "son";

        /* 현재 존재하는 파일 갯수를 가져온다. */
        _countFiles = getCountFiles();

        /* 만들 텍스트를 입력하여 python 코드를 실행. -> 동적으로 생성됨. */
        cmd.StartInfo.Arguments = "/K python synthesizer.py --load_path logs/" + model + " --text \"" + _sentence.text + "\"";
        //cmd.StartInfo.Arguments = "/K dir";

        /* try-catch 문으로 잡아준 이유 : 최초 cmd 만들어 줄 시 해당 if 문이 아닌 오류에 걸리는 현상 발생! */
        try
        {
            /* cmd가 있을시! */
            if (!cmd.HasExited)
            {
                //UnityEngine.Debug.Log("음성 파일 생성중이니 조금만 기다려 주세요!");
            }
            /* cmd가 없을시! (2번째 음성 합성 이후 여기 걸림) */
            else
            {
                cmd.Start();
                _isMakingVoice = true;
            }
        }
        catch (System.Exception e)
        {
            /* 최초 cmd 생성 할때, 해당 구문에 걸린다! */
            cmd.Start();
            _isMakingVoice = true;
        }

        /* 음성합성이 끝나면, 텍스트 내용 초기화! */
        title_str      = _title.text;
        _sentence.text = "";
        _title.text    = "";

        /* Cancel <-> Make 버튼이 바뀌어야 한다! */
        ChangeButton();
    }
    public override void VoiceFile_Start(string sql)
    {
        try
        {
            Open();

            using (IDbCommand cmd = connection.CreateCommand())
            {
                List <string> tmp = new List <string>();

                cmd.CommandText = sql;
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string f    = reader.GetString(0);
                        int    key  = reader.GetInt32(1);
                        string time = reader.GetString(2);

                        tmp.Add(f);

                        if (!fileInfo.ContainsKey(key))
                        {
                            fileInfo[key] = new List <string>();
                        }
                        fileInfo[key].Add(f);
                        if (!fileTime.ContainsKey(key))
                        {
                            Dictionary <string, string> ss = new Dictionary <string, string>();
                            fileTime.Add(key, ss);
                        }
                        if (!fileTime[key].ContainsKey(f))
                        {
                            fileTime[key].Add(f, time);
                        }
                    }
                }

                _StartDBController          = GameObject.Find("StartDBController").GetComponent <StartDBController>();
                _StartDBController.fileInfo = fileInfo;
                _StartDBController.fileTime = fileTime;
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
        }

        Close();
    }
Ejemplo n.º 6
0
    void Start()
    {
        _startDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
        _dirPath           = Static.STATIC.dir_path + "/DeepLeaning/samples";

        /* 현재 폴더에 존재하는 파일 갯수를 구한다. */
        _countFiles = getCountFiles();

        /* 외부 프로세서 실행시 보이지 않도록 설정. */
        //cmd.StartInfo.CreateNoWindow = true;
        //cmd.StartInfo.UseShellExecute = false;

        /* 외부프로세서 (cmd)를 지정하며, 하위 디렉토리를 설정한다. */
        cmd.StartInfo.FileName         = "cmd.exe";
        cmd.StartInfo.WorkingDirectory = Static.STATIC.dir_path + "/DeepLeaning";
        UnityEngine.Debug.Log(cmd.StartInfo.WorkingDirectory);
    }
    public override void VoiceAudio_Start(string sql)
    {
        try
        {
            Open();

            using (IDbCommand cmd = connection.CreateCommand())
            {
                List <string> tmp = new List <string>();

                cmd.CommandText = sql;
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string f   = reader.GetString(0);
                        int    key = reader.GetInt32(1);
                        string p   = reader.GetString(2);

                        AudioClip tmp_audio = Resources.Load <AudioClip>(p + f);
                        if (!audioInfo.ContainsKey(key))
                        {
                            Dictionary <string, AudioClip> sa = new Dictionary <string, AudioClip>();
                            audioInfo.Add(key, sa);
                        }
                        if (!audioInfo[key].ContainsKey(f))
                        {
                            audioInfo[key].Add(f, tmp_audio);
                        }
                    }
                }

                _StartDBController           = GameObject.Find("StartDBController").GetComponent <StartDBController>();
                _StartDBController.audioInfo = audioInfo;
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
        }

        Close();
    }
Ejemplo n.º 8
0
 private void Start()
 {
     _scrollRect          = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/Scroll View").GetComponent <ScrollRect>();
     _cameraMoveAroundSwi = Static.STATIC.cameraMoveAroun;
     _startDBController   = GameObject.Find("StartDBController").GetComponent <StartDBController>();
 }
    public void OnClickCreateDirectory()
    {
        Debug.Log("여긴 되나?");
        string _dir_name = _createField.text;

        if (_dir_name == "")
        {
            _createButton.gameObject.SetActive(true);
            _createField.gameObject.SetActive(false);
            _createField.text = "";
            return;
        }
        _dir_name = _createField.text;
        StartDBController _sd = _startDBController;

        if (_sd.directoryString.ContainsKey(_dir_name))
        {
            Debug.Log("여기서 막히나?");
            // 이미 이 이름의 디렉토리가 있어서 빠꾸쳐야함
            return;
        }

        /*
         * Directory 버튼 생성 부분인데 이거 솔직히 idx를 내가 직접 insert 해준다해도 prev_idx하고 다 찾아야하는데 난 자신없어서 냄겨둡니다.
         */
        //int _idx = _sd.directoryString[_createField.text];
        //int _prev_idx = _sd.directoryPoint[_idx];
        //Transform _parent = _sd.contentInfo[_prev_idx];
        //GameObject _tmp_btn = Instantiate(_startDBController._directorySampleBtn) as GameObject;
        //_tmp_btn.name = _dir_name;
        //_tmp_btn.transform.SetParent(_parent);
        //_tmp_btn.transform.GetChild(0).GetComponent<Text>().text = _dir_name;
        //_tmp_btn.transform.GetChild(2).GetComponent<Text>().text = _sd.directoryTime[_idx][_dir_name];
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._key = _idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._prev_key = _prev_idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._change_btn = false;
        //_tmp_btn.SetActive(true);
        //_tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        //string _lower = _dir_name.ToLower();
        //if (!_sd._currentSearch._fileTable.ContainsKey(_prev_idx))
        //{
        //    Dictionary<string, GameObject> sg = new Dictionary<string, GameObject>();
        //    _sd._currentSearch._fileTable.Add(_prev_idx, sg);
        //}
        //if (!_sd._currentSearch._fileTable[_prev_idx].ContainsKey(_lower))
        //{
        //    _tmp_btn = Instantiate(_sd._directorySampleBtn) as GameObject;
        //    _tmp_btn.name = _lower;
        //    _tmp_btn.transform.SetParent(_sd._current_content);
        //    _tmp_btn.transform.GetChild(0).GetComponent<Text>().text = _dir_name;
        //    _tmp_btn.transform.GetChild(2).GetComponent<Text>().text = _sd.directoryTime[_idx][_dir_name];
        //    _tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._key = _idx;
        //    _tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._prev_key = _prev_idx;
        //    _tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._change_btn = false;
        //    _tmp_btn.SetActive(false);
        //    _tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        //    _sd._currentSearch._fileTable[_prev_idx].Add(_lower, _tmp_btn);
        //}
        //if (!_sd._allSearch._fileTable.ContainsKey(_lower))
        //{
        //    _sd._allSearch._fileTable[_lower] = new List<GameObject>();
        //}
        //_tmp_btn = Instantiate(_sd._directorySampleBtn) as GameObject;
        //_tmp_btn.name = _lower;
        //_tmp_btn.transform.SetParent(_sd._all_content);
        //_tmp_btn.transform.GetChild(0).GetComponent<Text>().text = _dir_name;
        //_tmp_btn.transform.GetChild(2).GetComponent<Text>().text = _sd.directoryTime[_idx][_dir_name];
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._key = _idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._prev_key = _prev_idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._change_btn = false;
        //_tmp_btn.SetActive(false);
        //_tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        //_sd._allSearch._fileTable[_lower].Add(_tmp_btn);

        string _voiceDirectoryCreatePath;

        if (_sd._now > 0)
        {
            _voiceDirectoryCreatePath = _sd.directoryPath[_sd._now].Substring(1, _sd.directoryPath[_sd._now].Length - 1);
        }
        else
        {
            _voiceDirectoryCreatePath = "";
        }

        string _folderPath = @"" + Static.STATIC.dir_path + "/Resources/Voice" + _voiceDirectoryCreatePath + "/" + _dir_name;

        Directory.CreateDirectory(_folderPath);
        Debug.Log(_folderPath);
#if UNITY_EDITOR
        ImportAsset.NewImportAsset_File("Assets/Resources/Voice" + _voiceDirectoryCreatePath + "/" + _dir_name);
#endif

        //버튼, 컨텐츠 생성
        StartCoroutine(_sd.CreateDirectory(_voiceDirectoryCreatePath, _dir_name));

        _createButton.gameObject.SetActive(true);
        _createField.gameObject.SetActive(false);
        _createField.text = "";
    }
 private void Start()
 {
     _startDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
 }
 private void Start()
 {
     _startDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
     _scrollRect        = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/Scroll View").GetComponent <ScrollRect>();
 }
Ejemplo n.º 12
0
 private void Start()
 {
     dir_path           = Static.STATIC.dir_path;
     _startDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
 }
    public override void VoiceDirectory_Start(string sql)
    {
        try
        {
            Open();

            using (IDbCommand cmd = connection.CreateCommand())
            {
                List <string> tmp = new List <string>();

                cmd.CommandText = sql;
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string dir      = reader.GetString(0);
                        int    key      = reader.GetInt32(1);
                        int    prev_key = reader.GetInt32(2);
                        string time     = reader.GetString(3);

                        tmp.Add(dir);
                        if (!directoryString.ContainsKey(dir))
                        {
                            directoryString.Add(dir, key);
                        }
                        if (!directoryInteger.ContainsKey(key))
                        {
                            directoryInteger.Add(key, dir);
                            idxInfo.Add(key);
                        }
                        if (!directoryPoint.ContainsKey(key))
                        {
                            directoryPoint.Add(key, prev_key);
                        }
                        if (!directoryTime.ContainsKey(key))
                        {
                            Dictionary <string, string> ss = new Dictionary <string, string>();
                            directoryTime.Add(key, ss);
                        }
                        if (!directoryTime[key].ContainsKey(dir))
                        {
                            directoryTime[key].Add(dir, time);
                        }
                        if (prev_key == 0 && key == 0)
                        {
                            continue;
                        }
                        if (!directoryPathIdx.ContainsKey(prev_key))
                        {
                            directoryPathIdx.Add(prev_key, new List <int>());
                        }
                        //if (!directoryPathIdx.ContainsKey(key))
                        //{
                        //    directoryPathIdx.Add(key, new List<int>());
                        //}
                        directoryPathIdx[prev_key].Add(key);
                    }
                }

                _StartDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
                _StartDBController.directoryString  = directoryString;
                _StartDBController.directoryInteger = directoryInteger;
                _StartDBController.directoryPoint   = directoryPoint;
                _StartDBController.directoryTime    = directoryTime;
                _StartDBController.directoryName    = tmp;
                _StartDBController.idxInfo          = idxInfo;
                _StartDBController.directoryPathIdx = directoryPathIdx;
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
        }

        Close();
    }