MCPcopy Create free account
hub / github.com/HumeAI/hume-api-examples / Program

Class Program

tts/tts-dotnet-quickstart/Program.cs:16–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace TtsCsharpQuickstart;
15
16class Program
17{
18 // Constants
19 private const string HumeApiKey = "HUME_API_KEY";
20 public const string DefaultVoiceName = "Ava Song";
21 public const string Example1Text = "Dogs became domesticated between 23,000 and 30,000 years ago.";
22 private const int VoiceCreationDelaySeconds = 8;
23
24 private static string? _apiKey;
25 private static HumeClient? _client;
26
27 public static PostedTts Example1RequestParams => new PostedTts
28 {
29 Utterances = new List<PostedUtterance>
30 {
31 new PostedUtterance
32 {
33 Text = Example1Text,
34 Voice = new PostedUtteranceVoiceWithName
35 {
36 Name = DefaultVoiceName,
37 Provider = new VoiceProvider(VoiceProvider.Values.HumeAi)
38 }
39 }
40 },
41 // With `stripHeaders: true`, only the first audio chunk will contain
42 // headers in container formats (wav, mp3). This allows you to start a
43 // single audio player and stream all audio chunks to it without artifacts.
44 StripHeaders = true,
45 };
46
47 static async Task RunExamplesAsync()
48 {
49 // Get the API key from .env file
50 Env.Load();
51
52 Console.WriteLine("Starting...");
53
54 _apiKey = Environment.GetEnvironmentVariable(HumeApiKey);
55 if (string.IsNullOrEmpty(_apiKey))
56 {
57 throw new InvalidOperationException($"{HumeApiKey} not found in environment variables.");
58 }
59
60 _client = new HumeClient(_apiKey);
61
62 await Example1Async();
63 await Example2Async();
64 await Example3Async();
65
66 Console.WriteLine("Done");
67 }
68
69 static async Task Main(string[] args)
70 {
71 await RunExamplesAsync();
72 }
73

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected