diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/Azure.AI.SpeechToText.BatchTranscription.sln b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/Azure.AI.SpeechToText.BatchTranscription.sln new file mode 100644 index 000000000000..128b1570c531 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/Azure.AI.SpeechToText.BatchTranscription.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.SpeechToText.BatchTranscription", "src\Azure.AI.SpeechToText.BatchTranscription.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.SpeechToText.BatchTranscription.Tests", "tests\Azure.AI.SpeechToText.BatchTranscription.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/CHANGELOG.md b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/Directory.Build.props b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/README.md b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/README.md new file mode 100644 index 000000000000..dcf0eb3edee2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/README.md @@ -0,0 +1,107 @@ +# Azure.AI.SpeechToText.BatchTranscription client library for .NET + +Azure.AI.SpeechToText.BatchTranscription is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.AI.SpeechToText.BatchTranscription --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +### Service API versions + +The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version. + +For example, + +```C# Snippet:CreateClientForSpecificApiVersion +Uri endpoint = new Uri(""); +DefaultAzureCredential credential = new DefaultAzureCredential(); +ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.) +var client = new Client(endpoint, credential, options); +``` + +When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/README.png) \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/api/Azure.AI.SpeechToText.BatchTranscription.net8.0.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/api/Azure.AI.SpeechToText.BatchTranscription.net8.0.cs new file mode 100644 index 000000000000..a699711daf85 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/api/Azure.AI.SpeechToText.BatchTranscription.net8.0.cs @@ -0,0 +1,348 @@ +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public static partial class AISpeechToTextBatchTranscriptionModelFactory + { + public static Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription AsynchronousTranscription(Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks links = null, Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties properties = null, System.Uri self = null, Azure.AI.SpeechToText.BatchTranscription.EntityReference model = null, Azure.AI.SpeechToText.BatchTranscription.EntityReference dataset = null, System.Collections.Generic.IEnumerable contentUrls = null, System.Uri contentContainerUrl = null, string locale = null, string displayName = null, string description = null, System.Collections.Generic.IDictionary customProperties = null, System.DateTimeOffset? lastActionDateTime = default(System.DateTimeOffset?), Azure.AI.SpeechToText.BatchTranscription.ApiStatus? status = default(Azure.AI.SpeechToText.BatchTranscription.ApiStatus?), System.DateTimeOffset? createdDateTime = default(System.DateTimeOffset?)) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.EntityError EntityError(string code = null, string message = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.FileLinks FileLinks(System.Uri contentUrl = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.FileProperties FileProperties(int durationMilliseconds = 0, int size = 0) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.PageableFile PageableFile(System.Collections.Generic.IEnumerable values = null, System.Uri nextLink = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.PageableTranscription PageableTranscription(System.Collections.Generic.IEnumerable values = null, System.Uri nextLink = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.TranscriptionFile TranscriptionFile(System.DateTimeOffset createdDateTime = default(System.DateTimeOffset), Azure.AI.SpeechToText.BatchTranscription.FileKind kind = default(Azure.AI.SpeechToText.BatchTranscription.FileKind), Azure.AI.SpeechToText.BatchTranscription.FileLinks links = null, string name = null, Azure.AI.SpeechToText.BatchTranscription.FileProperties properties = null, System.Uri self = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks TranscriptionLinks(System.Uri files = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties TranscriptionProperties(bool? wordLevelTimestampsEnabled = default(bool?), bool? displayFormWordLevelTimestampsEnabled = default(bool?), int? durationMilliseconds = default(int?), System.Collections.Generic.IEnumerable channels = null, System.Uri destinationContainerUrl = null, Azure.AI.SpeechToText.BatchTranscription.PunctuationMode? punctuationMode = default(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode?), Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode? profanityFilterMode = default(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode?), int timeToLiveHours = 0, Azure.AI.SpeechToText.BatchTranscription.EntityError error = null, Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties diarization = null, Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties languageIdentification = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ApiStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ApiStatus(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus Failed { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus NotStarted { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus Running { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus Succeeded { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.ApiStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.ApiStatus left, Azure.AI.SpeechToText.BatchTranscription.ApiStatus right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.ApiStatus (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.ApiStatus left, Azure.AI.SpeechToText.BatchTranscription.ApiStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AsynchronousTranscription : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AsynchronousTranscription(Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties properties, string locale, string displayName) { } + public System.Uri ContentContainerUrl { get { throw null; } set { } } + public System.Collections.Generic.IList ContentUrls { get { throw null; } } + public System.DateTimeOffset? CreatedDateTime { get { throw null; } } + public System.Collections.Generic.IDictionary CustomProperties { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.EntityReference Dataset { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public System.DateTimeOffset? LastActionDateTime { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks Links { get { throw null; } set { } } + public string Locale { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.EntityReference Model { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties Properties { get { throw null; } set { } } + public System.Uri Self { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.ApiStatus? Status { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BatchTranscription + { + protected BatchTranscription() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response DeleteTranscription(string id, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task DeleteTranscriptionAsync(string id, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response GetTranscription(string id, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTranscription(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTranscriptionAsync(string id, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTranscriptionAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTranscriptionFiles(string id, int? skip, int? top, int? sasLifetimeMinutes, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTranscriptionFiles(string id, int? skip = default(int?), int? top = default(int?), int? sasLifetimeMinutes = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTranscriptionFilesAsync(string id, int? skip, int? top, int? sasLifetimeMinutes, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTranscriptionFilesAsync(string id, int? skip = default(int?), int? top = default(int?), int? sasLifetimeMinutes = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTranscriptions(int? skip, int? top, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTranscriptions(int? skip = default(int?), int? top = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTranscriptionsAsync(int? skip, int? top, string filter, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTranscriptionsAsync(int? skip = default(int?), int? top = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PatchTranscription(string id, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task PatchTranscriptionAsync(string id, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response SubmitTranscription(Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription transcription, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SubmitTranscription(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> SubmitTranscriptionAsync(Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription transcription, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task SubmitTranscriptionAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + } + public partial class ClientCustomizations + { + protected ClientCustomizations() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + } + public partial class DiarizationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public DiarizationProperties(bool enabled, int maxSpeakers) { } + public bool Enabled { get { throw null; } set { } } + public int MaxSpeakers { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EntityError : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EntityError() { } + public string Code { get { throw null; } } + public string Message { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityError System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityError System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EntityReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EntityReference(System.Uri self) { } + public System.Uri Self { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct FileKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public FileKind(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind AcousticDataArchive { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind AcousticDataTranscriptionV2 { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind Audio { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind DatasetReport { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind EvaluationDetails { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind LanguageData { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind ModelReport { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind OutputFormattingData { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind PronunciationData { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind Transcription { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind TranscriptionReport { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.FileKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.FileKind left, Azure.AI.SpeechToText.BatchTranscription.FileKind right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.FileKind (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.FileKind left, Azure.AI.SpeechToText.BatchTranscription.FileKind right) { throw null; } + public override string ToString() { throw null; } + } + public partial class FileLinks : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal FileLinks() { } + public System.Uri ContentUrl { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileLinks System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileLinks System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class FileProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal FileProperties() { } + public int DurationMilliseconds { get { throw null; } } + public int Size { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct LanguageIdentificationMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public LanguageIdentificationMode(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode Continuous { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode Single { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode left, Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode left, Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode right) { throw null; } + public override string ToString() { throw null; } + } + public partial class LanguageIdentificationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LanguageIdentificationProperties(System.Collections.Generic.IEnumerable candidateLocales) { } + public System.Collections.Generic.IList CandidateLocales { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode? Mode { get { throw null; } set { } } + public System.Collections.Generic.IDictionary SpeechModelMapping { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PageableFile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal PageableFile() { } + public System.Uri NextLink { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Values { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableFile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableFile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PageableTranscription : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal PageableTranscription() { } + public System.Uri NextLink { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Values { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableTranscription System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableTranscription System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ProfanityFilterMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ProfanityFilterMode(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode Masked { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode None { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode Removed { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode Tags { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct PunctuationMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public PunctuationMode(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode Automatic { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode Dictated { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode DictatedAndAutomatic { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode None { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode left, Azure.AI.SpeechToText.BatchTranscription.PunctuationMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.PunctuationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode left, Azure.AI.SpeechToText.BatchTranscription.PunctuationMode right) { throw null; } + public override string ToString() { throw null; } + } + public enum ServiceApiVersions + { + V20241115 = 0, + } + public partial class SpeechToTextClient + { + protected SpeechToTextClient() { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.SpeechToText.BatchTranscription.SpeechToTextClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.AI.SpeechToText.BatchTranscription.BatchTranscription GetBatchTranscriptionClient(Azure.AI.SpeechToText.BatchTranscription.ServiceApiVersions? serviceApiVersionsQueryParameter = default(Azure.AI.SpeechToText.BatchTranscription.ServiceApiVersions?)) { throw null; } + public virtual Azure.AI.SpeechToText.BatchTranscription.ClientCustomizations GetClientCustomizationsClient() { throw null; } + } + public partial class SpeechToTextClientOptions : Azure.Core.ClientOptions + { + public SpeechToTextClientOptions(Azure.AI.SpeechToText.BatchTranscription.SpeechToTextClientOptions.ServiceVersion version = Azure.AI.SpeechToText.BatchTranscription.SpeechToTextClientOptions.ServiceVersion.V2024_11_15) { } + public Azure.AI.SpeechToText.BatchTranscription.ServiceApiVersions? ServiceApiVersionsQueryParameter { get { throw null; } set { } } + public enum ServiceVersion + { + V2024_05_15_Preview = 1, + V2024_11_15 = 2, + } + } + public partial class TranscriptionFile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscriptionFile() { } + public System.DateTimeOffset CreatedDateTime { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.FileKind Kind { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.FileLinks Links { get { throw null; } } + public string Name { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.FileProperties Properties { get { throw null; } } + public System.Uri Self { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionFile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionFile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscriptionLinks : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscriptionLinks() { } + public System.Uri Files { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscriptionProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscriptionProperties(int timeToLiveHours) { } + public System.Collections.Generic.IList Channels { get { throw null; } } + public System.Uri DestinationContainerUrl { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties Diarization { get { throw null; } set { } } + public bool? DisplayFormWordLevelTimestampsEnabled { get { throw null; } set { } } + public int? DurationMilliseconds { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.EntityError Error { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties LanguageIdentification { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode? ProfanityFilterMode { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.PunctuationMode? PunctuationMode { get { throw null; } set { } } + public int TimeToLiveHours { get { throw null; } set { } } + public bool? WordLevelTimestampsEnabled { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AISpeechToTextBatchTranscriptionClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/api/Azure.AI.SpeechToText.BatchTranscription.netstandard2.0.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/api/Azure.AI.SpeechToText.BatchTranscription.netstandard2.0.cs new file mode 100644 index 000000000000..a699711daf85 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/api/Azure.AI.SpeechToText.BatchTranscription.netstandard2.0.cs @@ -0,0 +1,348 @@ +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public static partial class AISpeechToTextBatchTranscriptionModelFactory + { + public static Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription AsynchronousTranscription(Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks links = null, Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties properties = null, System.Uri self = null, Azure.AI.SpeechToText.BatchTranscription.EntityReference model = null, Azure.AI.SpeechToText.BatchTranscription.EntityReference dataset = null, System.Collections.Generic.IEnumerable contentUrls = null, System.Uri contentContainerUrl = null, string locale = null, string displayName = null, string description = null, System.Collections.Generic.IDictionary customProperties = null, System.DateTimeOffset? lastActionDateTime = default(System.DateTimeOffset?), Azure.AI.SpeechToText.BatchTranscription.ApiStatus? status = default(Azure.AI.SpeechToText.BatchTranscription.ApiStatus?), System.DateTimeOffset? createdDateTime = default(System.DateTimeOffset?)) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.EntityError EntityError(string code = null, string message = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.FileLinks FileLinks(System.Uri contentUrl = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.FileProperties FileProperties(int durationMilliseconds = 0, int size = 0) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.PageableFile PageableFile(System.Collections.Generic.IEnumerable values = null, System.Uri nextLink = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.PageableTranscription PageableTranscription(System.Collections.Generic.IEnumerable values = null, System.Uri nextLink = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.TranscriptionFile TranscriptionFile(System.DateTimeOffset createdDateTime = default(System.DateTimeOffset), Azure.AI.SpeechToText.BatchTranscription.FileKind kind = default(Azure.AI.SpeechToText.BatchTranscription.FileKind), Azure.AI.SpeechToText.BatchTranscription.FileLinks links = null, string name = null, Azure.AI.SpeechToText.BatchTranscription.FileProperties properties = null, System.Uri self = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks TranscriptionLinks(System.Uri files = null) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties TranscriptionProperties(bool? wordLevelTimestampsEnabled = default(bool?), bool? displayFormWordLevelTimestampsEnabled = default(bool?), int? durationMilliseconds = default(int?), System.Collections.Generic.IEnumerable channels = null, System.Uri destinationContainerUrl = null, Azure.AI.SpeechToText.BatchTranscription.PunctuationMode? punctuationMode = default(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode?), Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode? profanityFilterMode = default(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode?), int timeToLiveHours = 0, Azure.AI.SpeechToText.BatchTranscription.EntityError error = null, Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties diarization = null, Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties languageIdentification = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ApiStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ApiStatus(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus Failed { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus NotStarted { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus Running { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ApiStatus Succeeded { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.ApiStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.ApiStatus left, Azure.AI.SpeechToText.BatchTranscription.ApiStatus right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.ApiStatus (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.ApiStatus left, Azure.AI.SpeechToText.BatchTranscription.ApiStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AsynchronousTranscription : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AsynchronousTranscription(Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties properties, string locale, string displayName) { } + public System.Uri ContentContainerUrl { get { throw null; } set { } } + public System.Collections.Generic.IList ContentUrls { get { throw null; } } + public System.DateTimeOffset? CreatedDateTime { get { throw null; } } + public System.Collections.Generic.IDictionary CustomProperties { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.EntityReference Dataset { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public System.DateTimeOffset? LastActionDateTime { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks Links { get { throw null; } set { } } + public string Locale { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.EntityReference Model { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties Properties { get { throw null; } set { } } + public System.Uri Self { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.ApiStatus? Status { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BatchTranscription + { + protected BatchTranscription() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response DeleteTranscription(string id, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task DeleteTranscriptionAsync(string id, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response GetTranscription(string id, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTranscription(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTranscriptionAsync(string id, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTranscriptionAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTranscriptionFiles(string id, int? skip, int? top, int? sasLifetimeMinutes, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTranscriptionFiles(string id, int? skip = default(int?), int? top = default(int?), int? sasLifetimeMinutes = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTranscriptionFilesAsync(string id, int? skip, int? top, int? sasLifetimeMinutes, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTranscriptionFilesAsync(string id, int? skip = default(int?), int? top = default(int?), int? sasLifetimeMinutes = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTranscriptions(int? skip, int? top, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetTranscriptions(int? skip = default(int?), int? top = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetTranscriptionsAsync(int? skip, int? top, string filter, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetTranscriptionsAsync(int? skip = default(int?), int? top = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PatchTranscription(string id, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task PatchTranscriptionAsync(string id, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response SubmitTranscription(Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription transcription, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SubmitTranscription(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> SubmitTranscriptionAsync(Azure.AI.SpeechToText.BatchTranscription.AsynchronousTranscription transcription, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task SubmitTranscriptionAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + } + public partial class ClientCustomizations + { + protected ClientCustomizations() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + } + public partial class DiarizationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public DiarizationProperties(bool enabled, int maxSpeakers) { } + public bool Enabled { get { throw null; } set { } } + public int MaxSpeakers { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EntityError : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EntityError() { } + public string Code { get { throw null; } } + public string Message { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityError System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityError System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EntityReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EntityReference(System.Uri self) { } + public System.Uri Self { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.EntityReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct FileKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public FileKind(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind AcousticDataArchive { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind AcousticDataTranscriptionV2 { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind Audio { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind DatasetReport { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind EvaluationDetails { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind LanguageData { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind ModelReport { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind OutputFormattingData { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind PronunciationData { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind Transcription { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.FileKind TranscriptionReport { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.FileKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.FileKind left, Azure.AI.SpeechToText.BatchTranscription.FileKind right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.FileKind (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.FileKind left, Azure.AI.SpeechToText.BatchTranscription.FileKind right) { throw null; } + public override string ToString() { throw null; } + } + public partial class FileLinks : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal FileLinks() { } + public System.Uri ContentUrl { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileLinks System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileLinks System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class FileProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal FileProperties() { } + public int DurationMilliseconds { get { throw null; } } + public int Size { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.FileProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct LanguageIdentificationMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public LanguageIdentificationMode(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode Continuous { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode Single { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode left, Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode left, Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode right) { throw null; } + public override string ToString() { throw null; } + } + public partial class LanguageIdentificationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LanguageIdentificationProperties(System.Collections.Generic.IEnumerable candidateLocales) { } + public System.Collections.Generic.IList CandidateLocales { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationMode? Mode { get { throw null; } set { } } + public System.Collections.Generic.IDictionary SpeechModelMapping { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PageableFile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal PageableFile() { } + public System.Uri NextLink { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Values { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableFile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableFile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PageableTranscription : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal PageableTranscription() { } + public System.Uri NextLink { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Values { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableTranscription System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.PageableTranscription System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ProfanityFilterMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ProfanityFilterMode(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode Masked { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode None { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode Removed { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode Tags { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct PunctuationMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public PunctuationMode(string value) { throw null; } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode Automatic { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode Dictated { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode DictatedAndAutomatic { get { throw null; } } + public static Azure.AI.SpeechToText.BatchTranscription.PunctuationMode None { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode left, Azure.AI.SpeechToText.BatchTranscription.PunctuationMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.BatchTranscription.PunctuationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.BatchTranscription.PunctuationMode left, Azure.AI.SpeechToText.BatchTranscription.PunctuationMode right) { throw null; } + public override string ToString() { throw null; } + } + public enum ServiceApiVersions + { + V20241115 = 0, + } + public partial class SpeechToTextClient + { + protected SpeechToTextClient() { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.SpeechToText.BatchTranscription.SpeechToTextClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.AI.SpeechToText.BatchTranscription.BatchTranscription GetBatchTranscriptionClient(Azure.AI.SpeechToText.BatchTranscription.ServiceApiVersions? serviceApiVersionsQueryParameter = default(Azure.AI.SpeechToText.BatchTranscription.ServiceApiVersions?)) { throw null; } + public virtual Azure.AI.SpeechToText.BatchTranscription.ClientCustomizations GetClientCustomizationsClient() { throw null; } + } + public partial class SpeechToTextClientOptions : Azure.Core.ClientOptions + { + public SpeechToTextClientOptions(Azure.AI.SpeechToText.BatchTranscription.SpeechToTextClientOptions.ServiceVersion version = Azure.AI.SpeechToText.BatchTranscription.SpeechToTextClientOptions.ServiceVersion.V2024_11_15) { } + public Azure.AI.SpeechToText.BatchTranscription.ServiceApiVersions? ServiceApiVersionsQueryParameter { get { throw null; } set { } } + public enum ServiceVersion + { + V2024_05_15_Preview = 1, + V2024_11_15 = 2, + } + } + public partial class TranscriptionFile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscriptionFile() { } + public System.DateTimeOffset CreatedDateTime { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.FileKind Kind { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.FileLinks Links { get { throw null; } } + public string Name { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.FileProperties Properties { get { throw null; } } + public System.Uri Self { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionFile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionFile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscriptionLinks : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscriptionLinks() { } + public System.Uri Files { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionLinks System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscriptionProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscriptionProperties(int timeToLiveHours) { } + public System.Collections.Generic.IList Channels { get { throw null; } } + public System.Uri DestinationContainerUrl { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.DiarizationProperties Diarization { get { throw null; } set { } } + public bool? DisplayFormWordLevelTimestampsEnabled { get { throw null; } set { } } + public int? DurationMilliseconds { get { throw null; } } + public Azure.AI.SpeechToText.BatchTranscription.EntityError Error { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.LanguageIdentificationProperties LanguageIdentification { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.ProfanityFilterMode? ProfanityFilterMode { get { throw null; } set { } } + public Azure.AI.SpeechToText.BatchTranscription.PunctuationMode? PunctuationMode { get { throw null; } set { } } + public int TimeToLiveHours { get { throw null; } set { } } + public bool? WordLevelTimestampsEnabled { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.BatchTranscription.TranscriptionProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AISpeechToTextBatchTranscriptionClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Azure.AI.SpeechToText.BatchTranscription.csproj b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Azure.AI.SpeechToText.BatchTranscription.csproj new file mode 100644 index 000000000000..7982ee4fee11 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Azure.AI.SpeechToText.BatchTranscription.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.SpeechToText.BatchTranscription client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.SpeechToText.BatchTranscription for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.SpeechToText.BatchTranscription + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AISpeechToTextBatchTranscriptionClientBuilderExtensions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AISpeechToTextBatchTranscriptionClientBuilderExtensions.cs new file mode 100644 index 000000000000..65dc8d9993ac --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AISpeechToTextBatchTranscriptionClientBuilderExtensions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.AI.SpeechToText.BatchTranscription; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AISpeechToTextBatchTranscriptionClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new SpeechToTextClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AISpeechToTextBatchTranscriptionModelFactory.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AISpeechToTextBatchTranscriptionModelFactory.cs new file mode 100644 index 000000000000..45cdd3222801 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AISpeechToTextBatchTranscriptionModelFactory.cs @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Model factory for models. + public static partial class AISpeechToTextBatchTranscriptionModelFactory + { + /// Initializes a new instance of . + /// TranscriptionLinks. + /// TranscriptionProperties. + /// The location of this entity. + /// EntityReference. + /// EntityReference. + /// + /// A list of content urls to get audio files to transcribe. Up to 1000 urls are allowed. + /// This property will not be returned in a response. + /// + /// + /// A URL for an Azure blob container that contains the audio files. A container is allowed to have a maximum size of 5GB and a maximum number of 10000 blobs. + /// The maximum size for a blob is 2.5GB. + /// Container SAS should contain 'r' (read) and 'l' (list) permissions. + /// This property will not be returned in a response. + /// + /// The locale of the contained data. If Language Identification is used, this locale is used to transcribe speech for which no language could be detected. + /// The display name of the object. + /// The description of the object. + /// + /// The custom properties of this entity. The maximum allowed key length is 64 characters, the maximum + /// allowed value length is 256 characters and the count of allowed entries is 10. + /// + /// + /// The time-stamp when the current status was entered. + /// The time stamp is encoded as ISO 8601 date and time format + /// ("YYYY-MM-DDThh:mm:ssZ", see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// + /// The status of the object. + /// + /// The time-stamp when the object was created. + /// The time stamp is encoded as ISO 8601 date and time format + /// ("YYYY-MM-DDThh:mm:ssZ", see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// + /// A new instance for mocking. + public static AsynchronousTranscription AsynchronousTranscription(TranscriptionLinks links = null, TranscriptionProperties properties = null, Uri self = null, EntityReference model = null, EntityReference dataset = null, IEnumerable contentUrls = null, Uri contentContainerUrl = null, string locale = null, string displayName = null, string description = null, IDictionary customProperties = null, DateTimeOffset? lastActionDateTime = null, ApiStatus? status = null, DateTimeOffset? createdDateTime = null) + { + contentUrls ??= new List(); + customProperties ??= new Dictionary(); + + return new AsynchronousTranscription( + links, + properties, + self, + model, + dataset, + contentUrls?.ToList(), + contentContainerUrl, + locale, + displayName, + description, + customProperties, + lastActionDateTime, + status, + createdDateTime, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The location to get all files of this entity. See operation "Transcriptions_ListFiles" for more details. + /// A new instance for mocking. + public static TranscriptionLinks TranscriptionLinks(Uri files = null) + { + return new TranscriptionLinks(files, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A value indicating whether word level timestamps are requested. The default value is false. + /// A value indicating whether word level timestamps for the display form are requested. The default value is false. + /// + /// The duration in milliseconds of the transcription. + /// Durations larger than 2^53-1 are not supported to ensure compatibility with JavaScript integers. + /// + /// A collection of the requested channel numbers. In the default case, the channels 0 and 1 are considered. + /// + /// The requested destination container. + /// + /// Remarks + /// + /// When a destination container is used in combination with a timeToLive, the metadata of a transcription will be deleted normally, but the data stored in the destination container, including transcription results, will remain untouched, because no delete permissions are required for this container. + /// + /// To support automatic cleanup, either configure blob lifetimes on the container, or use "Bring your own Storage (BYOS)" instead of destinationContainerUrl, where blobs can be cleaned up. + /// + /// The mode used for punctuation. + /// Mode of profanity filtering. + /// + /// How long the transcription will be kept in the system after it has completed. Once the transcription reaches the time to live after completion(successful or failed) it will be automatically deleted. + /// + /// Note: When using BYOS (bring your own storage), the result files on the customer owned storage account will also be deleted.Use either destinationContainerUrl to specify a separate container for result files which will not be deleted when the timeToLive expires, or retrieve the result files through the API and store them as needed. + /// + /// The shortest supported duration is 6 hours, the longest supported duration is 31 days. 2 days (48 hours) is the recommended default value when data is consumed directly. + /// + /// EntityError. + /// DiarizationProperties. + /// LanguageIdentificationProperties. + /// A new instance for mocking. + public static TranscriptionProperties TranscriptionProperties(bool? wordLevelTimestampsEnabled = null, bool? displayFormWordLevelTimestampsEnabled = null, int? durationMilliseconds = null, IEnumerable channels = null, Uri destinationContainerUrl = null, PunctuationMode? punctuationMode = null, ProfanityFilterMode? profanityFilterMode = null, int timeToLiveHours = default, EntityError error = null, DiarizationProperties diarization = null, LanguageIdentificationProperties languageIdentification = null) + { + channels ??= new List(); + + return new TranscriptionProperties( + wordLevelTimestampsEnabled, + displayFormWordLevelTimestampsEnabled, + durationMilliseconds, + channels?.ToList(), + destinationContainerUrl, + punctuationMode, + profanityFilterMode, + timeToLiveHours, + error, + diarization, + languageIdentification, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The code of this error. + /// The message for this error. + /// A new instance for mocking. + public static EntityError EntityError(string code = null, string message = null) + { + return new EntityError(code, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// A list of entities limited by either the passed query parameters 'skip' and 'top' or their default values. + /// + /// When iterating through a list using pagination and deleting entities in parallel, some entities will be skipped in the results. + /// It's recommended to build a list on the client and delete after the fetching of the complete list. + /// + /// A link to the next set of paginated results if there are more entities available; otherwise null. + /// A new instance for mocking. + public static PageableTranscription PageableTranscription(IEnumerable values = null, Uri nextLink = null) + { + values ??= new List(); + + return new PageableTranscription(values?.ToList(), nextLink, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// A list of entities limited by either the passed query parameters 'skip' and 'top' or their default values. + /// + /// When iterating through a list using pagination and deleting entities in parallel, some entities will be skipped in the results. + /// It's recommended to build a list on the client and delete after the fetching of the complete list. + /// + /// A link to the next set of paginated results if there are more entities available; otherwise null. + /// A new instance for mocking. + public static PageableFile PageableFile(IEnumerable values = null, Uri nextLink = null) + { + values ??= new List(); + + return new PageableFile(values?.ToList(), nextLink, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation time of this file. The time stamp is encoded as ISO 8601 date and time format (see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// FileKind. + /// FileLinks. + /// The name of this file. + /// FileProperties. + /// The location of this entity. + /// A new instance for mocking. + public static TranscriptionFile TranscriptionFile(DateTimeOffset createdDateTime = default, FileKind kind = default, FileLinks links = null, string name = null, FileProperties properties = null, Uri self = null) + { + return new TranscriptionFile( + createdDateTime, + kind, + links, + name, + properties, + self, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The url to retrieve the content of this file. + /// A new instance for mocking. + public static FileLinks FileLinks(Uri contentUrl = null) + { + return new FileLinks(contentUrl, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The total duration in milliseconds of the file in case this file is an audio file. + /// The size of the data in bytes. + /// A new instance for mocking. + public static FileProperties FileProperties(int durationMilliseconds = default, int size = default) + { + return new FileProperties(durationMilliseconds, size, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ApiStatus.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ApiStatus.cs new file mode 100644 index 000000000000..15a05c02ce2d --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ApiStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Describe the current state of the API. + public readonly partial struct ApiStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApiStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotStartedValue = "NotStarted"; + private const string RunningValue = "Running"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + + /// The long running operation has not yet started. + public static ApiStatus NotStarted { get; } = new ApiStatus(NotStartedValue); + /// The long running operation is currently processing. + public static ApiStatus Running { get; } = new ApiStatus(RunningValue); + /// The long running operation has successfully completed. + public static ApiStatus Succeeded { get; } = new ApiStatus(SucceededValue); + /// The long running operation has failed. + public static ApiStatus Failed { get; } = new ApiStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(ApiStatus left, ApiStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApiStatus left, ApiStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ApiStatus(string value) => new ApiStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApiStatus other && Equals(other); + /// + public bool Equals(ApiStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AsynchronousTranscription.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AsynchronousTranscription.Serialization.cs new file mode 100644 index 000000000000..1da3c259169e --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AsynchronousTranscription.Serialization.cs @@ -0,0 +1,367 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class AsynchronousTranscription : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AsynchronousTranscription)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteObjectValue(Links, options); + } + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + if (options.Format != "W" && Optional.IsDefined(Self)) + { + writer.WritePropertyName("self"u8); + writer.WriteStringValue(Self.AbsoluteUri); + } + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteObjectValue(Model, options); + } + if (Optional.IsDefined(Dataset)) + { + writer.WritePropertyName("dataset"u8); + writer.WriteObjectValue(Dataset, options); + } + if (Optional.IsCollectionDefined(ContentUrls)) + { + writer.WritePropertyName("contentUrls"u8); + writer.WriteStartArray(); + foreach (var item in ContentUrls) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.AbsoluteUri); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ContentContainerUrl)) + { + writer.WritePropertyName("contentContainerUrl"u8); + writer.WriteStringValue(ContentContainerUrl.AbsoluteUri); + } + writer.WritePropertyName("locale"u8); + writer.WriteStringValue(Locale); + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(CustomProperties)) + { + writer.WritePropertyName("customProperties"u8); + writer.WriteStartObject(); + foreach (var item in CustomProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(LastActionDateTime)) + { + writer.WritePropertyName("lastActionDateTime"u8); + writer.WriteStringValue(LastActionDateTime.Value, "O"); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AsynchronousTranscription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AsynchronousTranscription)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAsynchronousTranscription(document.RootElement, options); + } + + internal static AsynchronousTranscription DeserializeAsynchronousTranscription(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TranscriptionLinks links = default; + TranscriptionProperties properties = default; + Uri self = default; + EntityReference model = default; + EntityReference dataset = default; + IList contentUrls = default; + Uri contentContainerUrl = default; + string locale = default; + string displayName = default; + string description = default; + IDictionary customProperties = default; + DateTimeOffset? lastActionDateTime = default; + ApiStatus? status = default; + DateTimeOffset? createdDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + links = TranscriptionLinks.DeserializeTranscriptionLinks(property.Value, options); + continue; + } + if (property.NameEquals("properties"u8)) + { + properties = TranscriptionProperties.DeserializeTranscriptionProperties(property.Value, options); + continue; + } + if (property.NameEquals("self"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + self = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = EntityReference.DeserializeEntityReference(property.Value, options); + continue; + } + if (property.NameEquals("dataset"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataset = EntityReference.DeserializeEntityReference(property.Value, options); + continue; + } + if (property.NameEquals("contentUrls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new Uri(item.GetString())); + } + } + contentUrls = array; + continue; + } + if (property.NameEquals("contentContainerUrl"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentContainerUrl = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("locale"u8)) + { + locale = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("customProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + customProperties = dictionary; + continue; + } + if (property.NameEquals("lastActionDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastActionDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ApiStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AsynchronousTranscription( + links, + properties, + self, + model, + dataset, + contentUrls ?? new ChangeTrackingList(), + contentContainerUrl, + locale, + displayName, + description, + customProperties ?? new ChangeTrackingDictionary(), + lastActionDateTime, + status, + createdDateTime, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AsynchronousTranscription)} does not support writing '{options.Format}' format."); + } + } + + AsynchronousTranscription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAsynchronousTranscription(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AsynchronousTranscription)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AsynchronousTranscription FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAsynchronousTranscription(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AsynchronousTranscription.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AsynchronousTranscription.cs new file mode 100644 index 000000000000..c7d45ed1483a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/AsynchronousTranscription.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Transcription. + public partial class AsynchronousTranscription + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// TranscriptionProperties. + /// The locale of the contained data. If Language Identification is used, this locale is used to transcribe speech for which no language could be detected. + /// The display name of the object. + /// , or is null. + public AsynchronousTranscription(TranscriptionProperties properties, string locale, string displayName) + { + Argument.AssertNotNull(properties, nameof(properties)); + Argument.AssertNotNull(locale, nameof(locale)); + Argument.AssertNotNull(displayName, nameof(displayName)); + + Properties = properties; + ContentUrls = new ChangeTrackingList(); + Locale = locale; + DisplayName = displayName; + CustomProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// TranscriptionLinks. + /// TranscriptionProperties. + /// The location of this entity. + /// EntityReference. + /// EntityReference. + /// + /// A list of content urls to get audio files to transcribe. Up to 1000 urls are allowed. + /// This property will not be returned in a response. + /// + /// + /// A URL for an Azure blob container that contains the audio files. A container is allowed to have a maximum size of 5GB and a maximum number of 10000 blobs. + /// The maximum size for a blob is 2.5GB. + /// Container SAS should contain 'r' (read) and 'l' (list) permissions. + /// This property will not be returned in a response. + /// + /// The locale of the contained data. If Language Identification is used, this locale is used to transcribe speech for which no language could be detected. + /// The display name of the object. + /// The description of the object. + /// + /// The custom properties of this entity. The maximum allowed key length is 64 characters, the maximum + /// allowed value length is 256 characters and the count of allowed entries is 10. + /// + /// + /// The time-stamp when the current status was entered. + /// The time stamp is encoded as ISO 8601 date and time format + /// ("YYYY-MM-DDThh:mm:ssZ", see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// + /// The status of the object. + /// + /// The time-stamp when the object was created. + /// The time stamp is encoded as ISO 8601 date and time format + /// ("YYYY-MM-DDThh:mm:ssZ", see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// + /// Keeps track of any properties unknown to the library. + internal AsynchronousTranscription(TranscriptionLinks links, TranscriptionProperties properties, Uri self, EntityReference model, EntityReference dataset, IList contentUrls, Uri contentContainerUrl, string locale, string displayName, string description, IDictionary customProperties, DateTimeOffset? lastActionDateTime, ApiStatus? status, DateTimeOffset? createdDateTime, IDictionary serializedAdditionalRawData) + { + Links = links; + Properties = properties; + Self = self; + Model = model; + Dataset = dataset; + ContentUrls = contentUrls; + ContentContainerUrl = contentContainerUrl; + Locale = locale; + DisplayName = displayName; + Description = description; + CustomProperties = customProperties; + LastActionDateTime = lastActionDateTime; + Status = status; + CreatedDateTime = createdDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AsynchronousTranscription() + { + } + + /// TranscriptionLinks. + public TranscriptionLinks Links { get; set; } + /// TranscriptionProperties. + public TranscriptionProperties Properties { get; set; } + /// The location of this entity. + public Uri Self { get; } + /// EntityReference. + public EntityReference Model { get; set; } + /// EntityReference. + public EntityReference Dataset { get; set; } + /// + /// A list of content urls to get audio files to transcribe. Up to 1000 urls are allowed. + /// This property will not be returned in a response. + /// + public IList ContentUrls { get; } + /// + /// A URL for an Azure blob container that contains the audio files. A container is allowed to have a maximum size of 5GB and a maximum number of 10000 blobs. + /// The maximum size for a blob is 2.5GB. + /// Container SAS should contain 'r' (read) and 'l' (list) permissions. + /// This property will not be returned in a response. + /// + public Uri ContentContainerUrl { get; set; } + /// The locale of the contained data. If Language Identification is used, this locale is used to transcribe speech for which no language could be detected. + public string Locale { get; set; } + /// The display name of the object. + public string DisplayName { get; set; } + /// The description of the object. + public string Description { get; set; } + /// + /// The custom properties of this entity. The maximum allowed key length is 64 characters, the maximum + /// allowed value length is 256 characters and the count of allowed entries is 10. + /// + public IDictionary CustomProperties { get; } + /// + /// The time-stamp when the current status was entered. + /// The time stamp is encoded as ISO 8601 date and time format + /// ("YYYY-MM-DDThh:mm:ssZ", see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// + public DateTimeOffset? LastActionDateTime { get; } + /// The status of the object. + public ApiStatus? Status { get; set; } + /// + /// The time-stamp when the object was created. + /// The time stamp is encoded as ISO 8601 date and time format + /// ("YYYY-MM-DDThh:mm:ssZ", see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// + public DateTimeOffset? CreatedDateTime { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/BatchTranscription.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/BatchTranscription.cs new file mode 100644 index 000000000000..da46a38aa46a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/BatchTranscription.cs @@ -0,0 +1,856 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + // Data plane generated sub-client. + /// The BatchTranscription sub-client. + public partial class BatchTranscription + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly ServiceApiVersions? _serviceApiVersionsQueryParameter; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of BatchTranscription for mocking. + protected BatchTranscription() + { + } + + /// Initializes a new instance of BatchTranscription. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// The identifier of the transcription. The default value is "2024-11-15". + internal BatchTranscription(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, ServiceApiVersions? serviceApiVersionsQueryParameter) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _serviceApiVersionsQueryParameter = serviceApiVersionsQueryParameter; + } + + /// Submits a new transcription job. + /// Transcription. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> SubmitTranscriptionAsync(AsynchronousTranscription transcription, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(transcription, nameof(transcription)); + + using RequestContent content = transcription.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await SubmitTranscriptionAsync(content, context).ConfigureAwait(false); + return Response.FromValue(AsynchronousTranscription.FromResponse(response), response); + } + + /// Submits a new transcription job. + /// Transcription. + /// The cancellation token to use. + /// is null. + /// + public virtual Response SubmitTranscription(AsynchronousTranscription transcription, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(transcription, nameof(transcription)); + + using RequestContent content = transcription.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = SubmitTranscription(content, context); + return Response.FromValue(AsynchronousTranscription.FromResponse(response), response); + } + + /// + /// [Protocol Method] Submits a new transcription job. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task SubmitTranscriptionAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.SubmitTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateSubmitTranscriptionRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Submits a new transcription job. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response SubmitTranscription(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.SubmitTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateSubmitTranscriptionRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of transcriptions for the authenticated subscription. + /// Number of transcriptions that will be skipped. + /// Number of transcriptions that will be included after skipping. + /// + /// A filtering expression for selecting a subset of the available transcriptions. + /// - Supported properties: displayName, description, createdDateTime, lastActionDateTime, status, locale. + /// - Operators: + /// - eq, ne are supported for all properties. + /// - gt, ge, lt, le are supported for createdDateTime and lastActionDateTime. + /// - and, or, not are supported. + /// - Example: + /// filter=createdDateTime gt 2022-02-01T11:00:00Z + /// + /// The cancellation token to use. + /// + public virtual async Task> GetTranscriptionsAsync(int? skip = null, int? top = null, string filter = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTranscriptionsAsync(skip, top, filter, context).ConfigureAwait(false); + return Response.FromValue(PageableTranscription.FromResponse(response), response); + } + + /// Gets a list of transcriptions for the authenticated subscription. + /// Number of transcriptions that will be skipped. + /// Number of transcriptions that will be included after skipping. + /// + /// A filtering expression for selecting a subset of the available transcriptions. + /// - Supported properties: displayName, description, createdDateTime, lastActionDateTime, status, locale. + /// - Operators: + /// - eq, ne are supported for all properties. + /// - gt, ge, lt, le are supported for createdDateTime and lastActionDateTime. + /// - and, or, not are supported. + /// - Example: + /// filter=createdDateTime gt 2022-02-01T11:00:00Z + /// + /// The cancellation token to use. + /// + public virtual Response GetTranscriptions(int? skip = null, int? top = null, string filter = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTranscriptions(skip, top, filter, context); + return Response.FromValue(PageableTranscription.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of transcriptions for the authenticated subscription. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Number of transcriptions that will be skipped. + /// Number of transcriptions that will be included after skipping. + /// + /// A filtering expression for selecting a subset of the available transcriptions. + /// - Supported properties: displayName, description, createdDateTime, lastActionDateTime, status, locale. + /// - Operators: + /// - eq, ne are supported for all properties. + /// - gt, ge, lt, le are supported for createdDateTime and lastActionDateTime. + /// - and, or, not are supported. + /// - Example: + /// filter=createdDateTime gt 2022-02-01T11:00:00Z + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTranscriptionsAsync(int? skip, int? top, string filter, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.GetTranscriptions"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionsRequest(skip, top, filter, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of transcriptions for the authenticated subscription. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Number of transcriptions that will be skipped. + /// Number of transcriptions that will be included after skipping. + /// + /// A filtering expression for selecting a subset of the available transcriptions. + /// - Supported properties: displayName, description, createdDateTime, lastActionDateTime, status, locale. + /// - Operators: + /// - eq, ne are supported for all properties. + /// - gt, ge, lt, le are supported for createdDateTime and lastActionDateTime. + /// - and, or, not are supported. + /// - Example: + /// filter=createdDateTime gt 2022-02-01T11:00:00Z + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTranscriptions(int? skip, int? top, string filter, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.GetTranscriptions"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionsRequest(skip, top, filter, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the files of the transcription identified by the given ID. + /// The identifier of the transcription. + /// Number of transcription files that will be skipped. + /// Number of transcription files that will be included after skipping. + /// + /// This parameter defines the duration in minutes for which an SAS url should be valid. + /// The parameter can only be used for operations on speech resources that don't have BYOS enabled and transcriptions without a destinationContainerUrl. For speech resources + /// that don't have BYOS enabled, the default SAS validity duration is 12 hours. + /// For speech resources with BYOS and transcriptions with a destinationContainerUrl, returned urls do not contain an SAS token. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetTranscriptionFilesAsync(string id, int? skip = null, int? top = null, int? sasLifetimeMinutes = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTranscriptionFilesAsync(id, skip, top, sasLifetimeMinutes, context).ConfigureAwait(false); + return Response.FromValue(PageableFile.FromResponse(response), response); + } + + /// Gets the files of the transcription identified by the given ID. + /// The identifier of the transcription. + /// Number of transcription files that will be skipped. + /// Number of transcription files that will be included after skipping. + /// + /// This parameter defines the duration in minutes for which an SAS url should be valid. + /// The parameter can only be used for operations on speech resources that don't have BYOS enabled and transcriptions without a destinationContainerUrl. For speech resources + /// that don't have BYOS enabled, the default SAS validity duration is 12 hours. + /// For speech resources with BYOS and transcriptions with a destinationContainerUrl, returned urls do not contain an SAS token. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetTranscriptionFiles(string id, int? skip = null, int? top = null, int? sasLifetimeMinutes = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTranscriptionFiles(id, skip, top, sasLifetimeMinutes, context); + return Response.FromValue(PageableFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets the files of the transcription identified by the given ID + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the transcription. + /// Number of transcription files that will be skipped. + /// Number of transcription files that will be included after skipping. + /// + /// This parameter defines the duration in minutes for which an SAS url should be valid. + /// The parameter can only be used for operations on speech resources that don't have BYOS enabled and transcriptions without a destinationContainerUrl. For speech resources + /// that don't have BYOS enabled, the default SAS validity duration is 12 hours. + /// For speech resources with BYOS and transcriptions with a destinationContainerUrl, returned urls do not contain an SAS token. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTranscriptionFilesAsync(string id, int? skip, int? top, int? sasLifetimeMinutes, RequestContext context) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.GetTranscriptionFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionFilesRequest(id, skip, top, sasLifetimeMinutes, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets the files of the transcription identified by the given ID + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the transcription. + /// Number of transcription files that will be skipped. + /// Number of transcription files that will be included after skipping. + /// + /// This parameter defines the duration in minutes for which an SAS url should be valid. + /// The parameter can only be used for operations on speech resources that don't have BYOS enabled and transcriptions without a destinationContainerUrl. For speech resources + /// that don't have BYOS enabled, the default SAS validity duration is 12 hours. + /// For speech resources with BYOS and transcriptions with a destinationContainerUrl, returned urls do not contain an SAS token. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTranscriptionFiles(string id, int? skip, int? top, int? sasLifetimeMinutes, RequestContext context) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.GetTranscriptionFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionFilesRequest(id, skip, top, sasLifetimeMinutes, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the transcription identified by the given ID. + /// The identifier of the transcription. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetTranscriptionAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTranscriptionAsync(id, context).ConfigureAwait(false); + return Response.FromValue(AsynchronousTranscription.FromResponse(response), response); + } + + /// Gets the transcription identified by the given ID. + /// The identifier of the transcription. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetTranscription(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTranscription(id, context); + return Response.FromValue(AsynchronousTranscription.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets the transcription identified by the given ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the transcription. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTranscriptionAsync(string id, RequestContext context) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.GetTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionRequest(id, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets the transcription identified by the given ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the transcription. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTranscription(string id, RequestContext context) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.GetTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionRequest(id, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Updates the mutable details of the transcription identified by its ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The identifier of the transcription. + /// The content to send as the body of the request. + /// request content type. Allowed values: "application/json" | "application/merge-patch+json". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task PatchTranscriptionAsync(string id, RequestContent content, ContentType contentType, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.PatchTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreatePatchTranscriptionRequest(id, content, contentType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Updates the mutable details of the transcription identified by its ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The identifier of the transcription. + /// The content to send as the body of the request. + /// request content type. Allowed values: "application/json" | "application/merge-patch+json". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response PatchTranscription(string id, RequestContent content, ContentType contentType, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.PatchTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreatePatchTranscriptionRequest(id, content, contentType, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes the specified transcription task. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The identifier of the transcription. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteTranscriptionAsync(string id, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.DeleteTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTranscriptionRequest(id, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes the specified transcription task. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The identifier of the transcription. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteTranscription(string id, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscription.DeleteTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTranscriptionRequest(id, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateSubmitTranscriptionRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier201); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions:submit", false); + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetTranscriptionsRequest(int? skip, int? top, string filter, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions", false); + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (top != null) + { + uri.AppendQuery("top", top.Value, true); + } + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTranscriptionFilesRequest(string id, int? skip, int? top, int? sasLifetimeMinutes, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions/", false); + uri.AppendPath(id, true); + uri.AppendPath("/files", false); + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (top != null) + { + uri.AppendQuery("top", top.Value, true); + } + if (sasLifetimeMinutes != null) + { + uri.AppendQuery("sasLifetimeMinutes", sasLifetimeMinutes.Value, true); + } + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTranscriptionRequest(string id, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions/", false); + uri.AppendPath(id, true); + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreatePatchTranscriptionRequest(string id, RequestContent content, ContentType contentType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions/", false); + uri.AppendPath(id, true); + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", contentType.ToString()); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTranscriptionRequest(string id, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions/", false); + uri.AppendPath(id, true); + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier201; + private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ClientCustomizations.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ClientCustomizations.cs new file mode 100644 index 000000000000..c1b13f0d8b50 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ClientCustomizations.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + // Data plane generated sub-client. + /// The ClientCustomizations sub-client. + public partial class ClientCustomizations + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of ClientCustomizations for mocking. + protected ClientCustomizations() + { + } + + /// Initializes a new instance of ClientCustomizations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + internal ClientCustomizations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/DiarizationProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/DiarizationProperties.Serialization.cs new file mode 100644 index 000000000000..5b31e5e9b940 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/DiarizationProperties.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class DiarizationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiarizationProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled); + writer.WritePropertyName("maxSpeakers"u8); + writer.WriteNumberValue(MaxSpeakers); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DiarizationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiarizationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiarizationProperties(document.RootElement, options); + } + + internal static DiarizationProperties DeserializeDiarizationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool enabled = default; + int maxSpeakers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled"u8)) + { + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("maxSpeakers"u8)) + { + maxSpeakers = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DiarizationProperties(enabled, maxSpeakers, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DiarizationProperties)} does not support writing '{options.Format}' format."); + } + } + + DiarizationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDiarizationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiarizationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DiarizationProperties FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDiarizationProperties(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/DiarizationProperties.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/DiarizationProperties.cs new file mode 100644 index 000000000000..b8edb4e39e7f --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/DiarizationProperties.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// DiarizationProperties. + public partial class DiarizationProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A value indicating whether speaker diarization is enabled. + /// A hint for the maximum number of speakers for diarization. Must be greater than 1 and less than 36. + public DiarizationProperties(bool enabled, int maxSpeakers) + { + Enabled = enabled; + MaxSpeakers = maxSpeakers; + } + + /// Initializes a new instance of . + /// A value indicating whether speaker diarization is enabled. + /// A hint for the maximum number of speakers for diarization. Must be greater than 1 and less than 36. + /// Keeps track of any properties unknown to the library. + internal DiarizationProperties(bool enabled, int maxSpeakers, IDictionary serializedAdditionalRawData) + { + Enabled = enabled; + MaxSpeakers = maxSpeakers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DiarizationProperties() + { + } + + /// A value indicating whether speaker diarization is enabled. + public bool Enabled { get; set; } + /// A hint for the maximum number of speakers for diarization. Must be greater than 1 and less than 36. + public int MaxSpeakers { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Docs/BatchTranscription.xml b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Docs/BatchTranscription.xml new file mode 100644 index 000000000000..b7d1ef126075 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Docs/BatchTranscription.xml @@ -0,0 +1,903 @@ + + + + + +This sample shows how to call SubmitTranscriptionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234), "", ""); +Response response = await client.SubmitTranscriptionAsync(transcription); +]]> +This sample shows how to call SubmitTranscriptionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234) +{ + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainerUrl = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentification = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = + { + ["key"] = new EntityReference(new Uri("http://localhost:3000")) + }, + }, +}, "", "") +{ + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + ContentUrls = { new Uri("http://localhost:3000") }, + ContentContainerUrl = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = + { + ["key"] = "" + }, + Status = ApiStatus.NotStarted, +}; +Response response = await client.SubmitTranscriptionAsync(transcription); +]]> + + + +This sample shows how to call SubmitTranscription. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234), "", ""); +Response response = client.SubmitTranscription(transcription); +]]> +This sample shows how to call SubmitTranscription with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234) +{ + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainerUrl = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentification = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = + { + ["key"] = new EntityReference(new Uri("http://localhost:3000")) + }, + }, +}, "", "") +{ + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + ContentUrls = { new Uri("http://localhost:3000") }, + ContentContainerUrl = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = + { + ["key"] = "" + }, + Status = ApiStatus.NotStarted, +}; +Response response = client.SubmitTranscription(transcription); +]]> + + + +This sample shows how to call SubmitTranscriptionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +using RequestContent content = RequestContent.Create(new +{ + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", +}); +Response response = await client.SubmitTranscriptionAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +]]> +This sample shows how to call SubmitTranscriptionAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +using RequestContent content = RequestContent.Create(new +{ + links = new object(), + properties = new + { + wordLevelTimestampsEnabled = true, + displayFormWordLevelTimestampsEnabled = true, + channels = new object[] + { + 1234 + }, + destinationContainerUrl = "http://localhost:3000", + punctuationMode = "None", + profanityFilterMode = "None", + timeToLiveHours = 1234, + error = new object(), + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + languageIdentification = new + { + mode = "Continuous", + candidateLocales = new object[] + { + "" + }, + speechModelMapping = new + { + key = new + { + self = "http://localhost:3000", + }, + }, + }, + }, + contentUrls = new object[] + { + "http://localhost:3000" + }, + contentContainerUrl = "http://localhost:3000", + locale = "", + displayName = "", + description = "", + customProperties = new + { + key = "", + }, + status = "NotStarted", +}); +Response response = await client.SubmitTranscriptionAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +]]> + + + +This sample shows how to call SubmitTranscription and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +using RequestContent content = RequestContent.Create(new +{ + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", +}); +Response response = client.SubmitTranscription(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +]]> +This sample shows how to call SubmitTranscription with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +using RequestContent content = RequestContent.Create(new +{ + links = new object(), + properties = new + { + wordLevelTimestampsEnabled = true, + displayFormWordLevelTimestampsEnabled = true, + channels = new object[] + { + 1234 + }, + destinationContainerUrl = "http://localhost:3000", + punctuationMode = "None", + profanityFilterMode = "None", + timeToLiveHours = 1234, + error = new object(), + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + languageIdentification = new + { + mode = "Continuous", + candidateLocales = new object[] + { + "" + }, + speechModelMapping = new + { + key = new + { + self = "http://localhost:3000", + }, + }, + }, + }, + contentUrls = new object[] + { + "http://localhost:3000" + }, + contentContainerUrl = "http://localhost:3000", + locale = "", + displayName = "", + description = "", + customProperties = new + { + key = "", + }, + status = "NotStarted", +}); +Response response = client.SubmitTranscription(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +]]> + + + +This sample shows how to call GetTranscriptionsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.GetTranscriptionsAsync(); +]]> +This sample shows how to call GetTranscriptionsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.GetTranscriptionsAsync(skip: 1234, top: 1234, filter: ""); +]]> + + + +This sample shows how to call GetTranscriptions. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.GetTranscriptions(); +]]> +This sample shows how to call GetTranscriptions with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.GetTranscriptions(skip: 1234, top: 1234, filter: ""); +]]> + + + +This sample shows how to call GetTranscriptionsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.GetTranscriptionsAsync(null, null, null, null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetTranscriptionsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.GetTranscriptionsAsync(1234, 1234, "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("@nextLink").ToString()); +]]> + + + +This sample shows how to call GetTranscriptions and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.GetTranscriptions(null, null, null, null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetTranscriptions with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.GetTranscriptions(1234, 1234, "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("@nextLink").ToString()); +]]> + + + +This sample shows how to call GetTranscriptionFilesAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.GetTranscriptionFilesAsync(""); +]]> +This sample shows how to call GetTranscriptionFilesAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.GetTranscriptionFilesAsync("", skip: 1234, top: 1234, sasLifetimeMinutes: 1234); +]]> + + + +This sample shows how to call GetTranscriptionFiles. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.GetTranscriptionFiles(""); +]]> +This sample shows how to call GetTranscriptionFiles with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.GetTranscriptionFiles("", skip: 1234, top: 1234, sasLifetimeMinutes: 1234); +]]> + + + +This sample shows how to call GetTranscriptionFilesAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.GetTranscriptionFilesAsync("", null, null, null, null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetTranscriptionFilesAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.GetTranscriptionFilesAsync("", 1234, 1234, 1234, null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("kind").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("contentUrl").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("size").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("@nextLink").ToString()); +]]> + + + +This sample shows how to call GetTranscriptionFiles and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.GetTranscriptionFiles("", null, null, null, null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetTranscriptionFiles with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.GetTranscriptionFiles("", 1234, 1234, 1234, null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("kind").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("contentUrl").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("size").ToString()); +Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("@nextLink").ToString()); +]]> + + + +This sample shows how to call GetTranscriptionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.GetTranscriptionAsync(""); +]]> +This sample shows how to call GetTranscriptionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.GetTranscriptionAsync(""); +]]> + + + +This sample shows how to call GetTranscription. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.GetTranscription(""); +]]> +This sample shows how to call GetTranscription with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.GetTranscription(""); +]]> + + + +This sample shows how to call GetTranscriptionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.GetTranscriptionAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +]]> +This sample shows how to call GetTranscriptionAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.GetTranscriptionAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +]]> + + + +This sample shows how to call GetTranscription and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.GetTranscription("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +]]> +This sample shows how to call GetTranscription with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.GetTranscription("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +]]> + + + +This sample shows how to call PatchTranscriptionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +using RequestContent content = RequestContent.Create(new object()); +Response response = await client.PatchTranscriptionAsync("", content, new ContentType("application/json")); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +]]> +This sample shows how to call PatchTranscriptionAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "", + description = "", + customProperties = new + { + key = "", + }, +}); +Response response = await client.PatchTranscriptionAsync("", content, new ContentType("application/json")); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +]]> + + + +This sample shows how to call PatchTranscription and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +using RequestContent content = RequestContent.Create(new object()); +Response response = client.PatchTranscription("", content, new ContentType("application/json")); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +]]> +This sample shows how to call PatchTranscription with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "", + description = "", + customProperties = new + { + key = "", + }, +}); +Response response = client.PatchTranscription("", content, new ContentType("application/json")); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); +Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +]]> + + + +This sample shows how to call DeleteTranscriptionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = await client.DeleteTranscriptionAsync(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteTranscriptionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = await client.DeleteTranscriptionAsync(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTranscription. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + +Response response = client.DeleteTranscription(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteTranscription with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +Response response = client.DeleteTranscription(""); + +Console.WriteLine(response.Status); +]]> + + + \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityError.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityError.Serialization.cs new file mode 100644 index 000000000000..8309ac713874 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityError.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class EntityError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityError)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EntityError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityError(document.RootElement, options); + } + + internal static EntityError DeserializeEntityError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EntityError(code, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EntityError)} does not support writing '{options.Format}' format."); + } + } + + EntityError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEntityError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static EntityError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEntityError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityError.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityError.cs new file mode 100644 index 000000000000..f40ad9f6b284 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityError.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// EntityError. + public partial class EntityError + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EntityError() + { + } + + /// Initializes a new instance of . + /// The code of this error. + /// The message for this error. + /// Keeps track of any properties unknown to the library. + internal EntityError(string code, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The code of this error. + public string Code { get; } + /// The message for this error. + public string Message { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityReference.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityReference.Serialization.cs new file mode 100644 index 000000000000..22ef81ff9287 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityReference.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class EntityReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityReference)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("self"u8); + writer.WriteStringValue(Self.AbsoluteUri); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EntityReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityReference(document.RootElement, options); + } + + internal static EntityReference DeserializeEntityReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri self = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("self"u8)) + { + self = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EntityReference(self, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EntityReference)} does not support writing '{options.Format}' format."); + } + } + + EntityReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEntityReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static EntityReference FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEntityReference(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityReference.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityReference.cs new file mode 100644 index 000000000000..e5a76b97f8dc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/EntityReference.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// EntityReference. + public partial class EntityReference + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location of the referenced entity. + /// is null. + public EntityReference(Uri self) + { + Argument.AssertNotNull(self, nameof(self)); + + Self = self; + } + + /// Initializes a new instance of . + /// The location of the referenced entity. + /// Keeps track of any properties unknown to the library. + internal EntityReference(Uri self, IDictionary serializedAdditionalRawData) + { + Self = self; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EntityReference() + { + } + + /// The location of the referenced entity. + public Uri Self { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileKind.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileKind.cs new file mode 100644 index 000000000000..610ddfe15201 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileKind.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// FileKind. + public readonly partial struct FileKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AcousticDataArchiveValue = "AcousticDataArchive"; + private const string AcousticDataTranscriptionV2Value = "AcousticDataTranscriptionV2"; + private const string AudioValue = "Audio"; + private const string DatasetReportValue = "DatasetReport"; + private const string EvaluationDetailsValue = "EvaluationDetails"; + private const string LanguageDataValue = "LanguageData"; + private const string ModelReportValue = "ModelReport"; + private const string OutputFormattingDataValue = "OutputFormattingData"; + private const string PronunciationDataValue = "PronunciationData"; + private const string TranscriptionValue = "Transcription"; + private const string TranscriptionReportValue = "TranscriptionReport"; + + /// Type of data is acoustic data archive. + public static FileKind AcousticDataArchive { get; } = new FileKind(AcousticDataArchiveValue); + /// Type of data is acoustic data transcription v2. + public static FileKind AcousticDataTranscriptionV2 { get; } = new FileKind(AcousticDataTranscriptionV2Value); + /// Type of data is audio. + public static FileKind Audio { get; } = new FileKind(AudioValue); + /// Type of data is dataset report. + public static FileKind DatasetReport { get; } = new FileKind(DatasetReportValue); + /// Type of data is evaluation details. + public static FileKind EvaluationDetails { get; } = new FileKind(EvaluationDetailsValue); + /// Type of data is language data. + public static FileKind LanguageData { get; } = new FileKind(LanguageDataValue); + /// Type of data is model report. + public static FileKind ModelReport { get; } = new FileKind(ModelReportValue); + /// Type of data is output formatting input file. + public static FileKind OutputFormattingData { get; } = new FileKind(OutputFormattingDataValue); + /// Type of data is pronunciation data. + public static FileKind PronunciationData { get; } = new FileKind(PronunciationDataValue); + /// Type of data is transcription. + public static FileKind Transcription { get; } = new FileKind(TranscriptionValue); + /// Type of data is transcription report. + public static FileKind TranscriptionReport { get; } = new FileKind(TranscriptionReportValue); + /// Determines if two values are the same. + public static bool operator ==(FileKind left, FileKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileKind left, FileKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileKind(string value) => new FileKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileKind other && Equals(other); + /// + public bool Equals(FileKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileLinks.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileLinks.Serialization.cs new file mode 100644 index 000000000000..2d4ffc7fd7b9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileLinks.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class FileLinks : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileLinks)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("contentUrl"u8); + writer.WriteStringValue(ContentUrl.AbsoluteUri); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileLinks IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileLinks)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileLinks(document.RootElement, options); + } + + internal static FileLinks DeserializeFileLinks(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri contentUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("contentUrl"u8)) + { + contentUrl = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileLinks(contentUrl, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileLinks)} does not support writing '{options.Format}' format."); + } + } + + FileLinks IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileLinks(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileLinks)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileLinks FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileLinks(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileLinks.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileLinks.cs new file mode 100644 index 000000000000..6d2d741fd3d2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileLinks.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// FileLinks. + public partial class FileLinks + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The url to retrieve the content of this file. + /// is null. + internal FileLinks(Uri contentUrl) + { + Argument.AssertNotNull(contentUrl, nameof(contentUrl)); + + ContentUrl = contentUrl; + } + + /// Initializes a new instance of . + /// The url to retrieve the content of this file. + /// Keeps track of any properties unknown to the library. + internal FileLinks(Uri contentUrl, IDictionary serializedAdditionalRawData) + { + ContentUrl = contentUrl; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileLinks() + { + } + + /// The url to retrieve the content of this file. + public Uri ContentUrl { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileProperties.Serialization.cs new file mode 100644 index 000000000000..23f09699739b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileProperties.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class FileProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("durationMilliseconds"u8); + writer.WriteNumberValue(DurationMilliseconds); + writer.WritePropertyName("size"u8); + writer.WriteNumberValue(Size); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileProperties(document.RootElement, options); + } + + internal static FileProperties DeserializeFileProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int durationMilliseconds = default; + int size = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("durationMilliseconds"u8)) + { + durationMilliseconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("size"u8)) + { + size = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileProperties(durationMilliseconds, size, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileProperties)} does not support writing '{options.Format}' format."); + } + } + + FileProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileProperties FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileProperties(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileProperties.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileProperties.cs new file mode 100644 index 000000000000..479208b69164 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/FileProperties.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// FileProperties. + public partial class FileProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The total duration in milliseconds of the file in case this file is an audio file. + /// The size of the data in bytes. + internal FileProperties(int durationMilliseconds, int size) + { + DurationMilliseconds = durationMilliseconds; + Size = size; + } + + /// Initializes a new instance of . + /// The total duration in milliseconds of the file in case this file is an audio file. + /// The size of the data in bytes. + /// Keeps track of any properties unknown to the library. + internal FileProperties(int durationMilliseconds, int size, IDictionary serializedAdditionalRawData) + { + DurationMilliseconds = durationMilliseconds; + Size = size; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileProperties() + { + } + + /// The total duration in milliseconds of the file in case this file is an audio file. + public int DurationMilliseconds { get; } + /// The size of the data in bytes. + public int Size { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Argument.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..eb35522b5c3c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..bc6ac25577dc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ChangeTrackingList.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..161434da64dd --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..3e3f8f653635 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Optional.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..f4aa85b59e7a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..67aa0bb53ab0 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationMode.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationMode.cs new file mode 100644 index 000000000000..cc9fb4c967fb --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// The mode used for language identification. + public readonly partial struct LanguageIdentificationMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LanguageIdentificationMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ContinuousValue = "Continuous"; + private const string SingleValue = "Single"; + + /// Continuous language identification (Default). + public static LanguageIdentificationMode Continuous { get; } = new LanguageIdentificationMode(ContinuousValue); + /// Single language identification. If no language can be identified, the error code NoLanguageIdentified is returned to the user. If there is ambiguity between multiple languages, the error code MultipleLanguagesIdentified is returned to the user. + public static LanguageIdentificationMode Single { get; } = new LanguageIdentificationMode(SingleValue); + /// Determines if two values are the same. + public static bool operator ==(LanguageIdentificationMode left, LanguageIdentificationMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LanguageIdentificationMode left, LanguageIdentificationMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LanguageIdentificationMode(string value) => new LanguageIdentificationMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LanguageIdentificationMode other && Equals(other); + /// + public bool Equals(LanguageIdentificationMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationProperties.Serialization.cs new file mode 100644 index 000000000000..0e0f69e45485 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationProperties.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class LanguageIdentificationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LanguageIdentificationProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + writer.WritePropertyName("candidateLocales"u8); + writer.WriteStartArray(); + foreach (var item in CandidateLocales) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(SpeechModelMapping)) + { + writer.WritePropertyName("speechModelMapping"u8); + writer.WriteStartObject(); + foreach (var item in SpeechModelMapping) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LanguageIdentificationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LanguageIdentificationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLanguageIdentificationProperties(document.RootElement, options); + } + + internal static LanguageIdentificationProperties DeserializeLanguageIdentificationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LanguageIdentificationMode? mode = default; + IList candidateLocales = default; + IDictionary speechModelMapping = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new LanguageIdentificationMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("candidateLocales"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + candidateLocales = array; + continue; + } + if (property.NameEquals("speechModelMapping"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, EntityReference.DeserializeEntityReference(property0.Value, options)); + } + speechModelMapping = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LanguageIdentificationProperties(mode, candidateLocales, speechModelMapping ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(LanguageIdentificationProperties)} does not support writing '{options.Format}' format."); + } + } + + LanguageIdentificationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLanguageIdentificationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LanguageIdentificationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static LanguageIdentificationProperties FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeLanguageIdentificationProperties(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationProperties.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationProperties.cs new file mode 100644 index 000000000000..a516708a89f8 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/LanguageIdentificationProperties.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// LanguageIdentificationProperties. + public partial class LanguageIdentificationProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The candidate locales for language identification (example ["en-US", "de-DE", "es-ES"]). A minimum of 2 and a maximum of 10 candidate locales, including the main locale for the transcription, is supported for continuous mode. For single language identification, the maximum number of candidate locales is unbounded. + /// is null. + public LanguageIdentificationProperties(IEnumerable candidateLocales) + { + Argument.AssertNotNull(candidateLocales, nameof(candidateLocales)); + + CandidateLocales = candidateLocales.ToList(); + SpeechModelMapping = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The mode used for language identification. + /// The candidate locales for language identification (example ["en-US", "de-DE", "es-ES"]). A minimum of 2 and a maximum of 10 candidate locales, including the main locale for the transcription, is supported for continuous mode. For single language identification, the maximum number of candidate locales is unbounded. + /// + /// An optional mapping of locales to speech model entities. If no model is given for a locale, the default base model is used. + /// Keys must be locales contained in the candidate locales, values are entities for models of the respective locales. + /// + /// Keeps track of any properties unknown to the library. + internal LanguageIdentificationProperties(LanguageIdentificationMode? mode, IList candidateLocales, IDictionary speechModelMapping, IDictionary serializedAdditionalRawData) + { + Mode = mode; + CandidateLocales = candidateLocales; + SpeechModelMapping = speechModelMapping; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LanguageIdentificationProperties() + { + } + + /// The mode used for language identification. + public LanguageIdentificationMode? Mode { get; set; } + /// The candidate locales for language identification (example ["en-US", "de-DE", "es-ES"]). A minimum of 2 and a maximum of 10 candidate locales, including the main locale for the transcription, is supported for continuous mode. For single language identification, the maximum number of candidate locales is unbounded. + public IList CandidateLocales { get; } + /// + /// An optional mapping of locales to speech model entities. If no model is given for a locale, the default base model is used. + /// Keys must be locales contained in the candidate locales, values are entities for models of the respective locales. + /// + public IDictionary SpeechModelMapping { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableFile.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableFile.Serialization.cs new file mode 100644 index 000000000000..813c596944e7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableFile.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class PageableFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PageableFile)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("@nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PageableFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PageableFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePageableFile(document.RootElement, options); + } + + internal static PageableFile DeserializePageableFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList values = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TranscriptionFile.DeserializeTranscriptionFile(item, options)); + } + values = array; + continue; + } + if (property.NameEquals("@nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PageableFile(values ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PageableFile)} does not support writing '{options.Format}' format."); + } + } + + PageableFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePageableFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PageableFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PageableFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePageableFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableFile.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableFile.cs new file mode 100644 index 000000000000..dcdede76ce79 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableFile.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Page of entities. + public partial class PageableFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal PageableFile() + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// A list of entities limited by either the passed query parameters 'skip' and 'top' or their default values. + /// + /// When iterating through a list using pagination and deleting entities in parallel, some entities will be skipped in the results. + /// It's recommended to build a list on the client and delete after the fetching of the complete list. + /// + /// A link to the next set of paginated results if there are more entities available; otherwise null. + /// Keeps track of any properties unknown to the library. + internal PageableFile(IReadOnlyList values, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Values = values; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// A list of entities limited by either the passed query parameters 'skip' and 'top' or their default values. + /// + /// When iterating through a list using pagination and deleting entities in parallel, some entities will be skipped in the results. + /// It's recommended to build a list on the client and delete after the fetching of the complete list. + /// + public IReadOnlyList Values { get; } + /// A link to the next set of paginated results if there are more entities available; otherwise null. + public Uri NextLink { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableTranscription.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableTranscription.Serialization.cs new file mode 100644 index 000000000000..e6ff9ff7d605 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableTranscription.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class PageableTranscription : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PageableTranscription)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("@nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PageableTranscription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PageableTranscription)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePageableTranscription(document.RootElement, options); + } + + internal static PageableTranscription DeserializePageableTranscription(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList values = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AsynchronousTranscription.DeserializeAsynchronousTranscription(item, options)); + } + values = array; + continue; + } + if (property.NameEquals("@nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PageableTranscription(values ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PageableTranscription)} does not support writing '{options.Format}' format."); + } + } + + PageableTranscription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePageableTranscription(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PageableTranscription)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PageableTranscription FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePageableTranscription(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableTranscription.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableTranscription.cs new file mode 100644 index 000000000000..1149f1e7de26 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PageableTranscription.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Page of entities. + public partial class PageableTranscription + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal PageableTranscription() + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// A list of entities limited by either the passed query parameters 'skip' and 'top' or their default values. + /// + /// When iterating through a list using pagination and deleting entities in parallel, some entities will be skipped in the results. + /// It's recommended to build a list on the client and delete after the fetching of the complete list. + /// + /// A link to the next set of paginated results if there are more entities available; otherwise null. + /// Keeps track of any properties unknown to the library. + internal PageableTranscription(IReadOnlyList values, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Values = values; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// A list of entities limited by either the passed query parameters 'skip' and 'top' or their default values. + /// + /// When iterating through a list using pagination and deleting entities in parallel, some entities will be skipped in the results. + /// It's recommended to build a list on the client and delete after the fetching of the complete list. + /// + public IReadOnlyList Values { get; } + /// A link to the next set of paginated results if there are more entities available; otherwise null. + public Uri NextLink { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ProfanityFilterMode.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ProfanityFilterMode.cs new file mode 100644 index 000000000000..31a9cd91fa79 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ProfanityFilterMode.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Mode of profanity filtering. + public readonly partial struct ProfanityFilterMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProfanityFilterMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string RemovedValue = "Removed"; + private const string TagsValue = "Tags"; + private const string MaskedValue = "Masked"; + + /// Disable profanity filtering. + public static ProfanityFilterMode None { get; } = new ProfanityFilterMode(NoneValue); + /// Remove profanity. + public static ProfanityFilterMode Removed { get; } = new ProfanityFilterMode(RemovedValue); + /// Add "profanity" XML tags</Profanity>. + public static ProfanityFilterMode Tags { get; } = new ProfanityFilterMode(TagsValue); + /// Mask the profanity with * except of the first letter, e.g., f***. + public static ProfanityFilterMode Masked { get; } = new ProfanityFilterMode(MaskedValue); + /// Determines if two values are the same. + public static bool operator ==(ProfanityFilterMode left, ProfanityFilterMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProfanityFilterMode left, ProfanityFilterMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ProfanityFilterMode(string value) => new ProfanityFilterMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProfanityFilterMode other && Equals(other); + /// + public bool Equals(ProfanityFilterMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PunctuationMode.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PunctuationMode.cs new file mode 100644 index 000000000000..b7d209ae262f --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/PunctuationMode.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// The mode used for punctuation. + public readonly partial struct PunctuationMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PunctuationMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string DictatedValue = "Dictated"; + private const string AutomaticValue = "Automatic"; + private const string DictatedAndAutomaticValue = "DictatedAndAutomatic"; + + /// No punctuation. + public static PunctuationMode None { get; } = new PunctuationMode(NoneValue); + /// Dictated punctuation marks only, i.e., explicit punctuation. + public static PunctuationMode Dictated { get; } = new PunctuationMode(DictatedValue); + /// Automatic punctuation. + public static PunctuationMode Automatic { get; } = new PunctuationMode(AutomaticValue); + /// Dictated punctuation marks or automatic punctuation. + public static PunctuationMode DictatedAndAutomatic { get; } = new PunctuationMode(DictatedAndAutomaticValue); + /// Determines if two values are the same. + public static bool operator ==(PunctuationMode left, PunctuationMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PunctuationMode left, PunctuationMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PunctuationMode(string value) => new PunctuationMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PunctuationMode other && Equals(other); + /// + public bool Equals(PunctuationMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ServiceApiVersions.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ServiceApiVersions.Serialization.cs new file mode 100644 index 000000000000..76632b6bb6db --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ServiceApiVersions.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + internal static partial class ServiceApiVersionsExtensions + { + public static string ToSerialString(this ServiceApiVersions value) => value switch + { + ServiceApiVersions.V20241115 => "2024-11-15", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ServiceApiVersions value.") + }; + + public static ServiceApiVersions ToServiceApiVersions(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "2024-11-15")) return ServiceApiVersions.V20241115; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ServiceApiVersions value."); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ServiceApiVersions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ServiceApiVersions.cs new file mode 100644 index 000000000000..bb5493bc7027 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/ServiceApiVersions.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Service API versions. + public enum ServiceApiVersions + { + /// 2024-11-15. + V20241115 + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/SpeechToTextClient.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/SpeechToTextClient.cs new file mode 100644 index 000000000000..a7d9ee55cd78 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/SpeechToTextClient.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + // Data plane generated client. + /// The SpeechToText service client. + public partial class SpeechToTextClient + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of SpeechToTextClient for mocking. + protected SpeechToTextClient() + { + } + + /// Initializes a new instance of SpeechToTextClient. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public SpeechToTextClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new SpeechToTextClientOptions()) + { + } + + /// Initializes a new instance of SpeechToTextClient. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public SpeechToTextClient(Uri endpoint, AzureKeyCredential credential, SpeechToTextClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new SpeechToTextClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + private ClientCustomizations _cachedClientCustomizations; + + /// Initializes a new instance of ClientCustomizations. + public virtual ClientCustomizations GetClientCustomizationsClient() + { + return Volatile.Read(ref _cachedClientCustomizations) ?? Interlocked.CompareExchange(ref _cachedClientCustomizations, new ClientCustomizations(ClientDiagnostics, _pipeline, _keyCredential, _endpoint), null) ?? _cachedClientCustomizations; + } + + /// Initializes a new instance of BatchTranscription. + /// The identifier of the transcription. The default value is "2024-11-15". + public virtual BatchTranscription GetBatchTranscriptionClient(ServiceApiVersions? serviceApiVersionsQueryParameter = null) + { + return new BatchTranscription(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, serviceApiVersionsQueryParameter); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/SpeechToTextClientOptions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/SpeechToTextClientOptions.cs new file mode 100644 index 000000000000..bb0904ec7371 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/SpeechToTextClientOptions.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// Client options for SpeechToTextClient. + public partial class SpeechToTextClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_11_15; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-05-15-preview". + V2024_05_15_Preview = 1, + /// Service version "2024-11-15". + V2024_11_15 = 2, + } + + internal string Version { get; } + + /// Initializes new instance of SpeechToTextClientOptions. + public SpeechToTextClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_05_15_Preview => "2024-05-15-preview", + ServiceVersion.V2024_11_15 => "2024-11-15", + _ => throw new NotSupportedException() + }; + } + + /// The identifier of the transcription. The default value is "2024-11-15". + public ServiceApiVersions? ServiceApiVersionsQueryParameter { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionFile.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionFile.Serialization.cs new file mode 100644 index 000000000000..2addc09d73c7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionFile.Serialization.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class TranscriptionFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscriptionFile)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + writer.WritePropertyName("links"u8); + writer.WriteObjectValue(Links, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + writer.WritePropertyName("self"u8); + writer.WriteStringValue(Self.AbsoluteUri); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscriptionFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionFile(document.RootElement, options); + } + + internal static TranscriptionFile DeserializeTranscriptionFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + FileKind kind = default; + FileLinks links = default; + string name = default; + FileProperties properties = default; + Uri self = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new FileKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("links"u8)) + { + links = FileLinks.DeserializeFileLinks(property.Value, options); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + properties = FileProperties.DeserializeFileProperties(property.Value, options); + continue; + } + if (property.NameEquals("self"u8)) + { + self = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscriptionFile( + createdDateTime, + kind, + links, + name, + properties, + self, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscriptionFile)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscriptionFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscriptionFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscriptionFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionFile.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionFile.cs new file mode 100644 index 000000000000..36b98445a9aa --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionFile.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// File. + public partial class TranscriptionFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation time of this file. The time stamp is encoded as ISO 8601 date and time format (see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// FileKind. + /// FileLinks. + /// The name of this file. + /// FileProperties. + /// The location of this entity. + /// , , or is null. + internal TranscriptionFile(DateTimeOffset createdDateTime, FileKind kind, FileLinks links, string name, FileProperties properties, Uri self) + { + Argument.AssertNotNull(links, nameof(links)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(properties, nameof(properties)); + Argument.AssertNotNull(self, nameof(self)); + + CreatedDateTime = createdDateTime; + Kind = kind; + Links = links; + Name = name; + Properties = properties; + Self = self; + } + + /// Initializes a new instance of . + /// The creation time of this file. The time stamp is encoded as ISO 8601 date and time format (see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + /// FileKind. + /// FileLinks. + /// The name of this file. + /// FileProperties. + /// The location of this entity. + /// Keeps track of any properties unknown to the library. + internal TranscriptionFile(DateTimeOffset createdDateTime, FileKind kind, FileLinks links, string name, FileProperties properties, Uri self, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + Kind = kind; + Links = links; + Name = name; + Properties = properties; + Self = self; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscriptionFile() + { + } + + /// The creation time of this file. The time stamp is encoded as ISO 8601 date and time format (see https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations). + public DateTimeOffset CreatedDateTime { get; } + /// FileKind. + public FileKind Kind { get; } + /// FileLinks. + public FileLinks Links { get; } + /// The name of this file. + public string Name { get; } + /// FileProperties. + public FileProperties Properties { get; } + /// The location of this entity. + public Uri Self { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionLinks.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionLinks.Serialization.cs new file mode 100644 index 000000000000..530e4c078f57 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionLinks.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class TranscriptionLinks : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscriptionLinks)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Files)) + { + writer.WritePropertyName("files"u8); + writer.WriteStringValue(Files.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionLinks IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscriptionLinks)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionLinks(document.RootElement, options); + } + + internal static TranscriptionLinks DeserializeTranscriptionLinks(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri files = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("files"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + files = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscriptionLinks(files, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscriptionLinks)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionLinks IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscriptionLinks(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionLinks)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscriptionLinks FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscriptionLinks(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionLinks.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionLinks.cs new file mode 100644 index 000000000000..731b40886201 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionLinks.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// TranscriptionLinks. + public partial class TranscriptionLinks + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TranscriptionLinks() + { + } + + /// Initializes a new instance of . + /// The location to get all files of this entity. See operation "Transcriptions_ListFiles" for more details. + /// Keeps track of any properties unknown to the library. + internal TranscriptionLinks(Uri files, IDictionary serializedAdditionalRawData) + { + Files = files; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The location to get all files of this entity. See operation "Transcriptions_ListFiles" for more details. + public Uri Files { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionProperties.Serialization.cs new file mode 100644 index 000000000000..7bfdd7781246 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionProperties.Serialization.cs @@ -0,0 +1,314 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + public partial class TranscriptionProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscriptionProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(WordLevelTimestampsEnabled)) + { + writer.WritePropertyName("wordLevelTimestampsEnabled"u8); + writer.WriteBooleanValue(WordLevelTimestampsEnabled.Value); + } + if (Optional.IsDefined(DisplayFormWordLevelTimestampsEnabled)) + { + writer.WritePropertyName("displayFormWordLevelTimestampsEnabled"u8); + writer.WriteBooleanValue(DisplayFormWordLevelTimestampsEnabled.Value); + } + if (options.Format != "W" && Optional.IsDefined(DurationMilliseconds)) + { + writer.WritePropertyName("durationMilliseconds"u8); + writer.WriteNumberValue(DurationMilliseconds.Value); + } + if (Optional.IsCollectionDefined(Channels)) + { + writer.WritePropertyName("channels"u8); + writer.WriteStartArray(); + foreach (var item in Channels) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DestinationContainerUrl)) + { + writer.WritePropertyName("destinationContainerUrl"u8); + writer.WriteStringValue(DestinationContainerUrl.AbsoluteUri); + } + if (Optional.IsDefined(PunctuationMode)) + { + writer.WritePropertyName("punctuationMode"u8); + writer.WriteStringValue(PunctuationMode.Value.ToString()); + } + if (Optional.IsDefined(ProfanityFilterMode)) + { + writer.WritePropertyName("profanityFilterMode"u8); + writer.WriteStringValue(ProfanityFilterMode.Value.ToString()); + } + writer.WritePropertyName("timeToLiveHours"u8); + writer.WriteNumberValue(TimeToLiveHours); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); + } + if (Optional.IsDefined(Diarization)) + { + writer.WritePropertyName("diarization"u8); + writer.WriteObjectValue(Diarization, options); + } + if (Optional.IsDefined(LanguageIdentification)) + { + writer.WritePropertyName("languageIdentification"u8); + writer.WriteObjectValue(LanguageIdentification, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscriptionProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionProperties(document.RootElement, options); + } + + internal static TranscriptionProperties DeserializeTranscriptionProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? wordLevelTimestampsEnabled = default; + bool? displayFormWordLevelTimestampsEnabled = default; + int? durationMilliseconds = default; + IList channels = default; + Uri destinationContainerUrl = default; + PunctuationMode? punctuationMode = default; + ProfanityFilterMode? profanityFilterMode = default; + int timeToLiveHours = default; + EntityError error = default; + DiarizationProperties diarization = default; + LanguageIdentificationProperties languageIdentification = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("wordLevelTimestampsEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wordLevelTimestampsEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("displayFormWordLevelTimestampsEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + displayFormWordLevelTimestampsEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("durationMilliseconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + durationMilliseconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("channels"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + channels = array; + continue; + } + if (property.NameEquals("destinationContainerUrl"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + destinationContainerUrl = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("punctuationMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + punctuationMode = new PunctuationMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("profanityFilterMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profanityFilterMode = new ProfanityFilterMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("timeToLiveHours"u8)) + { + timeToLiveHours = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = EntityError.DeserializeEntityError(property.Value, options); + continue; + } + if (property.NameEquals("diarization"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diarization = DiarizationProperties.DeserializeDiarizationProperties(property.Value, options); + continue; + } + if (property.NameEquals("languageIdentification"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + languageIdentification = LanguageIdentificationProperties.DeserializeLanguageIdentificationProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscriptionProperties( + wordLevelTimestampsEnabled, + displayFormWordLevelTimestampsEnabled, + durationMilliseconds, + channels ?? new ChangeTrackingList(), + destinationContainerUrl, + punctuationMode, + profanityFilterMode, + timeToLiveHours, + error, + diarization, + languageIdentification, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscriptionProperties)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscriptionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscriptionProperties FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscriptionProperties(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionProperties.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionProperties.cs new file mode 100644 index 000000000000..9f675d356fc6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Generated/TranscriptionProperties.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.BatchTranscription +{ + /// TranscriptionProperties. + public partial class TranscriptionProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// How long the transcription will be kept in the system after it has completed. Once the transcription reaches the time to live after completion(successful or failed) it will be automatically deleted. + /// + /// Note: When using BYOS (bring your own storage), the result files on the customer owned storage account will also be deleted.Use either destinationContainerUrl to specify a separate container for result files which will not be deleted when the timeToLive expires, or retrieve the result files through the API and store them as needed. + /// + /// The shortest supported duration is 6 hours, the longest supported duration is 31 days. 2 days (48 hours) is the recommended default value when data is consumed directly. + /// + public TranscriptionProperties(int timeToLiveHours) + { + Channels = new ChangeTrackingList(); + TimeToLiveHours = timeToLiveHours; + } + + /// Initializes a new instance of . + /// A value indicating whether word level timestamps are requested. The default value is false. + /// A value indicating whether word level timestamps for the display form are requested. The default value is false. + /// + /// The duration in milliseconds of the transcription. + /// Durations larger than 2^53-1 are not supported to ensure compatibility with JavaScript integers. + /// + /// A collection of the requested channel numbers. In the default case, the channels 0 and 1 are considered. + /// + /// The requested destination container. + /// + /// Remarks + /// + /// When a destination container is used in combination with a timeToLive, the metadata of a transcription will be deleted normally, but the data stored in the destination container, including transcription results, will remain untouched, because no delete permissions are required for this container. + /// + /// To support automatic cleanup, either configure blob lifetimes on the container, or use "Bring your own Storage (BYOS)" instead of destinationContainerUrl, where blobs can be cleaned up. + /// + /// The mode used for punctuation. + /// Mode of profanity filtering. + /// + /// How long the transcription will be kept in the system after it has completed. Once the transcription reaches the time to live after completion(successful or failed) it will be automatically deleted. + /// + /// Note: When using BYOS (bring your own storage), the result files on the customer owned storage account will also be deleted.Use either destinationContainerUrl to specify a separate container for result files which will not be deleted when the timeToLive expires, or retrieve the result files through the API and store them as needed. + /// + /// The shortest supported duration is 6 hours, the longest supported duration is 31 days. 2 days (48 hours) is the recommended default value when data is consumed directly. + /// + /// EntityError. + /// DiarizationProperties. + /// LanguageIdentificationProperties. + /// Keeps track of any properties unknown to the library. + internal TranscriptionProperties(bool? wordLevelTimestampsEnabled, bool? displayFormWordLevelTimestampsEnabled, int? durationMilliseconds, IList channels, Uri destinationContainerUrl, PunctuationMode? punctuationMode, ProfanityFilterMode? profanityFilterMode, int timeToLiveHours, EntityError error, DiarizationProperties diarization, LanguageIdentificationProperties languageIdentification, IDictionary serializedAdditionalRawData) + { + WordLevelTimestampsEnabled = wordLevelTimestampsEnabled; + DisplayFormWordLevelTimestampsEnabled = displayFormWordLevelTimestampsEnabled; + DurationMilliseconds = durationMilliseconds; + Channels = channels; + DestinationContainerUrl = destinationContainerUrl; + PunctuationMode = punctuationMode; + ProfanityFilterMode = profanityFilterMode; + TimeToLiveHours = timeToLiveHours; + Error = error; + Diarization = diarization; + LanguageIdentification = languageIdentification; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscriptionProperties() + { + } + + /// A value indicating whether word level timestamps are requested. The default value is false. + public bool? WordLevelTimestampsEnabled { get; set; } + /// A value indicating whether word level timestamps for the display form are requested. The default value is false. + public bool? DisplayFormWordLevelTimestampsEnabled { get; set; } + /// + /// The duration in milliseconds of the transcription. + /// Durations larger than 2^53-1 are not supported to ensure compatibility with JavaScript integers. + /// + public int? DurationMilliseconds { get; } + /// A collection of the requested channel numbers. In the default case, the channels 0 and 1 are considered. + public IList Channels { get; } + /// + /// The requested destination container. + /// + /// Remarks + /// + /// When a destination container is used in combination with a timeToLive, the metadata of a transcription will be deleted normally, but the data stored in the destination container, including transcription results, will remain untouched, because no delete permissions are required for this container. + /// + /// To support automatic cleanup, either configure blob lifetimes on the container, or use "Bring your own Storage (BYOS)" instead of destinationContainerUrl, where blobs can be cleaned up. + /// + public Uri DestinationContainerUrl { get; set; } + /// The mode used for punctuation. + public PunctuationMode? PunctuationMode { get; set; } + /// Mode of profanity filtering. + public ProfanityFilterMode? ProfanityFilterMode { get; set; } + /// + /// How long the transcription will be kept in the system after it has completed. Once the transcription reaches the time to live after completion(successful or failed) it will be automatically deleted. + /// + /// Note: When using BYOS (bring your own storage), the result files on the customer owned storage account will also be deleted.Use either destinationContainerUrl to specify a separate container for result files which will not be deleted when the timeToLive expires, or retrieve the result files through the API and store them as needed. + /// + /// The shortest supported duration is 6 hours, the longest supported duration is 31 days. 2 days (48 hours) is the recommended default value when data is consumed directly. + /// + public int TimeToLiveHours { get; set; } + /// EntityError. + public EntityError Error { get; set; } + /// DiarizationProperties. + public DiarizationProperties Diarization { get; set; } + /// LanguageIdentificationProperties. + public LanguageIdentificationProperties LanguageIdentification { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Properties/AssemblyInfo.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..a24e4b80b6de --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.AI.SpeechToText.BatchTranscription.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tests/Azure.AI.SpeechToText.BatchTranscription.Tests.csproj b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tests/Azure.AI.SpeechToText.BatchTranscription.Tests.csproj new file mode 100644 index 000000000000..ac27a40efb23 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tests/Azure.AI.SpeechToText.BatchTranscription.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tests/Generated/Samples/Samples_BatchTranscription.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tests/Generated/Samples/Samples_BatchTranscription.cs new file mode 100644 index 000000000000..7a23423d42ef --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tests/Generated/Samples/Samples_BatchTranscription.cs @@ -0,0 +1,977 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.SpeechToText.BatchTranscription.Samples +{ + public partial class Samples_BatchTranscription + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_SubmitTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + using RequestContent content = RequestContent.Create(new + { + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", + }); + Response response = client.SubmitTranscription(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_SubmitTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + using RequestContent content = RequestContent.Create(new + { + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", + }); + Response response = await client.SubmitTranscriptionAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_SubmitTranscription_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234), "", ""); + Response response = client.SubmitTranscription(transcription); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_SubmitTranscription_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234), "", ""); + Response response = await client.SubmitTranscriptionAsync(transcription); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_SubmitTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + using RequestContent content = RequestContent.Create(new + { + links = new object(), + properties = new + { + wordLevelTimestampsEnabled = true, + displayFormWordLevelTimestampsEnabled = true, + channels = new object[] + { +1234 + }, + destinationContainerUrl = "http://localhost:3000", + punctuationMode = "None", + profanityFilterMode = "None", + timeToLiveHours = 1234, + error = new object(), + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + languageIdentification = new + { + mode = "Continuous", + candidateLocales = new object[] + { +"" + }, + speechModelMapping = new + { + key = new + { + self = "http://localhost:3000", + }, + }, + }, + }, + contentUrls = new object[] + { +"http://localhost:3000" + }, + contentContainerUrl = "http://localhost:3000", + locale = "", + displayName = "", + description = "", + customProperties = new + { + key = "", + }, + status = "NotStarted", + }); + Response response = client.SubmitTranscription(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_SubmitTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + using RequestContent content = RequestContent.Create(new + { + links = new object(), + properties = new + { + wordLevelTimestampsEnabled = true, + displayFormWordLevelTimestampsEnabled = true, + channels = new object[] + { +1234 + }, + destinationContainerUrl = "http://localhost:3000", + punctuationMode = "None", + profanityFilterMode = "None", + timeToLiveHours = 1234, + error = new object(), + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + languageIdentification = new + { + mode = "Continuous", + candidateLocales = new object[] + { +"" + }, + speechModelMapping = new + { + key = new + { + self = "http://localhost:3000", + }, + }, + }, + }, + contentUrls = new object[] + { +"http://localhost:3000" + }, + contentContainerUrl = "http://localhost:3000", + locale = "", + displayName = "", + description = "", + customProperties = new + { + key = "", + }, + status = "NotStarted", + }); + Response response = await client.SubmitTranscriptionAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_SubmitTranscription_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234) + { + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainerUrl = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentification = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = +{ +["key"] = new EntityReference(new Uri("http://localhost:3000")) +}, + }, + }, "", "") + { + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + ContentUrls = { new Uri("http://localhost:3000") }, + ContentContainerUrl = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = +{ +["key"] = "" +}, + Status = ApiStatus.NotStarted, + }; + Response response = client.SubmitTranscription(transcription); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_SubmitTranscription_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + AsynchronousTranscription transcription = new AsynchronousTranscription(new TranscriptionProperties(1234) + { + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainerUrl = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentification = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = +{ +["key"] = new EntityReference(new Uri("http://localhost:3000")) +}, + }, + }, "", "") + { + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + ContentUrls = { new Uri("http://localhost:3000") }, + ContentContainerUrl = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = +{ +["key"] = "" +}, + Status = ApiStatus.NotStarted, + }; + Response response = await client.SubmitTranscriptionAsync(transcription); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptions_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.GetTranscriptions(null, null, null, null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.GetTranscriptionsAsync(null, null, null, null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.GetTranscriptions(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.GetTranscriptionsAsync(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptions_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.GetTranscriptions(1234, 1234, "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("@nextLink").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.GetTranscriptionsAsync(1234, 1234, "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("@nextLink").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.GetTranscriptions(skip: 1234, top: 1234, filter: ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.GetTranscriptionsAsync(skip: 1234, top: 1234, filter: ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptionFiles_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.GetTranscriptionFiles("", null, null, null, null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptionFiles_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.GetTranscriptionFilesAsync("", null, null, null, null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptionFiles_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.GetTranscriptionFiles(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptionFiles_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.GetTranscriptionFilesAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptionFiles_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.GetTranscriptionFiles("", 1234, 1234, 1234, null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("@nextLink").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptionFiles_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.GetTranscriptionFilesAsync("", 1234, 1234, 1234, null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("values")[0].GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("values")[0].GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("@nextLink").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscriptionFiles_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.GetTranscriptionFiles("", skip: 1234, top: 1234, sasLifetimeMinutes: 1234); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscriptionFiles_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.GetTranscriptionFilesAsync("", skip: 1234, top: 1234, sasLifetimeMinutes: 1234); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.GetTranscription("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.GetTranscriptionAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscription_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.GetTranscription(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscription_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.GetTranscriptionAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.GetTranscription("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.GetTranscriptionAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_GetTranscription_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.GetTranscription(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_GetTranscription_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.GetTranscriptionAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_PatchTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + using RequestContent content = RequestContent.Create(new object()); + Response response = client.PatchTranscription("", content, new ContentType("application/json")); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_PatchTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + using RequestContent content = RequestContent.Create(new object()); + Response response = await client.PatchTranscriptionAsync("", content, new ContentType("application/json")); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_PatchTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + using RequestContent content = RequestContent.Create(new + { + displayName = "", + description = "", + customProperties = new + { + key = "", + }, + }); + Response response = client.PatchTranscription("", content, new ContentType("application/json")); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_PatchTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + using RequestContent content = RequestContent.Create(new + { + displayName = "", + description = "", + customProperties = new + { + key = "", + }, + }); + Response response = await client.PatchTranscriptionAsync("", content, new ContentType("application/json")); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("links").GetProperty("files").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("wordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("displayFormWordLevelTimestampsEnabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("channels")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("destinationContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("punctuationMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("profanityFilterMode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("error").GetProperty("message").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("enabled").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("diarization").GetProperty("maxSpeakers").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("mode").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("candidateLocales")[0].ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("languageIdentification").GetProperty("speechModelMapping").GetProperty("").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("model").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("dataset").GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("contentUrls")[0].ToString()); + Console.WriteLine(result.GetProperty("contentContainerUrl").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("customProperties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("lastActionDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_DeleteTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = client.DeleteTranscription(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_DeleteTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(); + + Response response = await client.DeleteTranscriptionAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_BatchTranscription_DeleteTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = client.DeleteTranscription(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_BatchTranscription_DeleteTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscription client = new SpeechToTextClient(endpoint, credential).GetBatchTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + Response response = await client.DeleteTranscriptionAsync(""); + + Console.WriteLine(response.Status); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tsp-location.yaml b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tsp-location.yaml new file mode 100644 index 000000000000..07b515cb2ea0 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.BatchTranscription/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/Speech.SpeechToText.Batch +commit: 32f635ac1beff851b1f2741ebcd7e91e3cbdc6ee +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/Azure.AI.SpeechToText.FastTranscription.sln b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/Azure.AI.SpeechToText.FastTranscription.sln new file mode 100644 index 000000000000..3d29909d7128 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/Azure.AI.SpeechToText.FastTranscription.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.SpeechToText.FastTranscription", "src\Azure.AI.SpeechToText.FastTranscription.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.SpeechToText.FastTranscription.Tests", "tests\Azure.AI.SpeechToText.FastTranscription.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/CHANGELOG.md b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/Directory.Build.props b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/README.md b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/README.md new file mode 100644 index 000000000000..a006865eb51b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/README.md @@ -0,0 +1,107 @@ +# Azure.AI.SpeechToText.FastTranscription client library for .NET + +Azure.AI.SpeechToText.FastTranscription is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.AI.SpeechToText.FastTranscription --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +### Service API versions + +The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version. + +For example, + +```C# Snippet:CreateClientForSpecificApiVersion +Uri endpoint = new Uri(""); +DefaultAzureCredential credential = new DefaultAzureCredential(); +ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.) +var client = new Client(endpoint, credential, options); +``` + +When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/README.png) \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/api/Azure.AI.SpeechToText.FastTranscription.net8.0.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/api/Azure.AI.SpeechToText.FastTranscription.net8.0.cs new file mode 100644 index 000000000000..7549ce6e9141 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/api/Azure.AI.SpeechToText.FastTranscription.net8.0.cs @@ -0,0 +1,158 @@ +namespace Azure.AI.SpeechToText.FastTranscription +{ + public static partial class AISpeechToTextFastTranscriptionModelFactory + { + public static Azure.AI.SpeechToText.FastTranscription.ChannelCombinedPhrases ChannelCombinedPhrases(int? channel = default(int?), string text = null) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.TimestampedWord TimestampedWord(string text = null, int offsetMilliseconds = 0, int durationMilliseconds = 0) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.TranscribedPhrase TranscribedPhrase(int? channel = default(int?), int? speaker = default(int?), int offsetMilliseconds = 0, int durationMilliseconds = 0, string text = null, System.Collections.Generic.IEnumerable words = null, string locale = null, float confidence = 0f) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.TranscribeResult TranscribeResult(int durationMilliseconds = 0, System.Collections.Generic.IEnumerable combinedPhrases = null, System.Collections.Generic.IEnumerable phrases = null) { throw null; } + } + public partial class ChannelCombinedPhrases : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ChannelCombinedPhrases() { } + public int? Channel { get { throw null; } } + public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.ChannelCombinedPhrases System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.ChannelCombinedPhrases System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ClientCustomizations + { + protected ClientCustomizations() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + } + public partial class FastTranscription + { + protected FastTranscription() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response Transcribe(Azure.Core.RequestContent content, string contentType, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response Transcribe(System.IO.Stream audio, Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata definition = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task TranscribeAsync(Azure.Core.RequestContent content, string contentType, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> TranscribeAsync(System.IO.Stream audio, Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata definition = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ProfanityFilterMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ProfanityFilterMode(string value) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode Masked { get { throw null; } } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode None { get { throw null; } } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode Removed { get { throw null; } } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode Tags { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode right) { throw null; } + public override string ToString() { throw null; } + } + public enum ServiceApiVersions + { + V20241115 = 0, + } + public partial class SpeechToTextClient + { + protected SpeechToTextClient() { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.SpeechToText.FastTranscription.SpeechToTextClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.AI.SpeechToText.FastTranscription.ClientCustomizations GetClientCustomizationsClient() { throw null; } + public virtual Azure.AI.SpeechToText.FastTranscription.FastTranscription GetFastTranscriptionClient(Azure.AI.SpeechToText.FastTranscription.ServiceApiVersions? serviceApiVersionsQueryParameter = default(Azure.AI.SpeechToText.FastTranscription.ServiceApiVersions?)) { throw null; } + } + public partial class SpeechToTextClientOptions : Azure.Core.ClientOptions + { + public SpeechToTextClientOptions(Azure.AI.SpeechToText.FastTranscription.SpeechToTextClientOptions.ServiceVersion version = Azure.AI.SpeechToText.FastTranscription.SpeechToTextClientOptions.ServiceVersion.V2024_11_15) { } + public Azure.AI.SpeechToText.FastTranscription.ServiceApiVersions? ServiceApiVersionsQueryParameter { get { throw null; } set { } } + public enum ServiceVersion + { + V2024_05_15_Preview = 1, + V2024_11_15 = 2, + } + } + public partial class TimestampedWord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TimestampedWord() { } + public int DurationMilliseconds { get { throw null; } } + public int OffsetMilliseconds { get { throw null; } } + public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TimestampedWord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TimestampedWord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribeDiarizationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscribeDiarizationProperties() { } + public bool? Enabled { get { throw null; } set { } } + public int? MaxSpeakers { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeDiarizationProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeDiarizationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribedPhrase : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscribedPhrase() { } + public int? Channel { get { throw null; } } + public float Confidence { get { throw null; } } + public int DurationMilliseconds { get { throw null; } } + public string Locale { get { throw null; } } + public int OffsetMilliseconds { get { throw null; } } + public int? Speaker { get { throw null; } } + public string Text { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Words { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribedPhrase System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribedPhrase System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribeMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscribeMetadata() { } + public System.Collections.Generic.IList Channels { get { throw null; } } + public Azure.AI.SpeechToText.FastTranscription.TranscribeDiarizationProperties Diarization { get { throw null; } set { } } + public System.Collections.Generic.IList Locales { get { throw null; } } + public System.Collections.Generic.IDictionary Models { get { throw null; } } + public Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode? ProfanityFilterMode { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribeResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscribeResult() { } + public System.Collections.Generic.IReadOnlyList CombinedPhrases { get { throw null; } } + public int DurationMilliseconds { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Phrases { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AISpeechToTextFastTranscriptionClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/api/Azure.AI.SpeechToText.FastTranscription.netstandard2.0.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/api/Azure.AI.SpeechToText.FastTranscription.netstandard2.0.cs new file mode 100644 index 000000000000..7549ce6e9141 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/api/Azure.AI.SpeechToText.FastTranscription.netstandard2.0.cs @@ -0,0 +1,158 @@ +namespace Azure.AI.SpeechToText.FastTranscription +{ + public static partial class AISpeechToTextFastTranscriptionModelFactory + { + public static Azure.AI.SpeechToText.FastTranscription.ChannelCombinedPhrases ChannelCombinedPhrases(int? channel = default(int?), string text = null) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.TimestampedWord TimestampedWord(string text = null, int offsetMilliseconds = 0, int durationMilliseconds = 0) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.TranscribedPhrase TranscribedPhrase(int? channel = default(int?), int? speaker = default(int?), int offsetMilliseconds = 0, int durationMilliseconds = 0, string text = null, System.Collections.Generic.IEnumerable words = null, string locale = null, float confidence = 0f) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.TranscribeResult TranscribeResult(int durationMilliseconds = 0, System.Collections.Generic.IEnumerable combinedPhrases = null, System.Collections.Generic.IEnumerable phrases = null) { throw null; } + } + public partial class ChannelCombinedPhrases : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ChannelCombinedPhrases() { } + public int? Channel { get { throw null; } } + public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.ChannelCombinedPhrases System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.ChannelCombinedPhrases System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ClientCustomizations + { + protected ClientCustomizations() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + } + public partial class FastTranscription + { + protected FastTranscription() { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response Transcribe(Azure.Core.RequestContent content, string contentType, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response Transcribe(System.IO.Stream audio, Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata definition = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task TranscribeAsync(Azure.Core.RequestContent content, string contentType, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> TranscribeAsync(System.IO.Stream audio, Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata definition = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ProfanityFilterMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ProfanityFilterMode(string value) { throw null; } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode Masked { get { throw null; } } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode None { get { throw null; } } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode Removed { get { throw null; } } + public static Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode Tags { get { throw null; } } + public bool Equals(Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode right) { throw null; } + public static implicit operator Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode (string value) { throw null; } + public static bool operator !=(Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode left, Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode right) { throw null; } + public override string ToString() { throw null; } + } + public enum ServiceApiVersions + { + V20241115 = 0, + } + public partial class SpeechToTextClient + { + protected SpeechToTextClient() { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public SpeechToTextClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.SpeechToText.FastTranscription.SpeechToTextClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.AI.SpeechToText.FastTranscription.ClientCustomizations GetClientCustomizationsClient() { throw null; } + public virtual Azure.AI.SpeechToText.FastTranscription.FastTranscription GetFastTranscriptionClient(Azure.AI.SpeechToText.FastTranscription.ServiceApiVersions? serviceApiVersionsQueryParameter = default(Azure.AI.SpeechToText.FastTranscription.ServiceApiVersions?)) { throw null; } + } + public partial class SpeechToTextClientOptions : Azure.Core.ClientOptions + { + public SpeechToTextClientOptions(Azure.AI.SpeechToText.FastTranscription.SpeechToTextClientOptions.ServiceVersion version = Azure.AI.SpeechToText.FastTranscription.SpeechToTextClientOptions.ServiceVersion.V2024_11_15) { } + public Azure.AI.SpeechToText.FastTranscription.ServiceApiVersions? ServiceApiVersionsQueryParameter { get { throw null; } set { } } + public enum ServiceVersion + { + V2024_05_15_Preview = 1, + V2024_11_15 = 2, + } + } + public partial class TimestampedWord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TimestampedWord() { } + public int DurationMilliseconds { get { throw null; } } + public int OffsetMilliseconds { get { throw null; } } + public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TimestampedWord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TimestampedWord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribeDiarizationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscribeDiarizationProperties() { } + public bool? Enabled { get { throw null; } set { } } + public int? MaxSpeakers { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeDiarizationProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeDiarizationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribedPhrase : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscribedPhrase() { } + public int? Channel { get { throw null; } } + public float Confidence { get { throw null; } } + public int DurationMilliseconds { get { throw null; } } + public string Locale { get { throw null; } } + public int OffsetMilliseconds { get { throw null; } } + public int? Speaker { get { throw null; } } + public string Text { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Words { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribedPhrase System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribedPhrase System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribeMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscribeMetadata() { } + public System.Collections.Generic.IList Channels { get { throw null; } } + public Azure.AI.SpeechToText.FastTranscription.TranscribeDiarizationProperties Diarization { get { throw null; } set { } } + public System.Collections.Generic.IList Locales { get { throw null; } } + public System.Collections.Generic.IDictionary Models { get { throw null; } } + public Azure.AI.SpeechToText.FastTranscription.ProfanityFilterMode? ProfanityFilterMode { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeMetadata System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TranscribeResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscribeResult() { } + public System.Collections.Generic.IReadOnlyList CombinedPhrases { get { throw null; } } + public int DurationMilliseconds { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Phrases { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.SpeechToText.FastTranscription.TranscribeResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AISpeechToTextFastTranscriptionClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Azure.AI.SpeechToText.FastTranscription.csproj b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Azure.AI.SpeechToText.FastTranscription.csproj new file mode 100644 index 000000000000..2c7bef09b766 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Azure.AI.SpeechToText.FastTranscription.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.SpeechToText.FastTranscription client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.SpeechToText.FastTranscription for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.SpeechToText.FastTranscription + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/AISpeechToTextFastTranscriptionClientBuilderExtensions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/AISpeechToTextFastTranscriptionClientBuilderExtensions.cs new file mode 100644 index 000000000000..073421cf1c1f --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/AISpeechToTextFastTranscriptionClientBuilderExtensions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.AI.SpeechToText.FastTranscription; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AISpeechToTextFastTranscriptionClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new SpeechToTextClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddSpeechToTextClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/AISpeechToTextFastTranscriptionModelFactory.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/AISpeechToTextFastTranscriptionModelFactory.cs new file mode 100644 index 000000000000..a70e49286c93 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/AISpeechToTextFastTranscriptionModelFactory.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// Model factory for models. + public static partial class AISpeechToTextFastTranscriptionModelFactory + { + /// Initializes a new instance of . + /// The duration of the audio in milliseconds. + /// The full transcript for each channel. + /// The transcription results segmented into phrases. + /// A new instance for mocking. + public static TranscribeResult TranscribeResult(int durationMilliseconds = default, IEnumerable combinedPhrases = null, IEnumerable phrases = null) + { + combinedPhrases ??= new List(); + phrases ??= new List(); + + return new TranscribeResult(durationMilliseconds, combinedPhrases?.ToList(), phrases?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The 0-based channel index. Only present if channel separation is enabled. + /// The complete transcribed text for the channel. + /// A new instance for mocking. + public static ChannelCombinedPhrases ChannelCombinedPhrases(int? channel = null, string text = null) + { + return new ChannelCombinedPhrases(channel, text, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The 0-based channel index. Only present if channel separation is enabled. + /// A unique integer number that is assigned to each speaker detected in the audio without particular order. Only present if speaker diarization is enabled. + /// The start offset of the phrase in milliseconds. + /// The duration of the phrase in milliseconds. + /// The transcribed text of the phrase. + /// The words that make up the phrase. Only present if word-level timestamps are enabled. + /// The locale of the phrase. + /// The confidence value for the phrase. + /// A new instance for mocking. + public static TranscribedPhrase TranscribedPhrase(int? channel = null, int? speaker = null, int offsetMilliseconds = default, int durationMilliseconds = default, string text = null, IEnumerable words = null, string locale = null, float confidence = default) + { + words ??= new List(); + + return new TranscribedPhrase( + channel, + speaker, + offsetMilliseconds, + durationMilliseconds, + text, + words?.ToList(), + locale, + confidence, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The recognized word, including punctuation. + /// The start offset of the word in milliseconds. + /// The duration of the word in milliseconds. + /// A new instance for mocking. + public static TimestampedWord TimestampedWord(string text = null, int offsetMilliseconds = default, int durationMilliseconds = default) + { + return new TimestampedWord(text, offsetMilliseconds, durationMilliseconds, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ChannelCombinedPhrases.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ChannelCombinedPhrases.Serialization.cs new file mode 100644 index 000000000000..46336cdfb449 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ChannelCombinedPhrases.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + public partial class ChannelCombinedPhrases : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChannelCombinedPhrases)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Channel)) + { + writer.WritePropertyName("channel"u8); + writer.WriteNumberValue(Channel.Value); + } + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChannelCombinedPhrases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChannelCombinedPhrases)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChannelCombinedPhrases(document.RootElement, options); + } + + internal static ChannelCombinedPhrases DeserializeChannelCombinedPhrases(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? channel = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("channel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + channel = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChannelCombinedPhrases(channel, text, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChannelCombinedPhrases)} does not support writing '{options.Format}' format."); + } + } + + ChannelCombinedPhrases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChannelCombinedPhrases(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChannelCombinedPhrases)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ChannelCombinedPhrases FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChannelCombinedPhrases(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ChannelCombinedPhrases.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ChannelCombinedPhrases.cs new file mode 100644 index 000000000000..ba53665b2e5c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ChannelCombinedPhrases.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// The full transcript per channel. + public partial class ChannelCombinedPhrases + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The complete transcribed text for the channel. + /// is null. + internal ChannelCombinedPhrases(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// The 0-based channel index. Only present if channel separation is enabled. + /// The complete transcribed text for the channel. + /// Keeps track of any properties unknown to the library. + internal ChannelCombinedPhrases(int? channel, string text, IDictionary serializedAdditionalRawData) + { + Channel = channel; + Text = text; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChannelCombinedPhrases() + { + } + + /// The 0-based channel index. Only present if channel separation is enabled. + public int? Channel { get; } + /// The complete transcribed text for the channel. + public string Text { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ClientCustomizations.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ClientCustomizations.cs new file mode 100644 index 000000000000..59fcd9b3bcc1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ClientCustomizations.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + // Data plane generated sub-client. + /// The ClientCustomizations sub-client. + public partial class ClientCustomizations + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of ClientCustomizations for mocking. + protected ClientCustomizations() + { + } + + /// Initializes a new instance of ClientCustomizations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + internal ClientCustomizations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Docs/FastTranscription.xml b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Docs/FastTranscription.xml new file mode 100644 index 000000000000..ec04df0d8090 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Docs/FastTranscription.xml @@ -0,0 +1,215 @@ + + + + + +This sample shows how to call TranscribeAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + +Response response = await client.TranscribeAsync(null); +]]> +This sample shows how to call TranscribeAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +TranscribeMetadata definition = new TranscribeMetadata +{ + Locales = { "" }, + Models = + { + ["key"] = new Uri("http://localhost:3000") + }, + ProfanityFilterMode = ProfanityFilterMode.None, + Diarization = new TranscribeDiarizationProperties + { + Enabled = true, + MaxSpeakers = 1234, + }, + Channels = { 1234 }, +}; +Response response = await client.TranscribeAsync(null, definition: definition); +]]> + + + +This sample shows how to call Transcribe. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + +Response response = client.Transcribe(null); +]]> +This sample shows how to call Transcribe with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +TranscribeMetadata definition = new TranscribeMetadata +{ + Locales = { "" }, + Models = + { + ["key"] = new Uri("http://localhost:3000") + }, + ProfanityFilterMode = ProfanityFilterMode.None, + Diarization = new TranscribeDiarizationProperties + { + Enabled = true, + MaxSpeakers = 1234, + }, + Channels = { 1234 }, +}; +Response response = client.Transcribe(null, definition: definition); +]]> + + + +This sample shows how to call TranscribeAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + +using RequestContent content = RequestContent.Create(new +{ + audio = File.OpenRead(""), +}); +Response response = await client.TranscribeAsync(content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); +]]> +This sample shows how to call TranscribeAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +using RequestContent content = RequestContent.Create(new +{ + definition = new + { + locales = new object[] + { + "" + }, + models = new + { + key = "http://localhost:3000", + }, + profanityFilterMode = "None", + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + channels = new object[] + { + 1234 + }, + }, + audio = File.OpenRead(""), +}); +Response response = await client.TranscribeAsync(content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("channel").ToString()); +Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("channel").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("speaker").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("offsetMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); +]]> + + + +This sample shows how to call Transcribe and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + +using RequestContent content = RequestContent.Create(new +{ + audio = File.OpenRead(""), +}); +Response response = client.Transcribe(content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); +]]> +This sample shows how to call Transcribe with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + +using RequestContent content = RequestContent.Create(new +{ + definition = new + { + locales = new object[] + { + "" + }, + models = new + { + key = "http://localhost:3000", + }, + profanityFilterMode = "None", + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + channels = new object[] + { + 1234 + }, + }, + audio = File.OpenRead(""), +}); +Response response = client.Transcribe(content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("channel").ToString()); +Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("channel").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("speaker").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("offsetMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("durationMilliseconds").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/FastTranscription.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/FastTranscription.cs new file mode 100644 index 000000000000..0a10bb10aa3b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/FastTranscription.cs @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + // Data plane generated sub-client. + /// The FastTranscription sub-client. + public partial class FastTranscription + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly ServiceApiVersions? _serviceApiVersionsQueryParameter; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of FastTranscription for mocking. + protected FastTranscription() + { + } + + /// Initializes a new instance of FastTranscription. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// The identifier of the transcription. The default value is "2024-11-15". + internal FastTranscription(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, ServiceApiVersions? serviceApiVersionsQueryParameter) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _serviceApiVersionsQueryParameter = serviceApiVersionsQueryParameter; + } + + /// Transcribes the provided audio stream. + /// The content of the audio file to be transcribed. The audio file must be shorter than 2 hours in audio duration and smaller than 250 MB in size. + /// Metadata for a fast transcription request. This field contains a JSON-serialized object of type `TranscribeDefinition`. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> TranscribeAsync(Stream audio, TranscribeMetadata definition = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(audio, nameof(audio)); + + TranscribeRequest transcribeRequest = new TranscribeRequest(definition, audio, null); + using MultipartFormDataRequestContent content = transcribeRequest.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await TranscribeAsync(content, content.ContentType, context).ConfigureAwait(false); + return Response.FromValue(TranscribeResult.FromResponse(response), response); + } + + /// Transcribes the provided audio stream. + /// The content of the audio file to be transcribed. The audio file must be shorter than 2 hours in audio duration and smaller than 250 MB in size. + /// Metadata for a fast transcription request. This field contains a JSON-serialized object of type `TranscribeDefinition`. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Transcribe(Stream audio, TranscribeMetadata definition = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(audio, nameof(audio)); + + TranscribeRequest transcribeRequest = new TranscribeRequest(definition, audio, null); + using MultipartFormDataRequestContent content = transcribeRequest.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Transcribe(content, content.ContentType, context); + return Response.FromValue(TranscribeResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Transcribes the provided audio stream. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// request content type. Allowed values: "multipart/form-data". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task TranscribeAsync(RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("FastTranscription.Transcribe"); + scope.Start(); + try + { + using HttpMessage message = CreateTranscribeRequest(content, contentType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes the provided audio stream. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// request content type. Allowed values: "multipart/form-data". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Transcribe(RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("FastTranscription.Transcribe"); + scope.Start(); + try + { + using HttpMessage message = CreateTranscribeRequest(content, contentType, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateTranscribeRequest(RequestContent content, string contentType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/speechtotext", false); + uri.AppendPath("/transcriptions:transcribe", false); + if (_serviceApiVersionsQueryParameter != null) + { + uri.AppendQuery("api-version", _serviceApiVersionsQueryParameter.Value.ToSerialString(), true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", contentType); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Argument.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..3deed96c78d8 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..a8c4fd2a6a0c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ChangeTrackingList.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..29a993f38cc6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..887d12cc8fcd --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/MultipartFormDataRequestContent.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/MultipartFormDataRequestContent.cs new file mode 100644 index 000000000000..019c0f8c1a48 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/MultipartFormDataRequestContent.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.IO; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal class MultipartFormDataRequestContent : RequestContent + { + private readonly System.Net.Http.MultipartFormDataContent _multipartContent; + private static readonly Random _random = new Random(); + private static readonly char[] _boundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray(); + + public MultipartFormDataRequestContent() + { + _multipartContent = new System.Net.Http.MultipartFormDataContent(CreateBoundary()); + } + + public string ContentType + { + get + { + return _multipartContent.Headers.ContentType.ToString(); + } + } + + internal HttpContent HttpContent => _multipartContent; + + private static string CreateBoundary() + { + Span chars = new char[70]; + byte[] random = new byte[70]; + _random.NextBytes(random); + int mask = 255 >> 2; + for (int i = 0; i < 70; i++) + { + chars[i] = _boundaryValues[random[i] & mask]; + } + return chars.ToString(); + } + + public void Add(string content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new StringContent(content), name, filename, contentType); + } + + public void Add(int content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(long content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(float content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(double content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(decimal content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(bool content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content ? "true" : "false"; + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(Stream content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new StreamContent(content), name, filename, contentType); + } + + public void Add(byte[] content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new ByteArrayContent(content), name, filename, contentType); + } + + public void Add(BinaryData content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new ByteArrayContent(content.ToArray()), name, filename, contentType); + } + + private void Add(HttpContent content, string name, string filename, string contentType) + { + if (filename != null) + { + Argument.AssertNotNullOrEmpty(filename, nameof(filename)); + AddFilenameHeader(content, name, filename); + } + if (contentType != null) + { + Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); + AddContentTypeHeader(content, contentType); + } + _multipartContent.Add(content, name); + } + + public static void AddFilenameHeader(HttpContent content, string name, string filename) + { + ContentDispositionHeaderValue header = new ContentDispositionHeaderValue("form-data") { Name = name, FileName = filename }; + content.Headers.ContentDisposition = header; + } + + public static void AddContentTypeHeader(HttpContent content, string contentType) + { + MediaTypeHeaderValue header = new MediaTypeHeaderValue(contentType); + content.Headers.ContentType = header; + } + + public override bool TryComputeLength(out long length) + { + if (_multipartContent.Headers.ContentLength is long contentLength) + { + length = contentLength; + return true; + } + length = 0; + return false; + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { +#if NET6_0_OR_GREATER + _multipartContent.CopyTo(stream, default, cancellationToken); +#else +#pragma warning disable AZC0107 + _multipartContent.CopyToAsync(stream).EnsureCompleted(); +#pragma warning restore AZC0107 +#endif + } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { +#if NET6_0_OR_GREATER + await _multipartContent.CopyToAsync(stream, cancellationToken).ConfigureAwait(false); +#else + await _multipartContent.CopyToAsync(stream).ConfigureAwait(false); +#endif + } + + public override void Dispose() + { + _multipartContent.Dispose(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Optional.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..1ee0b0bc354c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..660a31b3784e --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ProfanityFilterMode.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ProfanityFilterMode.cs new file mode 100644 index 000000000000..880e07bfce74 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ProfanityFilterMode.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// Mode of profanity filtering. + public readonly partial struct ProfanityFilterMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProfanityFilterMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string RemovedValue = "Removed"; + private const string TagsValue = "Tags"; + private const string MaskedValue = "Masked"; + + /// Disable profanity filtering. + public static ProfanityFilterMode None { get; } = new ProfanityFilterMode(NoneValue); + /// Remove profanity. + public static ProfanityFilterMode Removed { get; } = new ProfanityFilterMode(RemovedValue); + /// Add "profanity" XML tags</Profanity>. + public static ProfanityFilterMode Tags { get; } = new ProfanityFilterMode(TagsValue); + /// Mask the profanity with * except of the first letter, e.g., f***. + public static ProfanityFilterMode Masked { get; } = new ProfanityFilterMode(MaskedValue); + /// Determines if two values are the same. + public static bool operator ==(ProfanityFilterMode left, ProfanityFilterMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProfanityFilterMode left, ProfanityFilterMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ProfanityFilterMode(string value) => new ProfanityFilterMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProfanityFilterMode other && Equals(other); + /// + public bool Equals(ProfanityFilterMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ServiceApiVersions.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ServiceApiVersions.Serialization.cs new file mode 100644 index 000000000000..1de72d6799cc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ServiceApiVersions.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal static partial class ServiceApiVersionsExtensions + { + public static string ToSerialString(this ServiceApiVersions value) => value switch + { + ServiceApiVersions.V20241115 => "2024-11-15", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ServiceApiVersions value.") + }; + + public static ServiceApiVersions ToServiceApiVersions(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "2024-11-15")) return ServiceApiVersions.V20241115; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ServiceApiVersions value."); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ServiceApiVersions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ServiceApiVersions.cs new file mode 100644 index 000000000000..7ad7158866d4 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/ServiceApiVersions.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// Service API versions. + public enum ServiceApiVersions + { + /// 2024-11-15. + V20241115 + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/SpeechToTextClient.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/SpeechToTextClient.cs new file mode 100644 index 000000000000..c098f09a413c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/SpeechToTextClient.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + // Data plane generated client. + /// The SpeechToText service client. + public partial class SpeechToTextClient + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of SpeechToTextClient for mocking. + protected SpeechToTextClient() + { + } + + /// Initializes a new instance of SpeechToTextClient. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public SpeechToTextClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new SpeechToTextClientOptions()) + { + } + + /// Initializes a new instance of SpeechToTextClient. + /// Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public SpeechToTextClient(Uri endpoint, AzureKeyCredential credential, SpeechToTextClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new SpeechToTextClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + private ClientCustomizations _cachedClientCustomizations; + + /// Initializes a new instance of ClientCustomizations. + public virtual ClientCustomizations GetClientCustomizationsClient() + { + return Volatile.Read(ref _cachedClientCustomizations) ?? Interlocked.CompareExchange(ref _cachedClientCustomizations, new ClientCustomizations(ClientDiagnostics, _pipeline, _keyCredential, _endpoint), null) ?? _cachedClientCustomizations; + } + + /// Initializes a new instance of FastTranscription. + /// The identifier of the transcription. The default value is "2024-11-15". + public virtual FastTranscription GetFastTranscriptionClient(ServiceApiVersions? serviceApiVersionsQueryParameter = null) + { + return new FastTranscription(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, serviceApiVersionsQueryParameter); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/SpeechToTextClientOptions.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/SpeechToTextClientOptions.cs new file mode 100644 index 000000000000..efadd968624c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/SpeechToTextClientOptions.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// Client options for SpeechToTextClient. + public partial class SpeechToTextClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_11_15; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-05-15-preview". + V2024_05_15_Preview = 1, + /// Service version "2024-11-15". + V2024_11_15 = 2, + } + + internal string Version { get; } + + /// Initializes new instance of SpeechToTextClientOptions. + public SpeechToTextClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_05_15_Preview => "2024-05-15-preview", + ServiceVersion.V2024_11_15 => "2024-11-15", + _ => throw new NotSupportedException() + }; + } + + /// The identifier of the transcription. The default value is "2024-11-15". + public ServiceApiVersions? ServiceApiVersionsQueryParameter { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TimestampedWord.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TimestampedWord.Serialization.cs new file mode 100644 index 000000000000..4fadb6939e26 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TimestampedWord.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + public partial class TimestampedWord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimestampedWord)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("offsetMilliseconds"u8); + writer.WriteNumberValue(OffsetMilliseconds); + writer.WritePropertyName("durationMilliseconds"u8); + writer.WriteNumberValue(DurationMilliseconds); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TimestampedWord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimestampedWord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimestampedWord(document.RootElement, options); + } + + internal static TimestampedWord DeserializeTimestampedWord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + int offsetMilliseconds = default; + int durationMilliseconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("offsetMilliseconds"u8)) + { + offsetMilliseconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("durationMilliseconds"u8)) + { + durationMilliseconds = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TimestampedWord(text, offsetMilliseconds, durationMilliseconds, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TimestampedWord)} does not support writing '{options.Format}' format."); + } + } + + TimestampedWord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTimestampedWord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimestampedWord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TimestampedWord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTimestampedWord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TimestampedWord.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TimestampedWord.cs new file mode 100644 index 000000000000..0d62b0d0ec40 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TimestampedWord.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// Time-stamped word in the display form. + public partial class TimestampedWord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The recognized word, including punctuation. + /// The start offset of the word in milliseconds. + /// The duration of the word in milliseconds. + /// is null. + internal TimestampedWord(string text, int offsetMilliseconds, int durationMilliseconds) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + OffsetMilliseconds = offsetMilliseconds; + DurationMilliseconds = durationMilliseconds; + } + + /// Initializes a new instance of . + /// The recognized word, including punctuation. + /// The start offset of the word in milliseconds. + /// The duration of the word in milliseconds. + /// Keeps track of any properties unknown to the library. + internal TimestampedWord(string text, int offsetMilliseconds, int durationMilliseconds, IDictionary serializedAdditionalRawData) + { + Text = text; + OffsetMilliseconds = offsetMilliseconds; + DurationMilliseconds = durationMilliseconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TimestampedWord() + { + } + + /// The recognized word, including punctuation. + public string Text { get; } + /// The start offset of the word in milliseconds. + public int OffsetMilliseconds { get; } + /// The duration of the word in milliseconds. + public int DurationMilliseconds { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeDiarizationProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeDiarizationProperties.Serialization.cs new file mode 100644 index 000000000000..ea74034191fa --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeDiarizationProperties.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + public partial class TranscribeDiarizationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeDiarizationProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(MaxSpeakers)) + { + writer.WritePropertyName("maxSpeakers"u8); + writer.WriteNumberValue(MaxSpeakers.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscribeDiarizationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeDiarizationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribeDiarizationProperties(document.RootElement, options); + } + + internal static TranscribeDiarizationProperties DeserializeTranscribeDiarizationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? enabled = default; + int? maxSpeakers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("maxSpeakers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxSpeakers = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribeDiarizationProperties(enabled, maxSpeakers, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscribeDiarizationProperties)} does not support writing '{options.Format}' format."); + } + } + + TranscribeDiarizationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribeDiarizationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribeDiarizationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscribeDiarizationProperties FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribeDiarizationProperties(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeDiarizationProperties.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeDiarizationProperties.cs new file mode 100644 index 000000000000..4418b45f3fd8 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeDiarizationProperties.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// The diarization settings. Diarization settings must be specified to enable diarization. + public partial class TranscribeDiarizationProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TranscribeDiarizationProperties() + { + } + + /// Initializes a new instance of . + /// Gets or sets a value indicating whether speaker diarization is enabled. + /// Gets or sets a hint for the maximum number of speakers for diarization. Must be greater than 1 and less than 36. + /// Keeps track of any properties unknown to the library. + internal TranscribeDiarizationProperties(bool? enabled, int? maxSpeakers, IDictionary serializedAdditionalRawData) + { + Enabled = enabled; + MaxSpeakers = maxSpeakers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets a value indicating whether speaker diarization is enabled. + public bool? Enabled { get; set; } + /// Gets or sets a hint for the maximum number of speakers for diarization. Must be greater than 1 and less than 36. + public int? MaxSpeakers { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeMetadata.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeMetadata.Serialization.cs new file mode 100644 index 000000000000..5742299ccdea --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeMetadata.Serialization.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + public partial class TranscribeMetadata : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeMetadata)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Locales)) + { + writer.WritePropertyName("locales"u8); + writer.WriteStartArray(); + foreach (var item in Locales) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Models)) + { + writer.WritePropertyName("models"u8); + writer.WriteStartObject(); + foreach (var item in Models) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value.AbsoluteUri); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(ProfanityFilterMode)) + { + writer.WritePropertyName("profanityFilterMode"u8); + writer.WriteStringValue(ProfanityFilterMode.Value.ToString()); + } + if (Optional.IsDefined(Diarization)) + { + writer.WritePropertyName("diarization"u8); + writer.WriteObjectValue(Diarization, options); + } + if (Optional.IsCollectionDefined(Channels)) + { + writer.WritePropertyName("channels"u8); + writer.WriteStartArray(); + foreach (var item in Channels) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscribeMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeMetadata)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribeMetadata(document.RootElement, options); + } + + internal static TranscribeMetadata DeserializeTranscribeMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList locales = default; + IDictionary models = default; + ProfanityFilterMode? profanityFilterMode = default; + TranscribeDiarizationProperties diarization = default; + IList channels = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("locales"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + locales = array; + continue; + } + if (property.NameEquals("models"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, new Uri(property0.Value.GetString())); + } + } + models = dictionary; + continue; + } + if (property.NameEquals("profanityFilterMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profanityFilterMode = new ProfanityFilterMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("diarization"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diarization = TranscribeDiarizationProperties.DeserializeTranscribeDiarizationProperties(property.Value, options); + continue; + } + if (property.NameEquals("channels"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + channels = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribeMetadata( + locales ?? new ChangeTrackingList(), + models ?? new ChangeTrackingDictionary(), + profanityFilterMode, + diarization, + channels ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscribeMetadata)} does not support writing '{options.Format}' format."); + } + } + + TranscribeMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribeMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribeMetadata)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscribeMetadata FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribeMetadata(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeMetadata.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeMetadata.cs new file mode 100644 index 000000000000..adad73f70aa9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeMetadata.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// Metadata for a fast transcription request. + public partial class TranscribeMetadata + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TranscribeMetadata() + { + Locales = new ChangeTrackingList(); + Models = new ChangeTrackingDictionary(); + Channels = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of possible locales for the transcription. If not specified, the locale of the speech in the audio is detected automatically from all supported locales. + /// Maps some or all candidate locales to a model URI to be used for transcription. If no mapping is given, the default model for the locale is used. + /// Mode of profanity filtering. + /// Mode of diarization. + /// The 0-based indices of the channels to be transcribed separately. If not specified, multiple channels are merged and transcribed jointly. Only up to two channels are supported. + /// Keeps track of any properties unknown to the library. + internal TranscribeMetadata(IList locales, IDictionary models, ProfanityFilterMode? profanityFilterMode, TranscribeDiarizationProperties diarization, IList channels, IDictionary serializedAdditionalRawData) + { + Locales = locales; + Models = models; + ProfanityFilterMode = profanityFilterMode; + Diarization = diarization; + Channels = channels; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of possible locales for the transcription. If not specified, the locale of the speech in the audio is detected automatically from all supported locales. + public IList Locales { get; } + /// Maps some or all candidate locales to a model URI to be used for transcription. If no mapping is given, the default model for the locale is used. + public IDictionary Models { get; } + /// Mode of profanity filtering. + public ProfanityFilterMode? ProfanityFilterMode { get; set; } + /// Mode of diarization. + public TranscribeDiarizationProperties Diarization { get; set; } + /// The 0-based indices of the channels to be transcribed separately. If not specified, multiple channels are merged and transcribed jointly. Only up to two channels are supported. + public IList Channels { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeRequest.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeRequest.Serialization.cs new file mode 100644 index 000000000000..eb21c99e614c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeRequest.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + internal partial class TranscribeRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Definition)) + { + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + } + writer.WritePropertyName("audio"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(global::System.BinaryData.FromStream(Audio)); +#else + using (JsonDocument document = JsonDocument.Parse(BinaryData.FromStream(Audio))) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscribeRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribeRequest(document.RootElement, options); + } + + internal static TranscribeRequest DeserializeTranscribeRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TranscribeMetadata definition = default; + Stream audio = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("definition"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + definition = TranscribeMetadata.DeserializeTranscribeMetadata(property.Value, options); + continue; + } + if (property.NameEquals("audio"u8)) + { + audio = BinaryData.FromString(property.Value.GetRawText()).ToStream(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribeRequest(definition, audio, serializedAdditionalRawData); + } + + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataRequestContent content = ToMultipartRequestContent(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) + { + return BinaryData.FromStream(stream); + } + else + { + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + } + } + + internal virtual MultipartFormDataRequestContent ToMultipartRequestContent() + { + MultipartFormDataRequestContent content = new MultipartFormDataRequestContent(); + if (Optional.IsDefined(Definition)) + { + content.Add(ModelReaderWriter.Write(Definition, ModelSerializationExtensions.WireOptions), "definition"); + } + content.Add(Audio, "audio", "audio", "application/octet-stream"); + return content; + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(TranscribeRequest)} does not support writing '{options.Format}' format."); + } + } + + TranscribeRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribeRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribeRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscribeRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribeRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeRequest.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeRequest.cs new file mode 100644 index 000000000000..b1640b15deb2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeRequest.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.IO; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// The TranscribeRequest. + internal partial class TranscribeRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The content of the audio file to be transcribed. The audio file must be shorter than 2 hours in audio duration and smaller than 250 MB in size. + /// is null. + internal TranscribeRequest(Stream audio) + { + Argument.AssertNotNull(audio, nameof(audio)); + + Audio = audio; + } + + /// Initializes a new instance of . + /// Metadata for a fast transcription request. This field contains a JSON-serialized object of type `TranscribeDefinition`. + /// The content of the audio file to be transcribed. The audio file must be shorter than 2 hours in audio duration and smaller than 250 MB in size. + /// Keeps track of any properties unknown to the library. + internal TranscribeRequest(TranscribeMetadata definition, Stream audio, IDictionary serializedAdditionalRawData) + { + Definition = definition; + Audio = audio; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscribeRequest() + { + } + + /// Metadata for a fast transcription request. This field contains a JSON-serialized object of type `TranscribeDefinition`. + public TranscribeMetadata Definition { get; } + /// The content of the audio file to be transcribed. The audio file must be shorter than 2 hours in audio duration and smaller than 250 MB in size. + public Stream Audio { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeResult.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeResult.Serialization.cs new file mode 100644 index 000000000000..9927f0a94fa9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeResult.Serialization.cs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + public partial class TranscribeResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("durationMilliseconds"u8); + writer.WriteNumberValue(DurationMilliseconds); + writer.WritePropertyName("combinedPhrases"u8); + writer.WriteStartArray(); + foreach (var item in CombinedPhrases) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("phrases"u8); + writer.WriteStartArray(); + foreach (var item in Phrases) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscribeResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribeResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribeResult(document.RootElement, options); + } + + internal static TranscribeResult DeserializeTranscribeResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int durationMilliseconds = default; + IReadOnlyList combinedPhrases = default; + IReadOnlyList phrases = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("durationMilliseconds"u8)) + { + durationMilliseconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("combinedPhrases"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChannelCombinedPhrases.DeserializeChannelCombinedPhrases(item, options)); + } + combinedPhrases = array; + continue; + } + if (property.NameEquals("phrases"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TranscribedPhrase.DeserializeTranscribedPhrase(item, options)); + } + phrases = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribeResult(durationMilliseconds, combinedPhrases, phrases, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscribeResult)} does not support writing '{options.Format}' format."); + } + } + + TranscribeResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribeResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribeResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscribeResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribeResult(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeResult.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeResult.cs new file mode 100644 index 000000000000..0357a7f8fb08 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribeResult.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// The result of the transcribe operation. + public partial class TranscribeResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The duration of the audio in milliseconds. + /// The full transcript for each channel. + /// The transcription results segmented into phrases. + /// or is null. + internal TranscribeResult(int durationMilliseconds, IEnumerable combinedPhrases, IEnumerable phrases) + { + Argument.AssertNotNull(combinedPhrases, nameof(combinedPhrases)); + Argument.AssertNotNull(phrases, nameof(phrases)); + + DurationMilliseconds = durationMilliseconds; + CombinedPhrases = combinedPhrases.ToList(); + Phrases = phrases.ToList(); + } + + /// Initializes a new instance of . + /// The duration of the audio in milliseconds. + /// The full transcript for each channel. + /// The transcription results segmented into phrases. + /// Keeps track of any properties unknown to the library. + internal TranscribeResult(int durationMilliseconds, IReadOnlyList combinedPhrases, IReadOnlyList phrases, IDictionary serializedAdditionalRawData) + { + DurationMilliseconds = durationMilliseconds; + CombinedPhrases = combinedPhrases; + Phrases = phrases; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscribeResult() + { + } + + /// The duration of the audio in milliseconds. + public int DurationMilliseconds { get; } + /// The full transcript for each channel. + public IReadOnlyList CombinedPhrases { get; } + /// The transcription results segmented into phrases. + public IReadOnlyList Phrases { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribedPhrase.Serialization.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribedPhrase.Serialization.cs new file mode 100644 index 000000000000..cca635ec0fbe --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribedPhrase.Serialization.cs @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + public partial class TranscribedPhrase : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribedPhrase)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Channel)) + { + writer.WritePropertyName("channel"u8); + writer.WriteNumberValue(Channel.Value); + } + if (Optional.IsDefined(Speaker)) + { + writer.WritePropertyName("speaker"u8); + writer.WriteNumberValue(Speaker.Value); + } + writer.WritePropertyName("offsetMilliseconds"u8); + writer.WriteNumberValue(OffsetMilliseconds); + writer.WritePropertyName("durationMilliseconds"u8); + writer.WriteNumberValue(DurationMilliseconds); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + if (Optional.IsCollectionDefined(Words)) + { + writer.WritePropertyName("words"u8); + writer.WriteStartArray(); + foreach (var item in Words) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Locale)) + { + writer.WritePropertyName("locale"u8); + writer.WriteStringValue(Locale); + } + writer.WritePropertyName("confidence"u8); + writer.WriteNumberValue(Confidence); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscribedPhrase IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribedPhrase)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribedPhrase(document.RootElement, options); + } + + internal static TranscribedPhrase DeserializeTranscribedPhrase(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? channel = default; + int? speaker = default; + int offsetMilliseconds = default; + int durationMilliseconds = default; + string text = default; + IReadOnlyList words = default; + string locale = default; + float confidence = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("channel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + channel = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("speaker"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + speaker = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("offsetMilliseconds"u8)) + { + offsetMilliseconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("durationMilliseconds"u8)) + { + durationMilliseconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("words"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TimestampedWord.DeserializeTimestampedWord(item, options)); + } + words = array; + continue; + } + if (property.NameEquals("locale"u8)) + { + locale = property.Value.GetString(); + continue; + } + if (property.NameEquals("confidence"u8)) + { + confidence = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribedPhrase( + channel, + speaker, + offsetMilliseconds, + durationMilliseconds, + text, + words ?? new ChangeTrackingList(), + locale, + confidence, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscribedPhrase)} does not support writing '{options.Format}' format."); + } + } + + TranscribedPhrase IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribedPhrase(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribedPhrase)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TranscribedPhrase FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribedPhrase(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribedPhrase.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribedPhrase.cs new file mode 100644 index 000000000000..c33e79ee44a8 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Generated/TranscribedPhrase.cs @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.SpeechToText.FastTranscription +{ + /// A transcribed phrase. + public partial class TranscribedPhrase + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The start offset of the phrase in milliseconds. + /// The duration of the phrase in milliseconds. + /// The transcribed text of the phrase. + /// The confidence value for the phrase. + /// is null. + internal TranscribedPhrase(int offsetMilliseconds, int durationMilliseconds, string text, float confidence) + { + Argument.AssertNotNull(text, nameof(text)); + + OffsetMilliseconds = offsetMilliseconds; + DurationMilliseconds = durationMilliseconds; + Text = text; + Words = new ChangeTrackingList(); + Confidence = confidence; + } + + /// Initializes a new instance of . + /// The 0-based channel index. Only present if channel separation is enabled. + /// A unique integer number that is assigned to each speaker detected in the audio without particular order. Only present if speaker diarization is enabled. + /// The start offset of the phrase in milliseconds. + /// The duration of the phrase in milliseconds. + /// The transcribed text of the phrase. + /// The words that make up the phrase. Only present if word-level timestamps are enabled. + /// The locale of the phrase. + /// The confidence value for the phrase. + /// Keeps track of any properties unknown to the library. + internal TranscribedPhrase(int? channel, int? speaker, int offsetMilliseconds, int durationMilliseconds, string text, IReadOnlyList words, string locale, float confidence, IDictionary serializedAdditionalRawData) + { + Channel = channel; + Speaker = speaker; + OffsetMilliseconds = offsetMilliseconds; + DurationMilliseconds = durationMilliseconds; + Text = text; + Words = words; + Locale = locale; + Confidence = confidence; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscribedPhrase() + { + } + + /// The 0-based channel index. Only present if channel separation is enabled. + public int? Channel { get; } + /// A unique integer number that is assigned to each speaker detected in the audio without particular order. Only present if speaker diarization is enabled. + public int? Speaker { get; } + /// The start offset of the phrase in milliseconds. + public int OffsetMilliseconds { get; } + /// The duration of the phrase in milliseconds. + public int DurationMilliseconds { get; } + /// The transcribed text of the phrase. + public string Text { get; } + /// The words that make up the phrase. Only present if word-level timestamps are enabled. + public IReadOnlyList Words { get; } + /// The locale of the phrase. + public string Locale { get; } + /// The confidence value for the phrase. + public float Confidence { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Properties/AssemblyInfo.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..c8be04c4c84a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.AI.SpeechToText.FastTranscription.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tests/Azure.AI.SpeechToText.FastTranscription.Tests.csproj b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tests/Azure.AI.SpeechToText.FastTranscription.Tests.csproj new file mode 100644 index 000000000000..f100316ee9d7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tests/Azure.AI.SpeechToText.FastTranscription.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tests/Generated/Samples/Samples_FastTranscription.cs b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tests/Generated/Samples/Samples_FastTranscription.cs new file mode 100644 index 000000000000..f7c9e6e0f9ae --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tests/Generated/Samples/Samples_FastTranscription.cs @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.IO; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.SpeechToText.FastTranscription.Samples +{ + public partial class Samples_FastTranscription + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FastTranscription_Transcribe_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + + using RequestContent content = RequestContent.Create(new + { + audio = File.OpenRead(""), + }); + Response response = client.Transcribe(content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FastTranscription_Transcribe_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + + using RequestContent content = RequestContent.Create(new + { + audio = File.OpenRead(""), + }); + Response response = await client.TranscribeAsync(content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FastTranscription_Transcribe_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + + Response response = client.Transcribe(null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FastTranscription_Transcribe_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(); + + Response response = await client.TranscribeAsync(null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FastTranscription_Transcribe_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + using RequestContent content = RequestContent.Create(new + { + definition = new + { + locales = new object[] + { +"" + }, + models = new + { + key = "http://localhost:3000", + }, + profanityFilterMode = "None", + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + channels = new object[] + { +1234 + }, + }, + audio = File.OpenRead(""), + }); + Response response = client.Transcribe(content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("channel").ToString()); + Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("channel").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("speaker").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("offsetMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FastTranscription_Transcribe_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + using RequestContent content = RequestContent.Create(new + { + definition = new + { + locales = new object[] + { +"" + }, + models = new + { + key = "http://localhost:3000", + }, + profanityFilterMode = "None", + diarization = new + { + enabled = true, + maxSpeakers = 1234, + }, + channels = new object[] + { +1234 + }, + }, + audio = File.OpenRead(""), + }); + Response response = await client.TranscribeAsync(content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("channel").ToString()); + Console.WriteLine(result.GetProperty("combinedPhrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("channel").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("speaker").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("offsetMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("offsetMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("words")[0].GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("phrases")[0].GetProperty("confidence").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FastTranscription_Transcribe_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + TranscribeMetadata definition = new TranscribeMetadata + { + Locales = { "" }, + Models = +{ +["key"] = new Uri("http://localhost:3000") +}, + ProfanityFilterMode = ProfanityFilterMode.None, + Diarization = new TranscribeDiarizationProperties + { + Enabled = true, + MaxSpeakers = 1234, + }, + Channels = { 1234 }, + }; + Response response = client.Transcribe(null, definition: definition); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FastTranscription_Transcribe_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + FastTranscription client = new SpeechToTextClient(endpoint, credential).GetFastTranscriptionClient(serviceApiVersionsQueryParameter: ServiceApiVersions.V20241115); + + TranscribeMetadata definition = new TranscribeMetadata + { + Locales = { "" }, + Models = +{ +["key"] = new Uri("http://localhost:3000") +}, + ProfanityFilterMode = ProfanityFilterMode.None, + Diarization = new TranscribeDiarizationProperties + { + Enabled = true, + MaxSpeakers = 1234, + }, + Channels = { 1234 }, + }; + Response response = await client.TranscribeAsync(null, definition: definition); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tsp-location.yaml b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tsp-location.yaml new file mode 100644 index 000000000000..6f5a0ede3848 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.SpeechToText.FastTranscription/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/Speech.SpeechToText.Fast +commit: 32f635ac1beff851b1f2741ebcd7e91e3cbdc6ee +repo: Azure/azure-rest-api-specs +additionalDirectories: