Skip to content

Commit

Permalink
Merge pull request #106 from deepgram/sr/sumv2-ga-prep
Browse files Browse the repository at this point in the history
adds warning object
  • Loading branch information
SandraRodgers authored Jul 19, 2023
2 parents 8e7c302 + 264349f commit c764603
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 20 deletions.
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

0 comments on commit c764603

Please sign in to comment.