diff --git a/Mirivoice/Assets/DefaultVoicers/Miri.z01 b/Mirivoice/Assets/DefaultVoicers/Miri.z01 index 37ea3f1..2ad43cf 100644 Binary files a/Mirivoice/Assets/DefaultVoicers/Miri.z01 and b/Mirivoice/Assets/DefaultVoicers/Miri.z01 differ diff --git a/Mirivoice/Assets/DefaultVoicers/Miri.zip b/Mirivoice/Assets/DefaultVoicers/Miri.zip index f357bd2..3291082 100644 Binary files a/Mirivoice/Assets/DefaultVoicers/Miri.zip and b/Mirivoice/Assets/DefaultVoicers/Miri.zip differ diff --git a/Mirivoice/Commands/MementoCommand.cs b/Mirivoice/Commands/MementoCommand.cs index 59c1eae..5ff6fdf 100644 --- a/Mirivoice/Commands/MementoCommand.cs +++ b/Mirivoice/Commands/MementoCommand.cs @@ -24,7 +24,7 @@ public void Execute(bool isRedoing) if (!isRedoing) { _originator.ClearRedoMemento(); - _originator.PrintMemento(); + //_originator.PrintMemento(); //Log.Debug($"-- exec"); } @@ -37,7 +37,7 @@ public void Execute(bool isRedoing) } //Log.Debug($"-- Redoing"); _originator.RestoreFromRedoMemento(); - _originator.PrintMemento(); + //_originator.PrintMemento(); } } diff --git a/Mirivoice/Commands/SetComboboxOriginator.cs b/Mirivoice/Commands/SetComboboxOriginator.cs index 110ea7f..50d7391 100644 --- a/Mirivoice/Commands/SetComboboxOriginator.cs +++ b/Mirivoice/Commands/SetComboboxOriginator.cs @@ -1,7 +1,4 @@ using Mirivoice.Mirivoice.Core.Format; -using Mirivoice.ViewModels; -using Serilog; -using System; namespace Mirivoice.Commands { @@ -20,7 +17,7 @@ public SetProsodyOriginator(ref int index, MResult v) : base(ref index) public override void UpdateProperties() { - Log.Debug("[Updating Properties] -- {obj}", obj); + //Log.Debug("[Updating Properties] -- {obj}", obj); v.NotProcessingSetProsodyCommand = true; // prevent recursion loop v.Prosody = obj; } diff --git a/Mirivoice/Commands/VITS2SetExpOriginator.cs b/Mirivoice/Commands/VITS2SetExpOriginator.cs index 57319cc..dac78db 100644 --- a/Mirivoice/Commands/VITS2SetExpOriginator.cs +++ b/Mirivoice/Commands/VITS2SetExpOriginator.cs @@ -1,8 +1,4 @@ -using Mirivoice.Engines; -using Mirivoice.Mirivoice.Core.Format; -using Mirivoice.ViewModels; -using Serilog; -using System; +using Mirivoice.ViewModels; namespace Mirivoice.Commands { @@ -29,7 +25,7 @@ public VITS2SetExpOriginator(ref int index, ExpressionEditViewModelVITS2 v, ExpV public override void UpdateProperties() { - Log.Debug("[Updating Properties] -- {obj}", obj); + //Log.Debug("[Updating Properties] -- {obj}", obj); switch (type) { case ExpVITS2.Speed: diff --git a/Mirivoice/Engines/VoicerMeta.cs b/Mirivoice/Engines/VoicerMeta.cs index 50c94f1..f430f58 100644 --- a/Mirivoice/Engines/VoicerMeta.cs +++ b/Mirivoice/Engines/VoicerMeta.cs @@ -24,10 +24,10 @@ public partial class VoicerMeta public string Phrase { get; set; } = ""; public string Description { get; set; } = ""; - + public string StyleIcon { get; set; } = ""; + - public VoicerMeta() { diff --git a/Mirivoice/Mirivoice.Core/Editor/VoicerSelector.cs b/Mirivoice/Mirivoice.Core/Editor/VoicerSelector.cs index e96b5eb..fa86b8d 100644 --- a/Mirivoice/Mirivoice.Core/Editor/VoicerSelector.cs +++ b/Mirivoice/Mirivoice.Core/Editor/VoicerSelector.cs @@ -33,16 +33,18 @@ public Voicer CurrentVoicer { this.RaiseAndSetIfChanged(ref _currentVoicer, value); _currentVoicer.RefreshNickAndStyle(); + v.OnStyleChanged(); OnPropertyChanged(nameof(CurrentVoicer)); v._currentDefaultVoicerIndex = Voicers.IndexOf(value); OnPropertyChanged(nameof(CurrentDefaultVoicerIndex)); - + } } } + public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) @@ -119,6 +121,7 @@ public void UpdateVoicerCollection() } updatedVoicer.CurrentVoicerMeta = updatedVoicer.VoicerMetaCollection[metaIndex]; updatedVoicer.RefreshNickAndStyle(); + voicersToUpdate.Add(new VoicerUpdate(updatedVoicer, updatedVoicerIndex)); @@ -223,6 +226,9 @@ public int CurrentDefaultVoicerIndex this.RaiseAndSetIfChanged(ref _currentDefaultVoicerIndex, value); _currentVoicer = Voicers[_currentDefaultVoicerIndex]; _currentVoicer.RefreshNickAndStyle(); + v.OnStyleChanged(); + + v.OnVoicerChanged(_currentVoicer); OnPropertyChanged(nameof(CurrentVoicer)); diff --git a/Mirivoice/Mirivoice.Core/Format/MResult.cs b/Mirivoice/Mirivoice.Core/Format/MResult.cs index 7edb81e..a93a873 100644 --- a/Mirivoice/Mirivoice.Core/Format/MResult.cs +++ b/Mirivoice/Mirivoice.Core/Format/MResult.cs @@ -50,6 +50,7 @@ public class MResult : VoicerSelectingViewModelBase int lastProsodyIndex; public override MTextBoxEditor mTextBoxEditor { get; set; } + public override void OnStyleChanged() { } private ImageBrush _bosIcon; public ImageBrush BosIcon { diff --git a/Mirivoice/Mirivoice.Core/Format/Voicer.cs b/Mirivoice/Mirivoice.Core/Format/Voicer.cs index e6c2417..dba6a41 100644 --- a/Mirivoice/Mirivoice.Core/Format/Voicer.cs +++ b/Mirivoice/Mirivoice.Core/Format/Voicer.cs @@ -1,6 +1,7 @@ using Mirivoice.Commands; using Mirivoice.Engines; using Mirivoice.Engines.TTS; +using Mirivoice.ViewModels; using Mirivoice.Views; using ReactiveUI; using Serilog; @@ -51,6 +52,7 @@ public class Voicer : ReactiveObject, INotifyPropertyChanged private VoicerMeta _currentVoicerMeta; private VoicerMeta lastVoicerMeta; + private LineBoxViewModel lv; private bool Undobackuped = false; @@ -67,6 +69,14 @@ public void SetRootPath(string rootPath) Engine.Init(this); } + public void SetLineBoxViewModel(LineBoxViewModel lv) + { + this.lv = lv; + if (lv is not null) + { + lv.OnStyleChanged(); + } + } public void Inference(string ipaText, string cacheFilePath, LineBoxView l) { //Log.Debug("[Infer Started] --- ipaText"); @@ -129,6 +139,11 @@ public VoicerMeta CurrentVoicerMeta } this.RaiseAndSetIfChanged(ref _currentVoicerMeta, value); this.RefreshNickAndStyle(); + + if (lv is not null) + { + lv.OnStyleChanged(); + } OnPropertyChanged(nameof(NickAndStyle)); OnPropertyChanged(nameof(CurrentVoicerMeta)); diff --git a/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs b/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs index d00da25..a870b86 100644 --- a/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs +++ b/Mirivoice/Mirivoice.Core/Managers/AudioManager.cs @@ -390,7 +390,11 @@ private void OnPlaybackStopped(object? sender, EventArgs e) if (audioPaths.Count == 0) // when stopped { v.isPlaying = false; - v.EnableGlobalPlay = true; + if (!_player.Paused) + { + v.EnableGlobalPlay = true; + } + v.EnablePreviewPlay = true; if (!MainViewModelPlaying) { diff --git a/Mirivoice/Mirivoice.Core/Managers/CommandManager.cs b/Mirivoice/Mirivoice.Core/Managers/CommandManager.cs index 1666822..41f88b6 100644 --- a/Mirivoice/Mirivoice.Core/Managers/CommandManager.cs +++ b/Mirivoice/Mirivoice.Core/Managers/CommandManager.cs @@ -56,7 +56,7 @@ void ClearStacks() } public void ExecuteCommand(ICommand command) { - Log.Debug("======== ExecuteCommand ========"); + //Log.Debug("======== ExecuteCommand ========"); command.Execute(false); _undoStack.Push(command); _redoStack.Clear(); @@ -71,7 +71,7 @@ public void ExecuteCommand(ICommand command) StreamWriter writer = new StreamWriter("filePath", false, Encoding.UTF8); public void Undo() { - Log.Debug("======== Undo ========"); + //Log.Debug("======== Undo ========"); if (_undoStack.Count > 0) { var command = _undoStack.Pop(); @@ -89,7 +89,7 @@ public void Undo() public void Redo() { - Log.Debug("======== Redo ========"); + //Log.Debug("======== Redo ========"); if (_redoStack.Count > 0) { var command = _redoStack.Pop(); diff --git a/Mirivoice/ViewModels/LineBoxViewModel.cs b/Mirivoice/ViewModels/LineBoxViewModel.cs index 07ab013..918dc5e 100644 --- a/Mirivoice/ViewModels/LineBoxViewModel.cs +++ b/Mirivoice/ViewModels/LineBoxViewModel.cs @@ -32,7 +32,7 @@ public string LineNo } } - private string _langCode; + private string _langCode; public string LangCode { get => _langCode; @@ -91,7 +91,7 @@ public string LineText { this.RaiseAndSetIfChanged(ref _lineText, value); OnPropertyChanged(nameof(LineText)); - + } } @@ -134,7 +134,7 @@ public ImageBrush Icon { get => _icon; - set + set { this.RaiseAndSetIfChanged(ref _icon, value); OnPropertyChanged(nameof(Icon)); @@ -147,6 +147,8 @@ public override void OnVoicerChanged(Voicer voicer) { //Log.Debug($"OnVoicerChanged: {voicer.NickAndStyle}"); VoicerInfo vInfo = voicer.Info; + voicer.SetLineBoxViewModel(this); + if (phonemizer is null) { @@ -154,7 +156,7 @@ public override void OnVoicerChanged(Voicer voicer) } if (lastType is not null && lastType != voicer.Info.Type) { - Log.Debug("Type Changed: {0}", voicer.Info.Type); + //Log.Debug("Type Changed: {0}", voicer.Info.Type); l.ResetExpEditor(voicer.Info.Type); } @@ -164,18 +166,52 @@ public override void OnVoicerChanged(Voicer voicer) VoicerType = voicer.Info.Type; if (vInfo.Icon != null && vInfo.Icon != string.Empty) { - string voicerIconPath = Path.Combine(voicer.RootPath, - vInfo.Icon.Replace('/', Path.DirectorySeparatorChar)); - if (!File.Exists(voicerIconPath)) + string voicerIconPath = null; + if (voicer.CurrentVoicerMeta.StyleIcon is not null) { - return; + voicerIconPath = Path.Combine(voicer.RootPath, + voicer.CurrentVoicerMeta.StyleIcon.Replace('/', Path.DirectorySeparatorChar)); + // try to get icon from style + if (voicerIconPath is not null && !File.Exists(voicerIconPath)) + { + voicerIconPath = Path.Combine(voicer.RootPath, + vInfo.Icon.Replace('/', Path.DirectorySeparatorChar)); + } + } + else + { + voicerIconPath = Path.Combine(voicerSelector.CurrentVoicer.RootPath, + vInfo.Icon.Replace('/', Path.DirectorySeparatorChar)); } + - Icon + // try to get icon from voicer + if (voicerIconPath is not null && !File.Exists(voicerIconPath)) + { + return; + } + if (voicerIconPath is not null) + { + Icon = new ImageBrush(new Bitmap(voicerIconPath)) { Stretch = Stretch.UniformToFill, }; + } + else + { + var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp"); + var assets = AssetLoader.Open(uri); + + using (var stream = assets) + { + var bitmap = new Bitmap(stream); + Icon = new ImageBrush(bitmap) + { + Stretch = Stretch.UniformToFill + }; + } + } } else @@ -193,7 +229,77 @@ public override void OnVoicerChanged(Voicer voicer) } } } + public override void OnStyleChanged() + { + Log.Information("OnStyleChanged"); + VoicerInfo vInfo = voicerSelector.CurrentVoicer.Info; + if (vInfo.Icon != null && vInfo.Icon != string.Empty) + { + string voicerIconPath = null; + if (voicerSelector.CurrentVoicer.CurrentVoicerMeta.StyleIcon is not null) + { + voicerIconPath = Path.Combine(voicerSelector.CurrentVoicer.RootPath, + voicerSelector.CurrentVoicer.CurrentVoicerMeta.StyleIcon.Replace('/', Path.DirectorySeparatorChar)); + // try to get icon from style + if (voicerIconPath is not null && !File.Exists(voicerIconPath)) + { + voicerIconPath = Path.Combine(voicerSelector.CurrentVoicer.RootPath, + vInfo.Icon.Replace('/', Path.DirectorySeparatorChar)); + } + } + else + { + voicerIconPath = Path.Combine(voicerSelector.CurrentVoicer.RootPath, + vInfo.Icon.Replace('/', Path.DirectorySeparatorChar)); + } + + + // try to get icon from voicer + if (voicerIconPath is not null && !File.Exists(voicerIconPath)) + { + return; + } + if (voicerIconPath is not null) + { + Icon + = new ImageBrush(new Bitmap(voicerIconPath)) + { + Stretch = Stretch.UniformToFill, + }; + } + else + { + var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp"); + var assets = AssetLoader.Open(uri); + + using (var stream = assets) + { + var bitmap = new Bitmap(stream); + Icon = new ImageBrush(bitmap) + { + Stretch = Stretch.UniformToFill + }; + } + } + + OnPropertyChanged(nameof(Icon)); + } + else + { + var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp"); + var assets = AssetLoader.Open(uri); + using (var stream = assets) + { + var bitmap = new Bitmap(stream); + Icon = new ImageBrush(bitmap) + { + Stretch = Stretch.UniformToFill + }; + } + OnPropertyChanged(nameof(Icon)); + } + } bool cultureChangedFirst = false; public override void OnVoicerCultureChanged(CultureInfo culture) { diff --git a/Mirivoice/ViewModels/MainViewModel.cs b/Mirivoice/ViewModels/MainViewModel.cs index 94300ad..0cb7b9f 100644 --- a/Mirivoice/ViewModels/MainViewModel.cs +++ b/Mirivoice/ViewModels/MainViewModel.cs @@ -501,7 +501,7 @@ public void OnPreviewButtonClick() else { isPlaying = false; - EnableGlobalPlay = true; + EnableGlobalPlay = false; Log.Information("Pause Button Clicked - preview"); } } @@ -637,6 +637,7 @@ public void OnStopButtonClick() MainManager.Instance.AudioM.StopAudio(); StopButtonEnabled = false; EnableGlobalPlay = true; + EnablePreviewPlay = true; } public void OnAddBoxesButtonClick() @@ -1005,7 +1006,7 @@ public async void OnVoicerInstallButtonClick() } public override void OnVoicerChanged(Voicer value) { } - + public override void OnStyleChanged() { } public override void OnVoicerCultureChanged(CultureInfo culture) { } } diff --git a/Mirivoice/ViewModels/SingleLineEditorViewModel.cs b/Mirivoice/ViewModels/SingleLineEditorViewModel.cs index 91b4705..2462b23 100644 --- a/Mirivoice/ViewModels/SingleLineEditorViewModel.cs +++ b/Mirivoice/ViewModels/SingleLineEditorViewModel.cs @@ -9,7 +9,7 @@ public class SingleLineEditorViewModel : VoicerSelectingViewModelBase public override MTextBoxEditor mTextBoxEditor { get; set; } public override void OnVoicerChanged(Voicer value) { } public override void OnVoicerCultureChanged(CultureInfo culture) { } - + public override void OnStyleChanged() { } public SingleLineEditorViewModel(string line=""): base(line, false) { diff --git a/Mirivoice/ViewModels/VoicerSelectingViewModelBase.cs b/Mirivoice/ViewModels/VoicerSelectingViewModelBase.cs index 8869c29..30ad380 100644 --- a/Mirivoice/ViewModels/VoicerSelectingViewModelBase.cs +++ b/Mirivoice/ViewModels/VoicerSelectingViewModelBase.cs @@ -19,6 +19,7 @@ public abstract class VoicerSelectingViewModelBase: ViewModelBase public string _currentScript; public bool NotProcessingSetScriptCommand = false; protected string lastScript; + public abstract void OnStyleChanged(); public virtual VoicerSelector voicerSelector { get; set; } public virtual MTextBoxEditor mTextBoxEditor { get; set; } public VoicerSelectingViewModelBase(bool useVoicerSelector=false) diff --git a/Mirivoice/Views/LineBoxView.axaml.cs b/Mirivoice/Views/LineBoxView.axaml.cs index 8562e6d..5d05bcb 100644 --- a/Mirivoice/Views/LineBoxView.axaml.cs +++ b/Mirivoice/Views/LineBoxView.axaml.cs @@ -283,6 +283,7 @@ public LineBoxView(MLinePrototype mLinePrototype, MainViewModel v, int index, in singleLineEditorView = new SingleLineEditorView(this); } ResetExpEditor(v.voicerSelector.CurrentVoicer.Info.Type); + viewModel.OnStyleChanged(); } // Commands public MCommand DelLineBoxCommand { get; set; }