Add vosk, Naudio
This commit is contained in:
@@ -1,6 +1,45 @@
|
||||
namespace VisionAsist.ViewModels;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using VisionAsist.Models;
|
||||
namespace VisionAsist.ViewModels;
|
||||
|
||||
public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public string Greeting { get; } = "Welcome to Avalonia!";
|
||||
[ObservableProperty]
|
||||
private bool isListening;
|
||||
[ObservableProperty]
|
||||
private string recognizedtext;
|
||||
private Action<string>? _coreHandler;
|
||||
|
||||
partial void OnIsListeningChanged(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
Core.StartListing();
|
||||
|
||||
// Сохраняем ссылку на обработчик
|
||||
_coreHandler = word =>
|
||||
{
|
||||
|
||||
Avalonia.Threading.Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
Recognizedtext = Core.TextAsist;
|
||||
});
|
||||
};
|
||||
|
||||
Core.triger.OnRecognized += _coreHandler;
|
||||
}
|
||||
else
|
||||
{
|
||||
Core.StopListing();
|
||||
|
||||
// Правильная отписка
|
||||
if (_coreHandler != null)
|
||||
{
|
||||
Core.triger.OnRecognized -= _coreHandler;
|
||||
_coreHandler = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
VisionAsist/ViewModels/SettingsViewModel.cs
Normal file
6
VisionAsist/ViewModels/SettingsViewModel.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace VisionAsist.ViewModels;
|
||||
|
||||
public class SettingsViewModel : ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace VisionAsist.ViewModels;
|
||||
|
||||
public abstract class ViewModelBase : ObservableObject
|
||||
public partial class ViewModelBase : ObservableObject
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user