using System;
using System.IO;
using System.Threading.Tasks;
using Lokutor;
using Lokutor.Exceptions;
namespace LokutorExample
{
class Program
{
static async Task Main(string[] args)
{
// Initialize client
var client = new LokutorClient("YOUR_API_KEY");
try
{
// Synthesize speech
var response = await client.SynthesizeAsync(
text: "Welcome to Lokutor! This is a high-quality text-to-speech system.",
voiceId: "F1",
quality: "high",
speed: 1.0f,
outputFormat: "mp3_22050",
includeVisemes: true,
language: "en"
);
// Decode and save audio
var audioBytes = Convert.FromBase64String(response.AudioBase64);
await File.WriteAllBytesAsync("output.mp3", audioBytes);
Console.WriteLine($"✅ Audio saved! Duration: {response.Duration:F2}s");
// Print visemes if available
if (response.Visemes != null && response.Visemes.Count > 0)
{
Console.WriteLine($"📊 Visemes: {response.Visemes.Count} frames");
for (int i = 0; i < Math.Min(5, response.Visemes.Count); i++)
{
var viseme = response.Visemes[i];
Console.WriteLine($" - ID: {viseme.Id}, Offset: {viseme.OffsetMs}ms");
}
}
}
catch (LokutorApiException ex)
{
Console.WriteLine($"❌ API Error: {ex.Message} (Status: {ex.StatusCode})");
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error: {ex.Message}");
}
}
}
}