Example #1
0
 void OnCreate()
 {
     if (characterSynthesis.Create())
     {
         if (characterSynthesis.DownloadResultFile())
         {
             AssetDatabase.Refresh();
             Router.ShowText(characterSynthesis.text_id);
             Close();
         }
         else
         {
             Debug.LogError("result file couldn't be downloaded");
         }
     }
     else
     {
         Debug.LogError($"CharacterSynthesis errors: {characterSynthesis.GetErrorsAsJson()}");
     }
 }
        private async Task PerformSynthesis(int idx)
        {
            await Task.Run(() => {
                try
                {
                    CharacterSynthesis characterSynthesis = characterSyntheses[idx];

                    if (!replaceExistingFiles && characterSynthesis.ResultFileExists())
                    {
                        Debug.Log($"Audio file for {characterSynthesis.text_slug} already existing: skip it");
                        exportSkipped++;
                    }
                    else
                    {
                        if (characterSynthesis.Create())
                        {
                            if (characterSynthesis.DownloadResultFile())
                            {
                                Logger.Log("Synthesis done");
                            }
                            else
                            {
                                Debug.LogError("result file couldn't be downloaded");
                                exportErrors.Add($"Audio file for {characterSynthesis.text_slug} couldn't be downloaded");
                            }
                        }
                        else
                        {
                            Debug.LogError($"CharacterSynthesis errors: {characterSynthesis.GetErrorsAsJson()}");
                            exportErrors.Add($"Synthesis error for {characterSynthesis.text_slug}");
                        }
                    }
                } catch (Exception e) {
                    exportErrors.Add($"Synthesis error for line {idx+1}: {e}");
                    Debug.LogError($"ERROR: {e}");
                }
            });
        }