-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat:Add language_detection_options to TranscriptOptionalParams #119
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
+1274
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. Documentation/type mismatch: fallback_language description suggests an array, but the type is string. The text says to specify ["auto"], but the schema defines a string. This will confuse users and SDKs. Apply this diff: 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 the list of expected languages, the `fallback_language` is used. Set to "auto" to let our model choose the fallback language from `expected_languages` with the highest confidence score.
type: string
default: "auto"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+1256
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. 💡 Verification agent 🧩 Analysis chainQuick validation checks for this spec block. Run this script to ensure we’ve eliminated the invalid "objects" key, corrected the "auto" guidance, and that the YAML still parses. 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1) Fail if any invalid 'objects:' key remains
if rg -n "^\s*objects\s*:" -C2 src/libs/AssemblyAI/openapi.yaml; then
echo "ERROR: Found invalid 'objects:' key under an array schema."
exit 1
else
echo "OK: No 'objects:' keys found."
fi
# 2) Fail if docs still suggest [\"auto\"] (array) for a string field
if rg -n '\["auto"\]' src/libs/AssemblyAI/openapi.yaml; then
echo 'ERROR: Found ["auto"] in fallback_language description.'
exit 1
else
echo 'OK: No ["auto"] mention found.'
fi
# 3) Basic YAML parse sanity check
python - <<'PY'
import yaml, sys
with open("src/libs/AssemblyAI/openapi.yaml", "r") as f:
yaml.safe_load(f)
print("OK: YAML parsed successfully.")
PYLength of output: 434 AssemblyAI OpenAPI Spec: Remove Invalid The validation script still detects an Please update • File: After making that change, re-run the validation script to confirm: #!/bin/bash
set -euo pipefail
# Check for any remaining invalid 'objects:' occurrences
rg -n "^\s*objects\s*:" -C2 src/libs/AssemblyAI/openapi.yaml && \
(echo "ERROR: 'objects:' key still present"; exit 1) || \
echo "OK: No 'objects:' keys found."
# Confirm no array-style ["auto"] guidance remains
rg -n '\["auto"\]' src/libs/AssemblyAI/openapi.yaml && \
(echo "ERROR: Found [\"auto\"] in description"; exit 1) || \
echo "OK: No [\"auto\"] mention found."
# Verify YAML parses
python - <<'PY'
import yaml
yaml.safe_load(open("src/libs/AssemblyAI/openapi.yaml"))
print("OK: YAML parsed successfully.")
PYOnce the 🤖 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.
Fix invalid OpenAPI array schema: replace "objects" with "items" and correct the field label.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents