Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Sep 26, 2024
1 parent c4683c6 commit 4c79856
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
4 changes: 0 additions & 4 deletions Mirivoice/Engines/TTS/EngineVITS2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
11 changes: 10 additions & 1 deletion Mirivoice/Mirivoice.Core/Managers/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -319,6 +327,7 @@ public void StopAudio()
_audioReaders.Clear();
_waveOut.Stop();
_waveOut.Dispose();
MainViewModelPlaying = false;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Mirivoice/ViewModels/LineBoxViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion Mirivoice/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ public async void OnNewButtonClick()

CurrentProjectPath = (string)mainWindow.FindResource("app.defprojectname");
mTextBoxEditor.CurrentScript = "";

CurrentEditIndex = 0;

MainManager.Instance.cmd.ProjectOpened();
Expand All @@ -564,8 +565,10 @@ public async void OnNewButtonClick()

}



LineBoxCollection.Clear();
CurrentSingleLineEditor = null;
MResultsCollection.Clear();

}

Expand Down
12 changes: 11 additions & 1 deletion Mirivoice/Views/LineBoxView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> res = viewModel.phonemizer.ConvertToIPA(viewModel.LineText, DispatcherPriority.ApplicationIdle);
IPAText = await res;
}
Expand All @@ -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))
Expand All @@ -420,6 +429,7 @@ await Dispatcher.UIThread.InvokeAsync(async () =>
else
{
Log.Warning("CurrentVoicerMeta is null");
return;
}
}
, DispatcherPriority.ApplicationIdle);
Expand Down

0 comments on commit 4c79856

Please sign in to comment.