Skip to content

Commit

Permalink
Merge pull request #46 from deepgram/translation
Browse files Browse the repository at this point in the history
Adding translation feature
  • Loading branch information
michaeljolley authored Oct 6, 2022
2 parents 28f9975 + bacbe49 commit e1c56a7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Deepgram/Transcription/Alternative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@ public class Alternative
/// <remark>Only used when the detect entities feature is enabled on the request</remark>
[JsonProperty("entities")]
public Entity[] Entities { get; set; }

/// <summary>
/// Array of Translation objects.
/// </summary>
/// <remark>Only used when the translation feature is enabled on the request</remark>
[JsonProperty("translations")]
public Translation[] Translations { get; set; }
}
}
13 changes: 10 additions & 3 deletions Deepgram/Transcription/PrerecordedTranscriptionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ public class PrerecordedTranscriptionOptions
/// Terms or phrases to search for in the submitted audio.
/// </summary>
[JsonProperty("search")]
public string[] SearchTerms { get; set; }
public string[] SearchTerms { get; set; } = null;

/// <summary>
/// Terms or phrases to search for in the submitted audio and replace.
/// </summary>
/// <remarks>Phrases should be submitted in the format: searchfor:replacewith</remarks>
[JsonProperty("replace")]
public string[] Replace { get; set; }
public string[] Replace { get; set; } = null;

/// <summary>
/// Callback URL to provide if you would like your submitted audio to be processed asynchronously.
Expand All @@ -114,7 +114,7 @@ public class PrerecordedTranscriptionOptions
/// it understand context.
/// </summary>
[JsonProperty("keywords")]
public string[] Keywords { get; set; }
public string[] Keywords { get; set; } = null;

/// <summary>
/// Indicates whether Deepgram will segment speech into meaningful semantic units, which allows
Expand Down Expand Up @@ -156,6 +156,13 @@ public class PrerecordedTranscriptionOptions
[JsonProperty("detect_entities")]
public Nullable<bool> DetectEntities { get; set; } = null;

/// <summary>
/// Language codes to which transcripts should be translated to.
/// </summary>
/// <remarks>If a provided language code matches the language code of the request, an error will be thrown.</remarks>
[JsonProperty("translation")]
public string[] Translation { get; set; } = null;

/// <summary>
/// Indicates whether Deepgram should detect topics within the provided audio.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions Deepgram/Transcription/Translation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using Newtonsoft.Json;

namespace Deepgram.Transcription
{
public class Translation
{
/// <summary>
/// Translated transcript.
/// </summary>
[JsonProperty("translation")]
public string TranslatedTranscript { get; set; }

/// <summary>
/// Language code of the translation.
/// </summary>
[JsonProperty("language")]
public string Language { get; set; }
}
}
6 changes: 6 additions & 0 deletions Deepgram/Usage/GetUsageSummaryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ public class GetUsageSummaryOptions
[JsonProperty("summarize")]
public Nullable<bool> Summarize { get; set; } = null;

/// <summary>
/// Limits results to requests that include the translation feature.
/// </summary>
[JsonProperty("translation")]
public Nullable<bool> Translation { get; set; } = null;

/// <summary>
/// Limits results to requests that include the topic detection feature.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions Deepgram/Usage/UsageRequestResponseConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public class UsageRequestResponseConfig
[JsonProperty("utterances")]
public Nullable<bool> Utterances { get; set; } = null;

/// <summary>
/// Array of translations associated with the request.
/// </summary>
[JsonProperty("translation")]
public string[] Translation { get; set; } = null;

/// <summary>
/// Indicates whether topic detection was requested.
/// </summary>
Expand Down

0 comments on commit e1c56a7

Please sign in to comment.