Skip to content

Girl Says Hello

Upload audio and image, generate a talking avatar video, and poll for completion.

This example assumes using Hedra; is in scope and apiKey contains your Hedra API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using var client = new HedraClient(apiKey);

// 1. List available models to get a valid model ID
var models = await client.ListModelsAsync();

var model = models.First();
var modelId = Guid.Parse(model.Id);
Console.WriteLine($"Using model: {modelId}");

// 2. Create and upload an audio asset
CreateAssetResponse audioAsset = await client.CreateAssetAsync(
    name: H.Resources.hello_wav.FileName,
    type: AssetType.Audio);

Asset uploadedAudio = await client.UploadAssetAsync(
    id: audioAsset.Id,
    file: Convert.ToBase64String(
        H.Resources.hello_wav.AsBytes()));

// 3. Create and upload an image asset
CreateAssetResponse imageAsset = await client.CreateAssetAsync(
    name: H.Resources.girl_png.FileName,
    type: AssetType.Image);

Asset uploadedImage = await client.UploadAssetAsync(
    id: imageAsset.Id,
    file: Convert.ToBase64String(
        H.Resources.girl_png.AsBytes()));

// 4. Generate a talking avatar video
GenerateAssetPublicGenerationsPostResponse generation = await client.GenerateAssetAsync(
    request: new GenerateVideoRequestInput
    {
        AiModelId = modelId,
        StartKeyframeId = imageAsset.Id,
        AudioId = audioAsset.Id,
        GeneratedVideoInputs = new GeneratedVideoInputs
        {
            TextPrompt = "A girl saying hello",
        },
    });

Guid generationId = generation.Video!.Id;
Console.WriteLine($"Generation ID: {generationId}");

// 5. Poll for completion
GenerationStatusResponse status;
do
{
    await Task.Delay(TimeSpan.FromSeconds(5));

    status = await client.GetStatusAsync(
        generationId: generationId);
}
while (status.Status is not (GenerationStatus.Complete or GenerationStatus.Error));

if (status.ErrorMessage != null)
{
    Console.WriteLine($"Error: {status.ErrorMessage}");
}

Console.WriteLine(status.Url);