Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds warning object #106

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Deepgram/Transcription/PrerecordedTranscriptionMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public class PrerecordedTranscriptionMetaData
/// Number of channels detected in the submitted audio.
/// </summary>
[JsonProperty("channels")]
public int Channels { get; set; }
public int Channels { get; set; }

/// <summary>
/// Warnings to provide feedback about unsupported and deprecated queries.
/// </summary>
[JsonProperty("warnings")]
public Warning[] Warnings { get; set; }
}
}
31 changes: 31 additions & 0 deletions Deepgram/Transcription/Warning.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Deepgram.Transcription
{
public class Warning
{
/// <summary>
/// Parameter sent in the request that resulted in the warning
/// </summary>
[JsonProperty("parameter")]
public string Parameter { get; set; }

/// <summary>
/// The type of warning
/// </summary>
[JsonProperty("type")]
[JsonConverter(typeof(StringEnumConverter))]
public WarningType Type { get; set; }

/// <summary>
/// The warning message
/// </summary>
[JsonProperty("message")]
public string Message { get; set; }

}
}


23 changes: 23 additions & 0 deletions Deepgram/Transcription/WarningType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Runtime.Serialization;

namespace Deepgram.Transcription
{
public enum WarningType

{
[EnumMember(Value = "unsupported_language")]
UnsupportedLanguage,

[EnumMember(Value = "unsupported_model")]
UnsupportedModel,

[EnumMember(Value = "unsupported_encoding")]
UnsupportedEncoding,

[EnumMember(Value = "deprecated")]
Deprecated
}
}


26 changes: 8 additions & 18 deletions SampleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,20 @@ namespace SampleApp
{
class Program
{
const string API_KEY = "YOUR_DEEPGRAM_API_KEY";
const string API_KEY = "";

static async Task Main(string[] args)
{
var credentials = new Credentials(API_KEY);
DeepgramClient deepgram = new DeepgramClient(credentials);

// UNCOMMENT IF USING LOCAL FILE:
// using (FileStream fs = File.OpenRead("preamble.wav"))
{
var response = await deepgram.Transcription.Prerecorded.GetTranscriptionAsync(
// UNCOMMENT IF USING LOCAL FILE:
// new Deepgram.Transcription.StreamSource(
// fs,
// "audio/wav"),
new Deepgram.Transcription.UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
{
DeepgramClient deepgram = new DeepgramClient(new Credentials(API_KEY));
var response = await deepgram.Transcription.Prerecorded.GetTranscriptionAsync(
new UrlSource("https://www.happyhourspanish.com/wp-content/uploads/podcasts/HHS_Podcast_Soccer_Eurocup.mp3"),
new PrerecordedTranscriptionOptions()
{
Punctuate = true,
Utterances = true,
Summarize = "v2",
DetectLanguage = true
});

Console.WriteLine(JsonConvert.SerializeObject(response));
}
Console.WriteLine(JsonConvert.SerializeObject(response));
}
}
}
2 changes: 1 addition & 1 deletion SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down