-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathProgram.cs
52 lines (44 loc) · 1.87 KB
/
Program.cs
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
// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
using Deepgram.Logger;
using Deepgram.Models.Listen.v1.REST;
namespace PreRecorded
{
class Program
{
static async Task Main(string[] args)
{
// Initialize Library with default logging
// Normal logging is "Info" level
//Library.Initialize();
// OR very chatty logging
Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose
// use the client factory with a API Key set with the "DEEPGRAM_API_KEY" environment variable
var deepgramClient = ClientFactory.CreateListenRESTClient();
// check to see if the file exists
if (!File.Exists(@"Bueller-Life-moves-pretty-fast.wav"))
{
Console.WriteLine("Error: File 'Bueller-Life-moves-pretty-fast.wav' not found.");
return;
}
// increase timeout to a very large value
CancellationTokenSource cancelToken = new CancellationTokenSource();
cancelToken.CancelAfter(3600000);
var audioData = File.ReadAllBytes(@"Bueller-Life-moves-pretty-fast.wav");
var response = await deepgramClient.TranscribeFile(
audioData,
new PreRecordedSchema()
{
Model = "nova-2",
Punctuate = true,
},
cancelToken);
Console.WriteLine($"\n\n{response}\n\n");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
// Teardown Library
Library.Terminate();
}
}
}