-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat:Add language_detection_options to TranscriptOptionalParams #118
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #nullable enable | ||
|
|
||
| namespace AssemblyAI | ||
| { | ||
| public sealed partial class TranscriptOptionalParamsLanguageDetectionOptions | ||
| { | ||
| /// <summary> | ||
| /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. | ||
| /// </summary> | ||
| public string ToJson( | ||
| global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Serialize( | ||
| this, | ||
| this.GetType(), | ||
| jsonSerializerContext); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. | ||
| /// </summary> | ||
| #if NET8_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] | ||
| #endif | ||
| public string ToJson( | ||
| global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Serialize( | ||
| this, | ||
| jsonSerializerOptions); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON string using the provided JsonSerializerContext. | ||
| /// </summary> | ||
| public static global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions? FromJson( | ||
| string json, | ||
| global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Deserialize( | ||
| json, | ||
| typeof(global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions), | ||
| jsonSerializerContext) as global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON string using the provided JsonSerializerOptions. | ||
| /// </summary> | ||
| #if NET8_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] | ||
| #endif | ||
| public static global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions? FromJson( | ||
| string json, | ||
| global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Deserialize<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions>( | ||
| json, | ||
| jsonSerializerOptions); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON stream using the provided JsonSerializerContext. | ||
| /// </summary> | ||
| public static async global::System.Threading.Tasks.ValueTask<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions?> FromJsonStreamAsync( | ||
| global::System.IO.Stream jsonStream, | ||
| global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) | ||
| { | ||
| return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( | ||
| jsonStream, | ||
| typeof(global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions), | ||
| jsonSerializerContext).ConfigureAwait(false)) as global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON stream using the provided JsonSerializerOptions. | ||
| /// </summary> | ||
| #if NET8_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] | ||
| #endif | ||
| public static global::System.Threading.Tasks.ValueTask<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions?> FromJsonStreamAsync( | ||
| global::System.IO.Stream jsonStream, | ||
| global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions?>( | ||
| jsonStream, | ||
| jsonSerializerOptions); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace AssemblyAI | ||
| { | ||
| /// <summary> | ||
| /// Specify options for Automatic Language Detection. | ||
| /// </summary> | ||
| public sealed partial class TranscriptOptionalParamsLanguageDetectionOptions | ||
| { | ||
| /// <summary> | ||
| /// List of languages expected in the audio file. | ||
| /// </summary> | ||
| [global::System.Text.Json.Serialization.JsonPropertyName("expected_languages")] | ||
| public byte[]? ExpectedLanguages { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score.<br/> | ||
| /// Default Value: auto | ||
| /// </summary> | ||
| [global::System.Text.Json.Serialization.JsonPropertyName("fallback_language")] | ||
| public string? FallbackLanguage { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Additional properties that are not explicitly defined in the schema | ||
| /// </summary> | ||
| [global::System.Text.Json.Serialization.JsonExtensionData] | ||
| public global::System.Collections.Generic.IDictionary<string, object> AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary<string, object>(); | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="TranscriptOptionalParamsLanguageDetectionOptions" /> class. | ||
| /// </summary> | ||
| /// <param name="expectedLanguages"> | ||
| /// List of languages expected in the audio file. | ||
| /// </param> | ||
| /// <param name="fallbackLanguage"> | ||
| /// If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score.<br/> | ||
| /// Default Value: auto | ||
| /// </param> | ||
| #if NET7_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] | ||
| #endif | ||
| public TranscriptOptionalParamsLanguageDetectionOptions( | ||
| byte[]? expectedLanguages, | ||
| string? fallbackLanguage) | ||
| { | ||
| this.ExpectedLanguages = expectedLanguages; | ||
| this.FallbackLanguage = fallbackLanguage; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="TranscriptOptionalParamsLanguageDetectionOptions" /> class. | ||
| /// </summary> | ||
| public TranscriptOptionalParamsLanguageDetectionOptions() | ||
| { | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1253,6 +1253,26 @@ components: | |||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||
| default: false | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| language_detection_options: | ||||||||||||||||||||||||
| x-label: Specify options for Automatic Language Detection. | ||||||||||||||||||||||||
| description: Specify options for Automatic Language Detection. | ||||||||||||||||||||||||
| type: object | ||||||||||||||||||||||||
| additionalProperties: false | ||||||||||||||||||||||||
| properties: | ||||||||||||||||||||||||
| expected_languages: | ||||||||||||||||||||||||
| x-label: Minimum speakers expected | ||||||||||||||||||||||||
| description: List of languages expected in the audio file. | ||||||||||||||||||||||||
| type: array | ||||||||||||||||||||||||
| objects: | ||||||||||||||||||||||||
| x-label: language | ||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||
| fallback_language: | ||||||||||||||||||||||||
| x-label: Fallback language | ||||||||||||||||||||||||
| description: | | ||||||||||||||||||||||||
| If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score. | ||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||
| default: "auto" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+1270
to
+1275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc/type mismatch: fallback_language is a string but docs say ["auto"] The description instructs to set ["auto"], which contradicts the string type and default "auto". This will confuse users and SDK docs. Apply this diff to correct the guidance: fallback_language:
x-label: Fallback language
description: |
- If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score.
+ If the detected language of the audio file is not in `expected_languages`, this value is used. Specify `"auto"` to let our model choose a fallback from `expected_languages` with the highest confidence score.
type: string
default: "auto"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| language_confidence_threshold: | ||||||||||||||||||||||||
| x-label: Language confidence threshold | ||||||||||||||||||||||||
| description: | | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Array schema bug: use items, not objects, and type the array elements
In JSON Schema/OpenAPI, arrays must declare items, not objects. As written, expected_languages will fail validation and codegen.
Apply this diff to fix the array definition and strongly type elements:
📝 Committable suggestion
🤖 Prompt for AI Agents