Skip to content

Commit 3518a72

Browse files
committed
Исправление совмести работы с Windows 11.
Изменен дефолтный адрес сохранению моделей распознавания поумолчанию. Теперь скачанные модели лежать по пути: C:\Users\USERNAME\AppData\Local\ChatCaster\Models
1 parent b925307 commit 3518a72

7 files changed

Lines changed: 338 additions & 89 deletions

File tree

ChatCaster.Core/Constants/AppConstants.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,19 @@ public static string GetConfigFilePath()
6060
/// <summary>
6161
/// Создает все необходимые директории если они не существуют
6262
/// </summary>
63+
///
64+
public static string GetModelsDirectory()
65+
{
66+
return Path.Combine(GetAppDataDirectory(), "Models");
67+
}
68+
6369
public static void EnsureDirectoriesExist()
6470
{
6571
Directory.CreateDirectory(GetAppDataDirectory());
6672
Directory.CreateDirectory(GetDefaultLogDirectory());
73+
Directory.CreateDirectory(GetModelsDirectory());
6774
}
75+
76+
6877
}
6978
}

ChatCaster.Windows/Managers/AudioSettings/WhisperModelManager.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using ChatCaster.Core.Constants;
12
using ChatCaster.Core.Models;
23
using ChatCaster.Core.Services.Audio;
34
using ChatCaster.Core.Services.System;
@@ -59,24 +60,23 @@ private async Task<bool> IsModelDownloadedAsync(string modelSize)
5960
{
6061
try
6162
{
62-
// ИСПРАВЛЕНИЕ: Используем абсолютный путь относительно приложения
63-
var modelsDirectory = Path.Combine(AppContext.BaseDirectory, "Models");
63+
// Используем путь из AppConstants
64+
var modelsDirectory = AppConstants.Paths.GetModelsDirectory();
6465
var modelPath = Path.Combine(modelsDirectory, $"ggml-{modelSize}.bin");
65-
66+
6667
Log.Debug("🔍 [MODEL_CHECK] Проверяем модель по пути: {ModelPath}", modelPath);
67-
68+
6869
var exists = await Task.Run(() => File.Exists(modelPath));
6970
Log.Debug("🔍 [MODEL_CHECK] Модель {ModelSize} существует: {Exists}", modelSize, exists);
70-
71+
7172
return exists;
7273
}
7374
catch (Exception ex)
7475
{
7576
Log.Warning(ex, "Ошибка проверки модели {ModelSize}", modelSize);
7677
return false;
7778
}
78-
}
79-
79+
}
8080

8181
/// <summary>
8282
/// Применяет текущую конфигурацию к речевому сервису без скачивания

ChatCaster.Windows/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using ChatCaster.Core.Constants;
12
using System.Windows;
23
using Microsoft.Extensions.DependencyInjection;
34
using Microsoft.Extensions.Hosting;
@@ -120,7 +121,7 @@ private static void ConfigureServices(IServiceCollection services, IConfiguratio
120121
config.ThreadCount = Environment.ProcessorCount / 2;
121122
config.EnableGpu = speechConfig.UseGpuAcceleration;
122123
config.Language = speechConfig.Language;
123-
config.ModelPath = Path.Combine(AppContext.BaseDirectory, "Models");
124+
config.ModelPath = AppConstants.Paths.GetModelsDirectory();
124125
speechConfig.EngineSettings["ModelPath"] = config.ModelPath;
125126
Log.Information("🔍 [WHISPER_CONFIG] AppContext.BaseDirectory: {BaseDir}", AppContext.BaseDirectory);
126127
Log.Information("🔍 [WHISPER_CONFIG] ModelPath установлен: {ModelPath}", config.ModelPath);
@@ -132,11 +133,17 @@ private static void ConfigureServices(IServiceCollection services, IConfiguratio
132133
});
133134

134135
// === ОСНОВНЫЕ СЕРВИСЫ ===
135-
services.AddSingleton<IAudioCaptureService, AudioCaptureService>();
136136
services.AddSingleton<ISystemIntegrationService, SystemIntegrationService>();
137137
services.AddSingleton<IOverlayService, WindowsOverlayService>();
138138
services.AddSingleton<ILocalizationService, LocalizationService>();
139139

140+
// === АУДИО СЕРВИСЫ ===
141+
services.AddSingleton<WindowsAudioCompatibility>();
142+
services.AddSingleton<IAudioCaptureService>(provider =>
143+
{
144+
return new AudioCaptureService(provider.GetRequiredService<WindowsAudioCompatibility>());
145+
});
146+
140147
// === ГЕЙМПАД СЕРВИСЫ ===
141148
services.AddSingleton<Services.GamepadService.MainGamepadService>(provider =>
142149
new Services.GamepadService.MainGamepadService(

ChatCaster.Windows/Services/ApplicationInitializationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private async Task EnsureDefaultConfigurationAsync(AppConfig config)
122122
if (!config.SpeechRecognition.EngineSettings.ContainsKey("ModelPath") ||
123123
string.IsNullOrEmpty(config.SpeechRecognition.EngineSettings["ModelPath"]?.ToString()))
124124
{
125-
config.SpeechRecognition.EngineSettings["ModelPath"] = Path.Combine(AppContext.BaseDirectory, "Models");
125+
config.SpeechRecognition.EngineSettings["ModelPath"] = AppConstants.Paths.GetModelsDirectory();
126126
configChanged = true;
127127
Log.Information("Установлен дефолтный ModelPath: {ModelPath}",
128128
config.SpeechRecognition.EngineSettings["ModelPath"]);

0 commit comments

Comments
 (0)