GirlSaysHello

 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
using var client = new HedraClient(apiKey);

// Example usage
// 1. Upload audio
// audio_response = requests.post(f"{BASE_URL}/v1/audio", headers={'X-API-KEY': API_KEY}, files={'file': open('audio.mp3','rb')})
// 
// 2. Upload image
// image_response = requests.post(f"{BASE_URL}/v1/portrait", headers={'X-API-KEY': API_KEY}, files={'file': open('img.png','rb')})
// 
// 3. Generate character video
// video_response = requests.post(f"{BASE_URL}/v1/characters", headers={'X-API-KEY': API_KEY}, json={"avatarImage": image_response.json()["url"], "audioSource": "audio", "voiceUrl": audio_response.json()["url"]})
// 
// 4. Call the Project endpoint to see your project / job status and get access to the URL of your generated character.
// project_status = requests.get(f"{BASE_URL}/v1/projects/{project_id}", headers={'X-API-KEY': API_KEY})

UploadAudioResponseBody uploadAudio = await client.Audio.UploadAudioAsync(
    file: H.Resources.hello_wav.AsBytes(),
    filename: H.Resources.hello_wav.FileName);


UploadAudioResponseBody uploadImage = await client.Portrait.UploadImageAsync(
    file: H.Resources.girl_png.AsBytes(),
    filename: H.Resources.girl_png.FileName);


ApiProjectInitializationResponseBody initializeCharacter = await client.Characters.InitializeCharacterGenerationAsync(
    audioSource: ApiGenerateTalkingAvatarRequestBodyAudioSource.Audio,
    avatarImage: uploadImage.Url,
    voiceUrl: uploadAudio.Url);


Console.WriteLine($"JobId: {initializeCharacter.JobId}");

AvatarProjectItem projectStatus;
do
{
    await Task.Delay(TimeSpan.FromSeconds(5));

    projectStatus = await client.Projects.GetProjectAsync(
        projectId: initializeCharacter.JobId);
}
while (projectStatus.VideoUrl == null && projectStatus.ErrorMessage == null);


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