Exemplo n.º 1
0
    void FinishedProcessingMulti(AudioClip finishedClip, List <PhonemeMarker> markers)
    {
        //Get Settings File
        string[] guids = AssetDatabase.FindAssets("ProjectSettings t:LipSyncProject");
        string   spath = "";

        if (guids.Length > 0)
        {
            spath = AssetDatabase.GUIDToAssetPath(guids[0]);

            if (guids.Length > 1)
            {
                Debug.LogWarning("LipSync: Multiple LipSyncProject files found. Only one will be used.");
            }
        }

        LipSyncProject settings = (LipSyncProject)AssetDatabase.LoadAssetAtPath(spath, typeof(LipSyncProject));

        // Create File
        string path = AssetDatabase.GetAssetPath(finishedClip);

        path = Path.ChangeExtension(path, xmlMode ? "xml" : "asset");

        try {
            LipSyncClipSetup.SaveFile(settings, path, xmlMode, "", finishedClip.length, markers.ToArray(), new EmotionMarker[0],
                                      new GestureMarker[0], finishedClip);
        } catch {
            Debug.Log(settings);
            Debug.Log(path);
            Debug.Log(xmlMode);
            Debug.Log(finishedClip);
            Debug.Log(markers);
        }

        if (currentClip < clips.Count)
        {
            AutoSync.AutoSyncOptions options = new AutoSync.AutoSyncOptions(languageModelNames[languageModel], attemptAudioConversion, allphone_ciEnabled, backtraceEnabled, beamExponent, pbeamExponent, lwValue, doCleanup, cleanupAggression);
            AutoSync.ProcessAudio(clips[currentClip], FinishedProcessingMulti, OnAutoSyncFailed, (currentClip + 1).ToString() + "/" + clips.Count.ToString(), options);
            currentClip++;
        }
        else
        {
            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();
            setup.ShowNotification(new GUIContent("Batch AutoSync Complete."));
            Close();
        }
    }
Exemplo n.º 2
0
    private void FinishedProcessingMulti(LipSyncData outputData, AutoSync.ASProcessDelegateData data)
    {
        if (data.success)
        {
            var settings = LipSyncEditorExtensions.GetProjectFile();

            // Create File
            string outputPath = AssetDatabase.GetAssetPath(outputData.clip);
            outputPath = Path.ChangeExtension(outputPath, xmlMode ? "xml" : "asset");

            try
            {
                LipSyncClipSetup.SaveFile(settings, outputPath, xmlMode, outputData.transcript, outputData.length, outputData.phonemeData, outputData.emotionData,
                                          outputData.gestureData, outputData.clip);
            }
            catch (Exception e)
            {
                Debug.LogError(e.StackTrace);
            }
        }
        else
        {
            batchIncomplete = true;
            string clipName = "Undefined";
            if (outputData.clip)
            {
                clipName = outputData.clip.name;
            }

            Debug.LogErrorFormat("AutoSync: Processing failed on clip '{0}'. Continuing with batch.", clipName);
        }

        if (currentClip < clips.Count)
        {
            currentClip++;

            if (autoSyncInstance == null)
            {
                autoSyncInstance = new AutoSync();
            }

            LipSyncData tempData = CreateInstance <LipSyncData>();
            tempData.clip   = clips[currentClip];
            tempData.length = tempData.clip.length;

            if (loadTranscripts)
            {
                tempData.transcript = AutoSyncUtility.TryGetTranscript(tempData.clip);
            }

            autoSyncInstance.RunSequence(currentModules.ToArray(), FinishedProcessingMulti, tempData);
        }
        else
        {
            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();

            if (!batchIncomplete)
            {
                setup.ShowNotification(new GUIContent("Batch AutoSync Completed Successfully"));
            }
            else
            {
                setup.ShowNotification(new GUIContent("Batch AutoSync Completed With Errors"));
            }

            Close();
        }
    }