/// <summary> Download and save at path clips in wav format. </summary>
 private static void DownloadWavFiles(string path, ResembleClip[] clips)
 {
     path = Utils.LocalPath(path);
     for (int i = 0; i < clips.Length; i++)
     {
         string filePath = path + "/" + clips[i].title + ".wav";
         AsyncRequest.Make(clips[i].link, filePath);
     }
     Resemble_Window.Open(Resemble_Window.Tab.Pool);
     AsyncRequest.RegisterRefreshEvent();
 }
Beispiel #2
0
        /// <summary> Create clip data and send the request. </summary>
        private void Generate()
        {
            string path = EditorUtility.SaveFilePanel("Save OneShot clip", savePath, "", "wav");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            savePath = Path.GetDirectoryName(path);
            AsyncRequest.Make(text.BuildResembleString(), voiceUUID, path);
            string name = Path.GetFileName(path);

            name = name.Remove(name.Length - 4);
            NotificationsPopup.Add("OneShot request send : " + name, MessageType.Info, null);
            text.SelectAll();
            text.Delete();
        }
        private void DrawTextArea()
        {
            //Tags buttons
            drawer.DrawTagsBtnsLayout(false);

            //Separator
            Rect rect = GUILayoutUtility.GetRect(1.0f, 1.0f, GUILayout.ExpandWidth(true));

            rect.Set(rect.x, rect.y, rect.width, 1.0f);
            EditorGUI.DrawRect(rect, Color.grey * 0.2f);

            //Draw text field
            drawer.DoLayout(true, false);

            //Draw character count bar
            rect = GUILayoutUtility.GetRect(Screen.width, 25).Shrink(10);
            rect.Set(rect.x, rect.y - 10, rect.width, rect.height + 10);
            drawer.DrawCharCountBar(rect);

            //Draw bottom text buttons
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (request == null)
            {
                EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(clip.text.userString));
                if (GUILayout.Button("Generate Audio"))
                {
                    request       = AsyncRequest.Make(clip);
                    clip.phonemes = null;
                }
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                if (GUILayout.Button("Select parent"))
                {
                    Selection.activeObject = clip.speech;
                }
            }

            GUILayout.EndHorizontal();
        }
        protected override void OnHeaderGUI()
        {
            //Init resources
            InitComponents();

            //Bar
            Rect rect = new Rect(0, 0, Screen.width, 46);

            GUI.Box(rect, "", Styles.bigTitle);

            //Icon
            rect.Set(6, 6, 32, 32);
            GUI.DrawTexture(rect, Resources.instance.icon);

            //Speech name and shorcut
            float width = Styles.header.CalcSize(new GUIContent(clip.speech.name + " > ")).x;

            rect.Set(44, 4, width, 22);
            if (GUI.Button(rect, clip.speech.name + " > ", Styles.header))
            {
                Selection.activeObject = clip.speech;
            }
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

            //Clip name and rename
            rect.Set(rect.x + rect.width, rect.y, Screen.width - (rect.x + rect.width + 50), rect.height);
            renameRect = rect;
            if (GUI.Button(rect, clip.clipName, Styles.header))
            {
                Rename();
            }
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

            //Resemble.ai link
            rect.Set(Screen.width - 140, rect.y + 24, 135, 16);
            if (GUI.Button(rect, "Show in Resemble.ai", EditorStyles.linkLabel))
            {
                WebPage.ResembleProjects.Open(Settings.projectUUID + "/clips/" + clip.uuid);
            }
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

            //Help button
            rect.Set(Screen.width - 37, 6, 16, 16);
            if (GUI.Button(rect, Styles.characterSetHelpBtn, GUIStyle.none))
            {
                WebPage.PluginDoc.Open();
            }

            //Options button
            rect.x += 18;
            if (GUI.Button(rect, Styles.popupBtn, GUIStyle.none))
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Update from API"), false, UpdateFromAPI);
                menu.AddItem(new GUIContent("Generate Audio"), false, () => { request = AsyncRequest.Make(clip); });
                menu.AddItem(new GUIContent("Download wav as..."), false, ExportClip);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Rename"), false, Rename);
                menu.AddItem(new GUIContent("Delete"), false, Delete);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Help"), false, () => { WebPage.PluginClip.Open(); });
                menu.AddItem(new GUIContent("Settings"), false, Settings.OpenWindow);
                menu.DropDown(rect);
            }
            GUILayout.Space(50);
        }