main
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled

This commit is contained in:
Harun CAN
2026-05-31 14:13:33 +03:00
parent 76a244af90
commit f89923b03f
3 changed files with 60 additions and 10 deletions
+40 -3
View File
@@ -46,15 +46,52 @@ public class VoiceboxTtsService
scene.Order,
scene.NarrationText[..Math.Min(60, scene.NarrationText.Length)]);
// VoiceBox'ta varsayılan bir profil (Örn: Kokoro default)
var profileId = string.IsNullOrWhiteSpace(voiceStyle) ? "b6a8a474-0fc0-4a8f-b9f1-a1e4c84a8649" : voiceStyle;
// 1. Voicebox profillerini çek ve uygun bir profil ID bul
string profileId = string.Empty;
try
{
var profilesResponse = await _httpClient.GetAsync("profiles", ct);
if (profilesResponse.IsSuccessStatusCode)
{
var profilesStr = await profilesResponse.Content.ReadAsStringAsync(ct);
using var profilesDoc = JsonDocument.Parse(profilesStr);
if (profilesDoc.RootElement.ValueKind == JsonValueKind.Array)
{
foreach (var profile in profilesDoc.RootElement.EnumerateArray())
{
var lang = profile.GetProperty("language").GetString();
var id = profile.GetProperty("id").GetString();
// Türkçe profil öncelikli
if (lang != null && lang.StartsWith("tr") && !string.IsNullOrEmpty(id))
{
profileId = id;
break;
}
else if (string.IsNullOrEmpty(profileId) && !string.IsNullOrEmpty(id))
{
profileId = id; // İlk bulduğunu yedek olarak tut
}
}
}
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Voicebox profilleri çekilirken hata oluştu.");
}
// Eğer hiçbir profil bulamazsak, hardcoded bir fallback (Voicebox'un ilk kurulumunda eklediği rastgele GUID değildir umarım)
if (string.IsNullOrEmpty(profileId))
{
profileId = "b6a8a474-0fc0-4a8f-b9f1-a1e4c84a8649";
}
var requestBody = new
{
text = scene.NarrationText,
profile_id = profileId,
language = "tr",
engine = "kokoro"
engine = "edge_tts" // Türkçe için en stabil olan edge_tts
};
var content = new StringContent(