Skip to content

Commit

Permalink
Overhaul of API interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed Nov 13, 2024
1 parent 2252e30 commit 29d32d9
Show file tree
Hide file tree
Showing 96 changed files with 1,341 additions and 695 deletions.
2 changes: 1 addition & 1 deletion Documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ See the installation steps for the [Utilities.Audio](https://github.com/rageAgai
1. Clone or download the repository from the desired branch (master, preview/unstable)
2. Drag the package folder `UBhashini/UBhashini/Packages/com.uralstech.ubhashini` into your Unity project's `Packages` folder
3. In the `Packages` folder of your project, add the following line to the list in `manifest.json`:
`"com.uralstech.ubhashini": "1.x.x",`
`"com.uralstech.ubhashini": "2.x.x",`
4. Check the instructions for [`Utils.Singleton`](https://uralstech.github.io/Utils.Singleton) to install it.

*Adding additional dependencies:*<br/>
Expand Down
4 changes: 4 additions & 0 deletions UBhashini/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ crashlytics-build.properties
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# -------------------------------------------------------------------------------------------

/[Aa]ssets
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.ComponentModel;

namespace Uralstech.UBhashini.Data
{
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
/// <summary>
/// Language data for requests.
/// </summary>
public class BhashiniLanguageData
{
/// <summary>
/// [SET: REQUIRED] The source language of the data.
/// The source language of the data.
/// </summary>
public string SourceLanguage;
[JsonProperty("sourceLanguage")]
public string Source;

/// <summary>
/// [SET: OPTIONAL] Can be <see cref="string.Empty"/>; the target language of the data.
/// The target language of the data. For translation tasks.
/// </summary>
[DefaultValue("")]
public string TargetLanguage = string.Empty;

/// <summary>
/// [DO NOT SET] May be <see langword="null"/>; used in ConfigurePipeline responses.
/// </summary>
[DefaultValue(null)]
public string[] TargetLanguageList = null;

/// <summary>
/// [DO NOT SET] May be <see cref="string.Empty"/>; the iso-15924 script code of the resposne.
/// </summary>
[DefaultValue("")]
public string SourceScriptCode = string.Empty;
[JsonProperty("targetLanguage", NullValueHandling = NullValueHandling.Ignore)]
public string Target = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;

namespace Uralstech.UBhashini.Data
{
/// <summary>
/// The type of task a pipeline should compute.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum BhashiniPipelineTaskType
{
/// <summary>
/// Default value. Do not use.
/// </summary>
Default = 0,

/// <summary>
/// Speech To Text.
/// </summary>
[EnumMember(Value = "asr")]
SpeechToText,

/// <summary>
/// Translation.
/// </summary>
[EnumMember(Value = "translation")]
Translation,

/// <summary>
/// Text To Speech.
/// </summary>
[EnumMember(Value = "tts")]
TextToSpeech,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,38 @@ namespace Uralstech.UBhashini.Data
[JsonConverter(typeof(StringEnumConverter))]
public enum BhashiniVoiceType
{
UNSPECIFIED_UNKNOWN_DONTUSE_DEFAULT = -1,
/// <summary>
/// Default value. Do not use.
/// </summary>
Default = 0,

/// <summary>
/// Male voice.
/// </summary>
[EnumMember(Value = "male")]
Male,

/// <summary>
/// Female voice.
/// </summary>
[EnumMember(Value = "female")]
Female,

/// <summary>
/// Trans voice.
/// </summary>
[EnumMember(Value = "transgender")]
Transgender,

/// <summary>
/// Non specified voice.
/// </summary>
[EnumMember(Value = "non-specified")]
NonSpecified,

/// <summary>
/// Other voice.
/// </summary>
[EnumMember(Value = "others")]
Others,
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,43 @@
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;

namespace Uralstech.UBhashini.Data
namespace Uralstech.UBhashini.Data.Compute
{
/// <remarks>
/// These enum values were taken from <see href="https://app.swaggerhub.com/apis/ulca/ULCA/0.7.0">SwaggerHub</see> and only <see cref="Wav"/> is guaranteed to work.
/// </remarks>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonConverter(typeof(StringEnumConverter))]
public enum BhashiniAudioFormat
{
UNSPECIFIED_UNKNOWN_DONTUSE_DEFAULT,
/// <summary>
/// Default value. Do not use.
/// </summary>
Default = 0,

/// <summary>
/// WAV
/// </summary>
[EnumMember(Value = "wav")]
Wav,

/// <summary>
/// PCM
/// </summary>
[EnumMember(Value = "pcm")]
Pcm,

/// <summary>
/// MP3
/// </summary>
[EnumMember(Value = "mp3")]
Mp3,

/// <summary>
/// FLAC
/// </summary>
[EnumMember(Value = "flac")]
Flac
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.ComponentModel;

namespace Uralstech.UBhashini.Data.Compute
{
/// <summary>
/// Configuration for a computation task.
/// </summary>
public class BhashiniComputeConfiguration
{
/// <summary>
/// The service to use for computation.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("serviceId")]
public string ServiceId;

/// <summary>
/// The language of the computation.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("language")]
public BhashiniLanguageData Language;

/// <summary>
/// Only for STT requests. The format to encode the input audio in.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("audioFormat", DefaultValueHandling = DefaultValueHandling.Ignore), DefaultValue(BhashiniAudioFormat.Default)]
public BhashiniAudioFormat AudioFormat = BhashiniAudioFormat.Default;

/// <summary>
/// Only for STT requests. The sample rate of the input audio.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("samplingRate", DefaultValueHandling = DefaultValueHandling.Ignore), DefaultValue(0)]
public int SampleRate = 0;

/// <summary>
/// Only for TTS requests. The voice type.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("gender", DefaultValueHandling = DefaultValueHandling.Ignore), DefaultValue(BhashiniVoiceType.Default)]
public BhashiniVoiceType VoiceType = BhashiniVoiceType.Default;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Uralstech.UBhashini.Data.Compute
{
/// <summary>
/// Request for inferencing a pipeline. Response type is <see cref="BhashiniComputeResponse"/>.
/// </summary>
public class BhashiniComputeRequest
{
/// <summary>
/// The tasks to be carried out by the pipeline.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("pipelineTasks")]
public BhashiniComputeTask[] Tasks;

/// <summary>
/// The input for the pipeline.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("inputData")]
public BhashiniInputData Input;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Uralstech.UBhashini.Data.Compute
{
/// <summary>
/// A computation task for a pipeline.
/// </summary>
public class BhashiniComputeTask
{
/// <summary>
/// The task type.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("taskType")]
public BhashiniPipelineTaskType Type;

/// <summary>
/// The configuration for the task.
/// </summary>
/// <remarks>
/// <seealso href="https://bhashini.gitbook.io/bhashini-apis/pipeline-compute-call/request-payload"/>
/// </remarks>
[JsonProperty("config")]
public BhashiniComputeConfiguration Configuration;

/// <param name="type">The task type.</param>
public BhashiniComputeTask(BhashiniPipelineTaskType type)
{
Type = type;
}

/// <param name="type">The task type.</param>
/// <param name="configuration">The task configuration from a <see cref="Pipeline.BhashiniPipelineResponse"/>.</param>
public BhashiniComputeTask(BhashiniPipelineTaskType type, Pipeline.BhashiniPipelineTaskConfiguration configuration) : this(type)
{
Configuration = new BhashiniComputeConfiguration()
{
ServiceId = configuration.ServiceId,
Language = configuration.Language,
VoiceType = ((BhashiniVoiceType?)configuration.SupportedVoices?.GetValue(0)) ?? BhashiniVoiceType.Default,
};
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 29d32d9

Please sign in to comment.