From 4c7985640790dda3c9995dc3d73d1a8b31000f20 Mon Sep 17 00:00:00 2001 From: EX3 Date: Thu, 26 Sep 2024 23:26:33 +0900 Subject: [PATCH] Fixed bugs --- Mirivoice/Engines/TTS/EngineVITS2.cs | 4 ---- Mirivoice/Mirivoice.Core/Managers/AudioManager.cs | 11 ++++++++++- Mirivoice/ViewModels/LineBoxViewModel.cs | 2 +- Mirivoice/ViewModels/MainViewModel.cs | 5 ++++- Mirivoice/Views/LineBoxView.axaml.cs | 12 +++++++++++- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Mirivoice/Engines/TTS/EngineVITS2.cs b/Mirivoice/Engines/TTS/EngineVITS2.cs index 472d0fd..73df558 100644 --- a/Mirivoice/Engines/TTS/EngineVITS2.cs +++ b/Mirivoice/Engines/TTS/EngineVITS2.cs @@ -178,10 +178,6 @@ public override void Inference(string ipaText, string cacheFilePath, int spkid) NamedOnnxValue.CreateFromTensor("sid", sidTensor) }; - if (File.Exists(cacheFilePath)) - { - return; - } var options = new SessionOptions(); using (var results = new InferenceSession(ModelPath, options).Run(inputs)) { diff --git a/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs b/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs index 2f6e70a..0227687 100644 --- a/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs +++ b/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs @@ -272,8 +272,16 @@ private void OnPlaybackStopped(object sender, StoppedEventArgs e) return; } + try + { _audioReaders[_currentFileIndex].Dispose(); - + } + catch (Exception ex) + { + Log.Error(ex, "Error disposing audio reader."); + } + + v.LineBoxCollection[currentLine].viewModel.IsSelected = false; v.LinesViewerOffset = new Avalonia.Vector(0, v.LinesViewerOffset.Y + 104); @@ -319,6 +327,7 @@ public void StopAudio() _audioReaders.Clear(); _waveOut.Stop(); _waveOut.Dispose(); + MainViewModelPlaying = false; } } diff --git a/Mirivoice/ViewModels/LineBoxViewModel.cs b/Mirivoice/ViewModels/LineBoxViewModel.cs index 099f77f..43ffb71 100644 --- a/Mirivoice/ViewModels/LineBoxViewModel.cs +++ b/Mirivoice/ViewModels/LineBoxViewModel.cs @@ -150,7 +150,7 @@ public override void OnVoicerChanged(Voicer voicer) VoicerInfo vInfo = voicer.Info; phonemizer = GetPhonemizer(voicer.Info.LangCode); - + l.IsCacheIsVaild = false; LangCode = voicer.Info.LangCode.ToUpper().Substring(0, 2); VoicerType = voicer.Info.Type; diff --git a/Mirivoice/ViewModels/MainViewModel.cs b/Mirivoice/ViewModels/MainViewModel.cs index b3eecc3..d7ed953 100644 --- a/Mirivoice/ViewModels/MainViewModel.cs +++ b/Mirivoice/ViewModels/MainViewModel.cs @@ -548,6 +548,7 @@ public async void OnNewButtonClick() CurrentProjectPath = (string)mainWindow.FindResource("app.defprojectname"); mTextBoxEditor.CurrentScript = ""; + CurrentEditIndex = 0; MainManager.Instance.cmd.ProjectOpened(); @@ -564,8 +565,10 @@ public async void OnNewButtonClick() } - + LineBoxCollection.Clear(); + CurrentSingleLineEditor = null; + MResultsCollection.Clear(); } diff --git a/Mirivoice/Views/LineBoxView.axaml.cs b/Mirivoice/Views/LineBoxView.axaml.cs index 60dde36..8d23914 100644 --- a/Mirivoice/Views/LineBoxView.axaml.cs +++ b/Mirivoice/Views/LineBoxView.axaml.cs @@ -376,12 +376,20 @@ public void AutoScroll() public async Task StartInference() { + if (viewModel.voicerSelector.CurrentVoicer is null) + { + Log.Warning("CurrentVoicer is null"); + return; + } //Log.Debug("StartInference"); await Dispatcher.UIThread.InvokeAsync(async () => { if (ShouldPhonemizeWhenSelected) { + DeActivatePhonemizer = false; + ShouldPhonemize = true; + Task res = viewModel.phonemizer.ConvertToIPA(viewModel.LineText, DispatcherPriority.ApplicationIdle); IPAText = await res; } @@ -399,8 +407,9 @@ await Dispatcher.UIThread.InvokeAsync(async () => { IsCacheIsVaild = false; } - if (viewModel.voicerSelector.CurrentVoicer.CurrentVoicerMeta != lastInferencedVoicerMeta) + if (lastInferencedVoicerMeta is not null && viewModel.voicerSelector.CurrentVoicer.CurrentVoicerMeta.SpeakerId != lastInferencedVoicerMeta.SpeakerId) { + Log.Debug("meta changed"); IsCacheIsVaild = false; } if (!System.IO.Path.Exists(CurrentCacheName)) @@ -420,6 +429,7 @@ await Dispatcher.UIThread.InvokeAsync(async () => else { Log.Warning("CurrentVoicerMeta is null"); + return; } } , DispatcherPriority.ApplicationIdle);