generated from fahricansecer/boilerplate-be
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user