diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/Azure.AI.Speech.BatchTranscription.sln b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/Azure.AI.Speech.BatchTranscription.sln new file mode 100644 index 000000000000..cfcc5ac1f026 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/Azure.AI.Speech.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.Speech.BatchTranscription", "src\Azure.AI.Speech.BatchTranscription.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Speech.BatchTranscription.Tests", "tests\Azure.AI.Speech.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.Speech.BatchTranscription/CHANGELOG.md b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.BatchTranscription/Directory.Build.props b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/README.md b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/README.md new file mode 100644 index 000000000000..a4a397067207 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/README.md @@ -0,0 +1,107 @@ +# Azure.AI.Speech.BatchTranscription client library for .NET + +Azure.AI.Speech.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.Speech.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.Speech.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.Speech.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.Speech.BatchTranscription/README.png) \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/api/Azure.AI.Speech.BatchTranscription.net8.0.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/api/Azure.AI.Speech.BatchTranscription.net8.0.cs new file mode 100644 index 000000000000..985baddd2c33 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/api/Azure.AI.Speech.BatchTranscription.net8.0.cs @@ -0,0 +1,303 @@ +namespace Azure.AI.Speech.BatchTranscription +{ + public static partial class AISpeechBatchTranscriptionModelFactory + { + public static Azure.AI.Speech.BatchTranscription.EntityError EntityError(string code = null, string message = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.FileLinks FileLinks(System.Uri content = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.FileProperties FileProperties(int durationMilliseconds = 0, int size = 0) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionFile TranscriptionFile(System.DateTimeOffset created = default(System.DateTimeOffset), Azure.AI.Speech.BatchTranscription.FileKind kind = default(Azure.AI.Speech.BatchTranscription.FileKind), Azure.AI.Speech.BatchTranscription.FileLinks links = null, string displayName = null, Azure.AI.Speech.BatchTranscription.FileProperties properties = null, System.Uri self = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionJob TranscriptionJob(Azure.AI.Speech.BatchTranscription.TranscriptionLinks links = null, Azure.AI.Speech.BatchTranscription.TranscriptionProperties properties = null, string id = null, System.Uri self = null, Azure.AI.Speech.BatchTranscription.EntityReference model = null, Azure.AI.Speech.BatchTranscription.EntityReference dataset = null, System.Collections.Generic.IEnumerable contents = null, System.Uri sourceContainer = null, string locale = null, string displayName = null, string description = null, System.Collections.Generic.IDictionary customProperties = null, System.DateTimeOffset? lastActionDateTime = default(System.DateTimeOffset?), Azure.AI.Speech.BatchTranscription.TranscriptionStatus status = default(Azure.AI.Speech.BatchTranscription.TranscriptionStatus), System.DateTimeOffset? created = default(System.DateTimeOffset?)) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionLinks TranscriptionLinks(System.Uri files = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionProperties TranscriptionProperties(bool? wordLevelTimestampsEnabled = default(bool?), bool? displayFormWordLevelTimestampsEnabled = default(bool?), int? durationMilliseconds = default(int?), System.Collections.Generic.IEnumerable channels = null, System.Uri destinationContainer = null, Azure.AI.Speech.BatchTranscription.PunctuationMode? punctuationMode = default(Azure.AI.Speech.BatchTranscription.PunctuationMode?), Azure.AI.Speech.BatchTranscription.ProfanityFilterMode? profanityFilterMode = default(Azure.AI.Speech.BatchTranscription.ProfanityFilterMode?), int timeToLiveHours = 0, Azure.AI.Speech.BatchTranscription.EntityError error = null, Azure.AI.Speech.BatchTranscription.DiarizationProperties diarization = null, Azure.AI.Speech.BatchTranscription.LanguageIdentificationProperties languageIdentificationProperties = null) { throw null; } + } + public partial class BatchTranscriptionClient + { + protected BatchTranscriptionClient() { } + public BatchTranscriptionClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public BatchTranscriptionClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.Speech.BatchTranscription.BatchTranscriptionClientOptions options) { } + 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.Pageable GetTranscriptionFiles(string id, int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.Pageable GetTranscriptionFiles(string id, int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionFilesAsync(string id, int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionFilesAsync(string id, int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetTranscriptions(int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.Pageable GetTranscriptions(int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionsAsync(int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionsAsync(int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StartTranscription(Azure.AI.Speech.BatchTranscription.TranscriptionJob resource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StartTranscription(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> StartTranscriptionAsync(Azure.AI.Speech.BatchTranscription.TranscriptionJob resource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartTranscriptionAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + } + public partial class BatchTranscriptionClientOptions : Azure.Core.ClientOptions + { + public BatchTranscriptionClientOptions(Azure.AI.Speech.BatchTranscription.BatchTranscriptionClientOptions.ServiceVersion version = Azure.AI.Speech.BatchTranscription.BatchTranscriptionClientOptions.ServiceVersion.V2024_11_15) { } + public enum ServiceVersion + { + V2024_11_15 = 1, + } + } + 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.Speech.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.Speech.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.Speech.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.Speech.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.Speech.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.Speech.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.Speech.BatchTranscription.FileKind AcousticDataArchive { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind AcousticDataTranscriptionV2 { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind Audio { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind DatasetReport { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind EvaluationDetails { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind LanguageData { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind ModelReport { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind OutputFormattingData { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind PronunciationData { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind Transcription { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind TranscriptionReport { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.FileKind left, Azure.AI.Speech.BatchTranscription.FileKind right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.FileKind (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.FileKind left, Azure.AI.Speech.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 Content { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Speech.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.Speech.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.Speech.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.Speech.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.Speech.BatchTranscription.LanguageIdentificationMode Continuous { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode Single { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.LanguageIdentificationMode left, Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode left, Azure.AI.Speech.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.Speech.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.Speech.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.Speech.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; } + } + [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.Speech.BatchTranscription.ProfanityFilterMode Masked { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.ProfanityFilterMode None { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.ProfanityFilterMode Removed { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.ProfanityFilterMode Tags { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.ProfanityFilterMode left, Azure.AI.Speech.BatchTranscription.ProfanityFilterMode right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.ProfanityFilterMode (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.ProfanityFilterMode left, Azure.AI.Speech.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.Speech.BatchTranscription.PunctuationMode Automatic { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.PunctuationMode Dictated { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.PunctuationMode DictatedAndAutomatic { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.PunctuationMode None { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.PunctuationMode left, Azure.AI.Speech.BatchTranscription.PunctuationMode right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.PunctuationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.PunctuationMode left, Azure.AI.Speech.BatchTranscription.PunctuationMode right) { throw null; } + public override string ToString() { throw null; } + } + public partial class TranscriptionFile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscriptionFile() { } + public System.DateTimeOffset Created { get { throw null; } } + public string DisplayName { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.FileKind Kind { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.FileLinks Links { get { throw null; } } + public Azure.AI.Speech.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.Speech.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.Speech.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 TranscriptionJob : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscriptionJob(Azure.AI.Speech.BatchTranscription.TranscriptionProperties properties, string locale, string displayName) { } + public System.Collections.Generic.IList Contents { get { throw null; } } + public System.DateTimeOffset? Created { get { throw null; } } + public System.Collections.Generic.IDictionary CustomProperties { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.EntityReference Dataset { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.DateTimeOffset? LastActionDateTime { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.TranscriptionLinks Links { get { throw null; } set { } } + public string Locale { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.EntityReference Model { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.TranscriptionProperties Properties { get { throw null; } set { } } + public System.Uri Self { get { throw null; } } + public System.Uri SourceContainer { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.TranscriptionStatus Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Speech.BatchTranscription.TranscriptionJob 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.Speech.BatchTranscription.TranscriptionJob 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.Speech.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.Speech.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 DestinationContainer { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.DiarizationProperties Diarization { get { throw null; } set { } } + public bool? DisplayFormWordLevelTimestampsEnabled { get { throw null; } set { } } + public int? DurationMilliseconds { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.EntityError Error { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.LanguageIdentificationProperties LanguageIdentificationProperties { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.ProfanityFilterMode? ProfanityFilterMode { get { throw null; } set { } } + public Azure.AI.Speech.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.Speech.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.Speech.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; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TranscriptionStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TranscriptionStatus(string value) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus Failed { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus NotStarted { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus Running { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus Succeeded { get { throw null; } } + public bool Equals(Azure.AI.Speech.BatchTranscription.TranscriptionStatus 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.Speech.BatchTranscription.TranscriptionStatus left, Azure.AI.Speech.BatchTranscription.TranscriptionStatus right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.TranscriptionStatus (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.TranscriptionStatus left, Azure.AI.Speech.BatchTranscription.TranscriptionStatus right) { throw null; } + public override string ToString() { throw null; } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AISpeechBatchTranscriptionClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddBatchTranscriptionClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddBatchTranscriptionClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/api/Azure.AI.Speech.BatchTranscription.netstandard2.0.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/api/Azure.AI.Speech.BatchTranscription.netstandard2.0.cs new file mode 100644 index 000000000000..985baddd2c33 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/api/Azure.AI.Speech.BatchTranscription.netstandard2.0.cs @@ -0,0 +1,303 @@ +namespace Azure.AI.Speech.BatchTranscription +{ + public static partial class AISpeechBatchTranscriptionModelFactory + { + public static Azure.AI.Speech.BatchTranscription.EntityError EntityError(string code = null, string message = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.FileLinks FileLinks(System.Uri content = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.FileProperties FileProperties(int durationMilliseconds = 0, int size = 0) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionFile TranscriptionFile(System.DateTimeOffset created = default(System.DateTimeOffset), Azure.AI.Speech.BatchTranscription.FileKind kind = default(Azure.AI.Speech.BatchTranscription.FileKind), Azure.AI.Speech.BatchTranscription.FileLinks links = null, string displayName = null, Azure.AI.Speech.BatchTranscription.FileProperties properties = null, System.Uri self = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionJob TranscriptionJob(Azure.AI.Speech.BatchTranscription.TranscriptionLinks links = null, Azure.AI.Speech.BatchTranscription.TranscriptionProperties properties = null, string id = null, System.Uri self = null, Azure.AI.Speech.BatchTranscription.EntityReference model = null, Azure.AI.Speech.BatchTranscription.EntityReference dataset = null, System.Collections.Generic.IEnumerable contents = null, System.Uri sourceContainer = null, string locale = null, string displayName = null, string description = null, System.Collections.Generic.IDictionary customProperties = null, System.DateTimeOffset? lastActionDateTime = default(System.DateTimeOffset?), Azure.AI.Speech.BatchTranscription.TranscriptionStatus status = default(Azure.AI.Speech.BatchTranscription.TranscriptionStatus), System.DateTimeOffset? created = default(System.DateTimeOffset?)) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionLinks TranscriptionLinks(System.Uri files = null) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionProperties TranscriptionProperties(bool? wordLevelTimestampsEnabled = default(bool?), bool? displayFormWordLevelTimestampsEnabled = default(bool?), int? durationMilliseconds = default(int?), System.Collections.Generic.IEnumerable channels = null, System.Uri destinationContainer = null, Azure.AI.Speech.BatchTranscription.PunctuationMode? punctuationMode = default(Azure.AI.Speech.BatchTranscription.PunctuationMode?), Azure.AI.Speech.BatchTranscription.ProfanityFilterMode? profanityFilterMode = default(Azure.AI.Speech.BatchTranscription.ProfanityFilterMode?), int timeToLiveHours = 0, Azure.AI.Speech.BatchTranscription.EntityError error = null, Azure.AI.Speech.BatchTranscription.DiarizationProperties diarization = null, Azure.AI.Speech.BatchTranscription.LanguageIdentificationProperties languageIdentificationProperties = null) { throw null; } + } + public partial class BatchTranscriptionClient + { + protected BatchTranscriptionClient() { } + public BatchTranscriptionClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public BatchTranscriptionClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.Speech.BatchTranscription.BatchTranscriptionClientOptions options) { } + 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.Pageable GetTranscriptionFiles(string id, int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.Pageable GetTranscriptionFiles(string id, int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionFilesAsync(string id, int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionFilesAsync(string id, int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetTranscriptions(int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.Pageable GetTranscriptions(int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionsAsync(int? maxCount, int? skip, string filter, Azure.RequestContext context) { throw null; } + public virtual Azure.AsyncPageable GetTranscriptionsAsync(int? maxCount = default(int?), int? skip = default(int?), string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StartTranscription(Azure.AI.Speech.BatchTranscription.TranscriptionJob resource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StartTranscription(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> StartTranscriptionAsync(Azure.AI.Speech.BatchTranscription.TranscriptionJob resource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartTranscriptionAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + } + public partial class BatchTranscriptionClientOptions : Azure.Core.ClientOptions + { + public BatchTranscriptionClientOptions(Azure.AI.Speech.BatchTranscription.BatchTranscriptionClientOptions.ServiceVersion version = Azure.AI.Speech.BatchTranscription.BatchTranscriptionClientOptions.ServiceVersion.V2024_11_15) { } + public enum ServiceVersion + { + V2024_11_15 = 1, + } + } + 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.Speech.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.Speech.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.Speech.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.Speech.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.Speech.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.Speech.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.Speech.BatchTranscription.FileKind AcousticDataArchive { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind AcousticDataTranscriptionV2 { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind Audio { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind DatasetReport { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind EvaluationDetails { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind LanguageData { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind ModelReport { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind OutputFormattingData { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind PronunciationData { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind Transcription { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.FileKind TranscriptionReport { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.FileKind left, Azure.AI.Speech.BatchTranscription.FileKind right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.FileKind (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.FileKind left, Azure.AI.Speech.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 Content { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Speech.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.Speech.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.Speech.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.Speech.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.Speech.BatchTranscription.LanguageIdentificationMode Continuous { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode Single { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.LanguageIdentificationMode left, Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.LanguageIdentificationMode left, Azure.AI.Speech.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.Speech.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.Speech.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.Speech.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; } + } + [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.Speech.BatchTranscription.ProfanityFilterMode Masked { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.ProfanityFilterMode None { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.ProfanityFilterMode Removed { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.ProfanityFilterMode Tags { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.ProfanityFilterMode left, Azure.AI.Speech.BatchTranscription.ProfanityFilterMode right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.ProfanityFilterMode (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.ProfanityFilterMode left, Azure.AI.Speech.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.Speech.BatchTranscription.PunctuationMode Automatic { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.PunctuationMode Dictated { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.PunctuationMode DictatedAndAutomatic { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.PunctuationMode None { get { throw null; } } + public bool Equals(Azure.AI.Speech.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.Speech.BatchTranscription.PunctuationMode left, Azure.AI.Speech.BatchTranscription.PunctuationMode right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.PunctuationMode (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.PunctuationMode left, Azure.AI.Speech.BatchTranscription.PunctuationMode right) { throw null; } + public override string ToString() { throw null; } + } + public partial class TranscriptionFile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TranscriptionFile() { } + public System.DateTimeOffset Created { get { throw null; } } + public string DisplayName { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.FileKind Kind { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.FileLinks Links { get { throw null; } } + public Azure.AI.Speech.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.Speech.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.Speech.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 TranscriptionJob : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TranscriptionJob(Azure.AI.Speech.BatchTranscription.TranscriptionProperties properties, string locale, string displayName) { } + public System.Collections.Generic.IList Contents { get { throw null; } } + public System.DateTimeOffset? Created { get { throw null; } } + public System.Collections.Generic.IDictionary CustomProperties { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.EntityReference Dataset { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.DateTimeOffset? LastActionDateTime { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.TranscriptionLinks Links { get { throw null; } set { } } + public string Locale { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.EntityReference Model { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.TranscriptionProperties Properties { get { throw null; } set { } } + public System.Uri Self { get { throw null; } } + public System.Uri SourceContainer { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.TranscriptionStatus Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Speech.BatchTranscription.TranscriptionJob 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.Speech.BatchTranscription.TranscriptionJob 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.Speech.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.Speech.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 DestinationContainer { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.DiarizationProperties Diarization { get { throw null; } set { } } + public bool? DisplayFormWordLevelTimestampsEnabled { get { throw null; } set { } } + public int? DurationMilliseconds { get { throw null; } } + public Azure.AI.Speech.BatchTranscription.EntityError Error { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.LanguageIdentificationProperties LanguageIdentificationProperties { get { throw null; } set { } } + public Azure.AI.Speech.BatchTranscription.ProfanityFilterMode? ProfanityFilterMode { get { throw null; } set { } } + public Azure.AI.Speech.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.Speech.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.Speech.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; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TranscriptionStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TranscriptionStatus(string value) { throw null; } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus Failed { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus NotStarted { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus Running { get { throw null; } } + public static Azure.AI.Speech.BatchTranscription.TranscriptionStatus Succeeded { get { throw null; } } + public bool Equals(Azure.AI.Speech.BatchTranscription.TranscriptionStatus 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.Speech.BatchTranscription.TranscriptionStatus left, Azure.AI.Speech.BatchTranscription.TranscriptionStatus right) { throw null; } + public static implicit operator Azure.AI.Speech.BatchTranscription.TranscriptionStatus (string value) { throw null; } + public static bool operator !=(Azure.AI.Speech.BatchTranscription.TranscriptionStatus left, Azure.AI.Speech.BatchTranscription.TranscriptionStatus right) { throw null; } + public override string ToString() { throw null; } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AISpeechBatchTranscriptionClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddBatchTranscriptionClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddBatchTranscriptionClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Azure.AI.Speech.BatchTranscription.csproj b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Azure.AI.Speech.BatchTranscription.csproj new file mode 100644 index 000000000000..ab5175468c5a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Azure.AI.Speech.BatchTranscription.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.Speech.BatchTranscription client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.Speech.BatchTranscription for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.Speech.BatchTranscription + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/AISpeechBatchTranscriptionClientBuilderExtensions.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/AISpeechBatchTranscriptionClientBuilderExtensions.cs new file mode 100644 index 000000000000..91852a535252 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/AISpeechBatchTranscriptionClientBuilderExtensions.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.Speech.BatchTranscription; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AISpeechBatchTranscriptionClientBuilderExtensions + { + /// 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 AddBatchTranscriptionClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new BatchTranscriptionClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddBatchTranscriptionClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/AISpeechBatchTranscriptionModelFactory.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/AISpeechBatchTranscriptionModelFactory.cs new file mode 100644 index 000000000000..60ba49171da4 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/AISpeechBatchTranscriptionModelFactory.cs @@ -0,0 +1,180 @@ +// 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.Speech.BatchTranscription +{ + /// Model factory for models. + public static partial class AISpeechBatchTranscriptionModelFactory + { + /// Initializes a new instance of . + /// TranscriptionLinks. + /// TranscriptionProperties. + /// The id of this entity. + /// 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 TranscriptionJob TranscriptionJob(TranscriptionLinks links = null, TranscriptionProperties properties = null, string id = null, Uri self = null, EntityReference model = null, EntityReference dataset = null, IEnumerable contents = null, Uri sourceContainer = null, string locale = null, string displayName = null, string description = null, IDictionary customProperties = null, DateTimeOffset? lastActionDateTime = null, TranscriptionStatus status = default, DateTimeOffset? created = null) + { + contents ??= new List(); + customProperties ??= new Dictionary(); + + return new TranscriptionJob( + links, + properties, + id, + self, + model, + dataset, + contents?.ToList(), + sourceContainer, + locale, + displayName, + description, + customProperties, + lastActionDateTime, + status, + created, + 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. + /// Speaker Identification. + /// LanguageIdentificationProperties. + /// A new instance for mocking. + public static TranscriptionProperties TranscriptionProperties(bool? wordLevelTimestampsEnabled = null, bool? displayFormWordLevelTimestampsEnabled = null, int? durationMilliseconds = null, IEnumerable channels = null, Uri destinationContainer = null, PunctuationMode? punctuationMode = null, ProfanityFilterMode? profanityFilterMode = null, int timeToLiveHours = default, EntityError error = null, DiarizationProperties diarization = null, LanguageIdentificationProperties languageIdentificationProperties = null) + { + channels ??= new List(); + + return new TranscriptionProperties( + wordLevelTimestampsEnabled, + displayFormWordLevelTimestampsEnabled, + durationMilliseconds, + channels?.ToList(), + destinationContainer, + punctuationMode, + profanityFilterMode, + timeToLiveHours, + error, + diarization, + languageIdentificationProperties, + 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 . + /// 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 created = default, FileKind kind = default, FileLinks links = null, string displayName = null, FileProperties properties = null, Uri self = null) + { + return new TranscriptionFile( + created, + kind, + links, + displayName, + 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 content = null) + { + return new FileLinks(content, 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.Speech.BatchTranscription/src/Generated/BatchTranscriptionClient.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/BatchTranscriptionClient.cs new file mode 100644 index 000000000000..74e9b7ac54f9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/BatchTranscriptionClient.cs @@ -0,0 +1,697 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Speech.BatchTranscription +{ + // Data plane generated client. + /// The BatchTranscription service client. + public partial class BatchTranscriptionClient + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// 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 BatchTranscriptionClient for mocking. + protected BatchTranscriptionClient() + { + } + + /// Initializes a new instance of BatchTranscriptionClient. + /// 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 BatchTranscriptionClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new BatchTranscriptionClientOptions()) + { + } + + /// Initializes a new instance of BatchTranscriptionClient. + /// 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 BatchTranscriptionClient(Uri endpoint, AzureKeyCredential credential, BatchTranscriptionClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new BatchTranscriptionClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Starts a new transcription job. + /// The resource instance. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> StartTranscriptionAsync(TranscriptionJob resource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resource, nameof(resource)); + + using RequestContent content = resource.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StartTranscriptionAsync(content, context).ConfigureAwait(false); + return Response.FromValue(TranscriptionJob.FromResponse(response), response); + } + + /// Starts a new transcription job. + /// The resource instance. + /// The cancellation token to use. + /// is null. + /// + public virtual Response StartTranscription(TranscriptionJob resource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resource, nameof(resource)); + + using RequestContent content = resource.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StartTranscription(content, context); + return Response.FromValue(TranscriptionJob.FromResponse(response), response); + } + + /// + /// [Protocol Method] Starts 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 StartTranscriptionAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscriptionClient.StartTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateStartTranscriptionRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Starts 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 StartTranscription(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("BatchTranscriptionClient.StartTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateStartTranscriptionRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the transcription identified by the given ID. + /// The id of this entity. + /// 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(TranscriptionJob.FromResponse(response), response); + } + + /// Gets the transcription identified by the given ID. + /// The id of this entity. + /// 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(TranscriptionJob.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 id of this entity. + /// 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("BatchTranscriptionClient.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 id of this entity. + /// 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("BatchTranscriptionClient.GetTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTranscriptionRequest(id, 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 id of this entity. + /// 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("BatchTranscriptionClient.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 id of this entity. + /// 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("BatchTranscriptionClient.DeleteTranscription"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTranscriptionRequest(id, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of transcriptions for the authenticated subscription. + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetTranscriptionsAsync(int? maxCount = null, int? skip = null, string filter = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionsRequest(maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionsNextPageRequest(nextLink, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TranscriptionJob.DeserializeTranscriptionJob(e), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptions", "values", "@nextLink", context); + } + + /// Gets a list of transcriptions for the authenticated subscription. + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// The cancellation token to use. + /// + public virtual Pageable GetTranscriptions(int? maxCount = null, int? skip = null, string filter = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionsRequest(maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionsNextPageRequest(nextLink, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TranscriptionJob.DeserializeTranscriptionJob(e), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptions", "values", "@nextLink", context); + } + + /// + /// [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. + /// + /// + /// + /// + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// 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 from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTranscriptionsAsync(int? maxCount, int? skip, string filter, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionsRequest(maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionsNextPageRequest(nextLink, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptions", "values", "@nextLink", context); + } + + /// + /// [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. + /// + /// + /// + /// + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// 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 from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTranscriptions(int? maxCount, int? skip, string filter, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionsRequest(maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionsNextPageRequest(nextLink, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptions", "values", "@nextLink", context); + } + + /// Gets the files of the transcription identified by the given ID. + /// The id of this entity. + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetTranscriptionFilesAsync(string id, int? maxCount = null, int? skip = null, string filter = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionFilesRequest(id, maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionFilesNextPageRequest(nextLink, id, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TranscriptionFile.DeserializeTranscriptionFile(e), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptionFiles", "values", "@nextLink", context); + } + + /// Gets the files of the transcription identified by the given ID. + /// The id of this entity. + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetTranscriptionFiles(string id, int? maxCount = null, int? skip = null, string filter = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionFilesRequest(id, maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionFilesNextPageRequest(nextLink, id, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TranscriptionFile.DeserializeTranscriptionFile(e), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptionFiles", "values", "@nextLink", context); + } + + /// + /// [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 id of this entity. + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// 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 from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTranscriptionFilesAsync(string id, int? maxCount, int? skip, string filter, RequestContext context) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionFilesRequest(id, maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionFilesNextPageRequest(nextLink, id, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptionFiles", "values", "@nextLink", context); + } + + /// + /// [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 id of this entity. + /// The number of result items to return. + /// The number of result items to skip. + /// Filter the result list using the given expression. + /// 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 from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTranscriptionFiles(string id, int? maxCount, int? skip, string filter, RequestContext context) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTranscriptionFilesRequest(id, maxCount, skip, filter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranscriptionFilesNextPageRequest(nextLink, id, maxCount, skip, filter, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "BatchTranscriptionClient.GetTranscriptionFiles", "values", "@nextLink", context); + } + + internal HttpMessage CreateStartTranscriptionRequest(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); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + 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); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTranscriptionsRequest(int? maxCount, int? skip, 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); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTranscriptionFilesRequest(string id, int? maxCount, int? skip, 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); + uri.AppendPath(id, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTranscriptionsNextPageRequest(string nextLink, int? maxCount, int? skip, 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.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTranscriptionFilesNextPageRequest(string nextLink, string id, int? maxCount, int? skip, 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.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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.Speech.BatchTranscription/src/Generated/BatchTranscriptionClientOptions.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/BatchTranscriptionClientOptions.cs new file mode 100644 index 000000000000..2194aa669832 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/BatchTranscriptionClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.Speech.BatchTranscription +{ + /// Client options for BatchTranscriptionClient. + public partial class BatchTranscriptionClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_11_15; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-11-15". + V2024_11_15 = 1, + } + + internal string Version { get; } + + /// Initializes new instance of BatchTranscriptionClientOptions. + public BatchTranscriptionClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_11_15 => "2024-11-15", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/DiarizationProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/DiarizationProperties.Serialization.cs new file mode 100644 index 000000000000..685bb8f5047d --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/DiarizationProperties.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/DiarizationProperties.cs new file mode 100644 index 000000000000..b8cbc57911ae --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.BatchTranscription +{ + /// Speaker Identification Properties. + 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 identification 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 identification 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 identification 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.Speech.BatchTranscription/src/Generated/Docs/BatchTranscriptionClient.xml b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Docs/BatchTranscriptionClient.xml new file mode 100644 index 000000000000..21e6985ec90a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Docs/BatchTranscriptionClient.xml @@ -0,0 +1,831 @@ + + + + + +This sample shows how to call StartTranscriptionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234), "", ""); +Response response = await client.StartTranscriptionAsync(resource); +]]> +This sample shows how to call StartTranscriptionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234) +{ + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainer = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentificationProperties = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = + { + ["key"] = new EntityReference(new Uri("http://localhost:3000")) + }, + }, +}, "", "") +{ + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + Contents = { new Uri("http://localhost:3000") }, + SourceContainer = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = + { + ["key"] = "" + }, +}; +Response response = await client.StartTranscriptionAsync(resource); +]]> + + + +This sample shows how to call StartTranscription. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234), "", ""); +Response response = client.StartTranscription(resource); +]]> +This sample shows how to call StartTranscription with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234) +{ + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainer = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentificationProperties = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = + { + ["key"] = new EntityReference(new Uri("http://localhost:3000")) + }, + }, +}, "", "") +{ + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + Contents = { new Uri("http://localhost:3000") }, + SourceContainer = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = + { + ["key"] = "" + }, +}; +Response response = client.StartTranscription(resource); +]]> + + + +This sample shows how to call StartTranscriptionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", +}); +Response response = await client.StartTranscriptionAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> +This sample shows how to call StartTranscriptionAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +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 = "", + }, +}); +Response response = await client.StartTranscriptionAsync(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("id").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 StartTranscription and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", +}); +Response response = client.StartTranscription(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> +This sample shows how to call StartTranscription with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +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 = "", + }, +}); +Response response = client.StartTranscription(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("id").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 GetTranscriptionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = await client.GetTranscriptionAsync(""); +]]> +This sample shows how to call GetTranscriptionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = await client.GetTranscriptionAsync(""); +]]> + + + +This sample shows how to call GetTranscription. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = client.GetTranscription(""); +]]> +This sample shows how to call GetTranscription with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = client.GetTranscription(""); +]]> + + + +This sample shows how to call GetTranscriptionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +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("id").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> +This sample shows how to call GetTranscriptionAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +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("id").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(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = client.GetTranscription("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("self").ToString()); +Console.WriteLine(result.GetProperty("locale").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> +This sample shows how to call GetTranscription with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +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("id").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(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = await client.DeleteTranscriptionAsync(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteTranscriptionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = await client.DeleteTranscriptionAsync(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTranscription. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = client.DeleteTranscription(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteTranscription with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +Response response = client.DeleteTranscription(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetTranscriptionsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (TranscriptionJob item in client.GetTranscriptionsAsync()) +{ +} +]]> +This sample shows how to call GetTranscriptionsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (TranscriptionJob item in client.GetTranscriptionsAsync(maxCount: 1234, skip: 1234, filter: "")) +{ +} +]]> + + + +This sample shows how to call GetTranscriptions. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (TranscriptionJob item in client.GetTranscriptions()) +{ +} +]]> +This sample shows how to call GetTranscriptions with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (TranscriptionJob item in client.GetTranscriptions(maxCount: 1234, skip: 1234, filter: "")) +{ +} +]]> + + + +This sample shows how to call GetTranscriptionsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTranscriptionsAsync(null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); +} +]]> +This sample shows how to call GetTranscriptionsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTranscriptionsAsync(1234, 1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).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("id").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 GetTranscriptions and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (BinaryData item in client.GetTranscriptions(null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); +} +]]> +This sample shows how to call GetTranscriptions with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (BinaryData item in client.GetTranscriptions(1234, 1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).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("id").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 GetTranscriptionFilesAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (TranscriptionFile item in client.GetTranscriptionFilesAsync("")) +{ +} +]]> +This sample shows how to call GetTranscriptionFilesAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (TranscriptionFile item in client.GetTranscriptionFilesAsync("", maxCount: 1234, skip: 1234, filter: "")) +{ +} +]]> + + + +This sample shows how to call GetTranscriptionFiles. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (TranscriptionFile item in client.GetTranscriptionFiles("")) +{ +} +]]> +This sample shows how to call GetTranscriptionFiles with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (TranscriptionFile item in client.GetTranscriptionFiles("", maxCount: 1234, skip: 1234, filter: "")) +{ +} +]]> + + + +This sample shows how to call GetTranscriptionFilesAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTranscriptionFilesAsync("", null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); +} +]]> +This sample shows how to call GetTranscriptionFilesAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTranscriptionFilesAsync("", 1234, 1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); +} +]]> + + + +This sample shows how to call GetTranscriptionFiles and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (BinaryData item in client.GetTranscriptionFiles("", null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); +} +]]> +This sample shows how to call GetTranscriptionFiles with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + +foreach (BinaryData item in client.GetTranscriptionFiles("", 1234, 1234, "", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/EntityError.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/EntityError.Serialization.cs new file mode 100644 index 000000000000..58e76cbb782c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/EntityError.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/EntityError.cs new file mode 100644 index 000000000000..5150d0f343a1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/EntityReference.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/EntityReference.Serialization.cs new file mode 100644 index 000000000000..a664c28d5c93 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/EntityReference.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/EntityReference.cs new file mode 100644 index 000000000000..f245408ffbcb --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/FileKind.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/FileKind.cs new file mode 100644 index 000000000000..593d2bc71501 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/FileLinks.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/FileLinks.Serialization.cs new file mode 100644 index 000000000000..35d87280de3c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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(Content.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/FileLinks.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/FileLinks.cs new file mode 100644 index 000000000000..db54b3cccf14 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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 content) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// 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 content, IDictionary serializedAdditionalRawData) + { + Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileLinks() + { + } + + /// The url to retrieve the content of this file. + public Uri Content { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/FileProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/FileProperties.Serialization.cs new file mode 100644 index 000000000000..e89cf7280699 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/FileProperties.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/FileProperties.cs new file mode 100644 index 000000000000..8c73e5a7cec0 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/Internal/Argument.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..8c772fb36b38 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..f7f8064b014d --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/Internal/ChangeTrackingList.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..b004a155db80 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..6a1d96ab2cf7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// 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.Speech.BatchTranscription +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + 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.Speech.BatchTranscription/src/Generated/Internal/Optional.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..2e7778f9eb03 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..08f14d868fd2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/LanguageIdentificationMode.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/LanguageIdentificationMode.cs new file mode 100644 index 000000000000..9a12ff418737 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/LanguageIdentificationProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/LanguageIdentificationProperties.Serialization.cs new file mode 100644 index 000000000000..c87f693b875e --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/LanguageIdentificationProperties.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/LanguageIdentificationProperties.cs new file mode 100644 index 000000000000..a066be32bd12 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/ProfanityFilterMode.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/ProfanityFilterMode.cs new file mode 100644 index 000000000000..258b450e355d --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/PunctuationMode.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/PunctuationMode.cs new file mode 100644 index 000000000000..5124ebacafbe --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/TranscriptionFile.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionFile.Serialization.cs new file mode 100644 index 000000000000..6b71a45781e6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionFile.Serialization.cs @@ -0,0 +1,192 @@ +// 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.Speech.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(Created, "O"); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + writer.WritePropertyName("links"u8); + writer.WriteObjectValue(Links, options); + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + if (options.Format != "W") + { + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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 displayName = 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("displayName"u8)) + { + displayName = 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, + displayName, + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/TranscriptionFile.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionFile.cs new file mode 100644 index 000000000000..882d5e514b72 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionFile.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Speech.BatchTranscription +{ + /// TranscriptionFile. + 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. + /// , or is null. + internal TranscriptionFile(DateTimeOffset created, FileKind kind, FileLinks links, string displayName, FileProperties properties) + { + Argument.AssertNotNull(links, nameof(links)); + Argument.AssertNotNull(displayName, nameof(displayName)); + Argument.AssertNotNull(properties, nameof(properties)); + + Created = created; + Kind = kind; + Links = links; + DisplayName = displayName; + Properties = properties; + } + + /// 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 created, FileKind kind, FileLinks links, string displayName, FileProperties properties, Uri self, IDictionary serializedAdditionalRawData) + { + Created = created; + Kind = kind; + Links = links; + DisplayName = displayName; + 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 Created { get; } + /// FileKind. + public FileKind Kind { get; } + /// FileLinks. + public FileLinks Links { get; } + /// The name of this file. + public string DisplayName { get; } + /// FileProperties. + public FileProperties Properties { get; } + /// The location of this entity. + public Uri Self { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionJob.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionJob.Serialization.cs new file mode 100644 index 000000000000..41340a16882f --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionJob.Serialization.cs @@ -0,0 +1,371 @@ +// 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.Speech.BatchTranscription +{ + public partial class TranscriptionJob : 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(TranscriptionJob)} 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") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + 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(Contents)) + { + writer.WritePropertyName("contentUrls"u8); + writer.WriteStartArray(); + foreach (var item in Contents) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.AbsoluteUri); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(SourceContainer)) + { + writer.WritePropertyName("contentContainerUrl"u8); + writer.WriteStringValue(SourceContainer.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 (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Created)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(Created.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionJob 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(TranscriptionJob)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionJob(document.RootElement, options); + } + + internal static TranscriptionJob DeserializeTranscriptionJob(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TranscriptionLinks links = default; + TranscriptionProperties properties = default; + string id = 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; + TranscriptionStatus 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("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("self"u8)) + { + 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)) + { + status = new TranscriptionStatus(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 TranscriptionJob( + links, + properties, + id, + 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(TranscriptionJob)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionJob 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionJob(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionJob)} 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 TranscriptionJob FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionJob(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.Speech.BatchTranscription/src/Generated/TranscriptionJob.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionJob.cs new file mode 100644 index 000000000000..0b0213009742 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionJob.cs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Speech.BatchTranscription +{ + /// Transcription. + public partial class TranscriptionJob + { + /// + /// 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 TranscriptionJob(TranscriptionProperties properties, string locale, string displayName) + { + Argument.AssertNotNull(properties, nameof(properties)); + Argument.AssertNotNull(locale, nameof(locale)); + Argument.AssertNotNull(displayName, nameof(displayName)); + + Properties = properties; + Contents = new ChangeTrackingList(); + Locale = locale; + DisplayName = displayName; + CustomProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// TranscriptionLinks. + /// TranscriptionProperties. + /// The id of this entity. + /// 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 TranscriptionJob(TranscriptionLinks links, TranscriptionProperties properties, string id, Uri self, EntityReference model, EntityReference dataset, IList contents, Uri sourceContainer, string locale, string displayName, string description, IDictionary customProperties, DateTimeOffset? lastActionDateTime, TranscriptionStatus status, DateTimeOffset? created, IDictionary serializedAdditionalRawData) + { + Links = links; + Properties = properties; + Id = id; + Self = self; + Model = model; + Dataset = dataset; + Contents = contents; + SourceContainer = sourceContainer; + Locale = locale; + DisplayName = displayName; + Description = description; + CustomProperties = customProperties; + LastActionDateTime = lastActionDateTime; + Status = status; + Created = created; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscriptionJob() + { + } + + /// TranscriptionLinks. + public TranscriptionLinks Links { get; set; } + /// TranscriptionProperties. + public TranscriptionProperties Properties { get; set; } + /// The id of this entity. + public string Id { get; } + /// 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 Contents { 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 SourceContainer { 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 TranscriptionStatus Status { get; } + /// + /// 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? Created { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionLinks.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionLinks.Serialization.cs new file mode 100644 index 000000000000..0731f1398e47 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/TranscriptionLinks.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionLinks.cs new file mode 100644 index 000000000000..57703d315687 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/src/Generated/TranscriptionProperties.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionProperties.Serialization.cs new file mode 100644 index 000000000000..901c86dd0c8a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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(DestinationContainer)) + { + writer.WritePropertyName("destinationContainerUrl"u8); + writer.WriteStringValue(DestinationContainer.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(LanguageIdentificationProperties)) + { + writer.WritePropertyName("languageIdentification"u8); + writer.WriteObjectValue(LanguageIdentificationProperties, 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.BatchTranscription/src/Generated/TranscriptionProperties.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionProperties.cs new file mode 100644 index 000000000000..5212d9069559 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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. + /// Speaker Identification. + /// LanguageIdentificationProperties. + /// Keeps track of any properties unknown to the library. + internal TranscriptionProperties(bool? wordLevelTimestampsEnabled, bool? displayFormWordLevelTimestampsEnabled, int? durationMilliseconds, IList channels, Uri destinationContainer, PunctuationMode? punctuationMode, ProfanityFilterMode? profanityFilterMode, int timeToLiveHours, EntityError error, DiarizationProperties diarization, LanguageIdentificationProperties languageIdentificationProperties, IDictionary serializedAdditionalRawData) + { + WordLevelTimestampsEnabled = wordLevelTimestampsEnabled; + DisplayFormWordLevelTimestampsEnabled = displayFormWordLevelTimestampsEnabled; + DurationMilliseconds = durationMilliseconds; + Channels = channels; + DestinationContainer = destinationContainer; + PunctuationMode = punctuationMode; + ProfanityFilterMode = profanityFilterMode; + TimeToLiveHours = timeToLiveHours; + Error = error; + Diarization = diarization; + LanguageIdentificationProperties = languageIdentificationProperties; + _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 DestinationContainer { 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; } + /// Speaker Identification. + public DiarizationProperties Diarization { get; set; } + /// LanguageIdentificationProperties. + public LanguageIdentificationProperties LanguageIdentificationProperties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionStatus.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionStatus.cs new file mode 100644 index 000000000000..b49157307591 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Generated/TranscriptionStatus.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.Speech.BatchTranscription +{ + /// Describe the current state of the API. + public readonly partial struct TranscriptionStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TranscriptionStatus(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 TranscriptionStatus NotStarted { get; } = new TranscriptionStatus(NotStartedValue); + /// The long running operation is currently processing. + public static TranscriptionStatus Running { get; } = new TranscriptionStatus(RunningValue); + /// The long running operation has successfully completed. + public static TranscriptionStatus Succeeded { get; } = new TranscriptionStatus(SucceededValue); + /// The long running operation has failed. + public static TranscriptionStatus Failed { get; } = new TranscriptionStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(TranscriptionStatus left, TranscriptionStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TranscriptionStatus left, TranscriptionStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TranscriptionStatus(string value) => new TranscriptionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TranscriptionStatus other && Equals(other); + /// + public bool Equals(TranscriptionStatus 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.Speech.BatchTranscription/src/Properties/AssemblyInfo.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..f490de52e5c7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.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.Speech.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.Speech.BatchTranscription/tests/Azure.AI.Speech.BatchTranscription.Tests.csproj b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tests/Azure.AI.Speech.BatchTranscription.Tests.csproj new file mode 100644 index 000000000000..ca9006139d1c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tests/Azure.AI.Speech.BatchTranscription.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tests/Generated/Samples/Samples_BatchTranscriptionClient.cs b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tests/Generated/Samples/Samples_BatchTranscriptionClient.cs new file mode 100644 index 000000000000..0922e180cc9d --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tests/Generated/Samples/Samples_BatchTranscriptionClient.cs @@ -0,0 +1,899 @@ +// 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.Speech.BatchTranscription.Samples +{ + public partial class Samples_BatchTranscriptionClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_StartTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", + }); + Response response = client.StartTranscription(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_StartTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + properties = new + { + timeToLiveHours = 1234, + }, + locale = "", + displayName = "", + }); + Response response = await client.StartTranscriptionAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_StartTranscription_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234), "", ""); + Response response = client.StartTranscription(resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_StartTranscription_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234), "", ""); + Response response = await client.StartTranscriptionAsync(resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_StartTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + 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 = "", + }, + }); + Response response = client.StartTranscription(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("id").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_TranscriptionJob_StartTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + 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 = "", + }, + }); + Response response = await client.StartTranscriptionAsync(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("id").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_TranscriptionJob_StartTranscription_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234) + { + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainer = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentificationProperties = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = +{ +["key"] = new EntityReference(new Uri("http://localhost:3000")) +}, + }, + }, "", "") + { + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + Contents = { new Uri("http://localhost:3000") }, + SourceContainer = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = +{ +["key"] = "" +}, + }; + Response response = client.StartTranscription(resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_StartTranscription_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + TranscriptionJob resource = new TranscriptionJob(new TranscriptionProperties(1234) + { + WordLevelTimestampsEnabled = true, + DisplayFormWordLevelTimestampsEnabled = true, + Channels = { 1234 }, + DestinationContainer = new Uri("http://localhost:3000"), + PunctuationMode = PunctuationMode.None, + ProfanityFilterMode = ProfanityFilterMode.None, + Error = new EntityError(), + Diarization = new DiarizationProperties(true, 1234), + LanguageIdentificationProperties = new LanguageIdentificationProperties(new string[] { "" }) + { + Mode = LanguageIdentificationMode.Continuous, + SpeechModelMapping = +{ +["key"] = new EntityReference(new Uri("http://localhost:3000")) +}, + }, + }, "", "") + { + Links = new TranscriptionLinks(), + Model = default, + Dataset = default, + Contents = { new Uri("http://localhost:3000") }, + SourceContainer = new Uri("http://localhost:3000"), + Description = "", + CustomProperties = +{ +["key"] = "" +}, + }; + Response response = await client.StartTranscriptionAsync(resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_GetTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = client.GetTranscription("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_GetTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + 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("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_GetTranscription_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = client.GetTranscription(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_GetTranscription_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = await client.GetTranscriptionAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_GetTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + 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("id").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_TranscriptionJob_GetTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + 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("id").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_TranscriptionJob_GetTranscription_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = client.GetTranscription(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_GetTranscription_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = await client.GetTranscriptionAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_DeleteTranscription_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = client.DeleteTranscription(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_DeleteTranscription_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = await client.DeleteTranscriptionAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_DeleteTranscription_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = client.DeleteTranscription(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_DeleteTranscription_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + Response response = await client.DeleteTranscriptionAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_GetTranscriptions_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (BinaryData item in client.GetTranscriptions(null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_GetTranscriptions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTranscriptionsAsync(null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("properties").GetProperty("timeToLiveHours").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + Console.WriteLine(result.GetProperty("locale").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_GetTranscriptions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (TranscriptionJob item in client.GetTranscriptions()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_GetTranscriptions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (TranscriptionJob item in client.GetTranscriptionsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionJob_GetTranscriptions_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (BinaryData item in client.GetTranscriptions(1234, 1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).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("id").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_TranscriptionJob_GetTranscriptions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTranscriptionsAsync(1234, 1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).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("id").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_TranscriptionJob_GetTranscriptions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (TranscriptionJob item in client.GetTranscriptions(maxCount: 1234, skip: 1234, filter: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionJob_GetTranscriptions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (TranscriptionJob item in client.GetTranscriptionsAsync(maxCount: 1234, skip: 1234, filter: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionFile_GetTranscriptionFiles_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (BinaryData item in client.GetTranscriptionFiles("", null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionFile_GetTranscriptionFiles_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTranscriptionFilesAsync("", null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionFile_GetTranscriptionFiles_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (TranscriptionFile item in client.GetTranscriptionFiles("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionFile_GetTranscriptionFiles_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (TranscriptionFile item in client.GetTranscriptionFilesAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionFile_GetTranscriptionFiles_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (BinaryData item in client.GetTranscriptionFiles("", 1234, 1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionFile_GetTranscriptionFiles_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTranscriptionFilesAsync("", 1234, 1234, "", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("links").GetProperty("contentUrl").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("durationMilliseconds").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("size").ToString()); + Console.WriteLine(result.GetProperty("self").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TranscriptionFile_GetTranscriptionFiles_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + foreach (TranscriptionFile item in client.GetTranscriptionFiles("", maxCount: 1234, skip: 1234, filter: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TranscriptionFile_GetTranscriptionFiles_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + BatchTranscriptionClient client = new BatchTranscriptionClient(endpoint, credential); + + await foreach (TranscriptionFile item in client.GetTranscriptionFilesAsync("", maxCount: 1234, skip: 1234, filter: "")) + { + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tsp-location.yaml b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tsp-location.yaml new file mode 100644 index 000000000000..3736afd9d514 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.BatchTranscription/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/Speech.BatchTranscription +commit: 42d832f4bd16b04dd3cb124ca3e8dfaef1211bc2 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/Azure.AI.Speech.Transcription.sln b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/Azure.AI.Speech.Transcription.sln new file mode 100644 index 000000000000..0e27ceffdc2c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/Azure.AI.Speech.Transcription.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.Speech.Transcription", "src\Azure.AI.Speech.Transcription.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Speech.Transcription.Tests", "tests\Azure.AI.Speech.Transcription.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.Speech.Transcription/CHANGELOG.md b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription/Directory.Build.props b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/README.md b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/README.md new file mode 100644 index 000000000000..ea27e0b32607 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/README.md @@ -0,0 +1,107 @@ +# Azure.AI.Speech.Transcription client library for .NET + +Azure.AI.Speech.Transcription 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.Speech.Transcription/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.Speech.Transcription --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.Speech.Transcription/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.Speech.Transcription/README.png) \ No newline at end of file diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Azure.AI.Speech.Transcription.csproj b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Azure.AI.Speech.Transcription.csproj new file mode 100644 index 000000000000..f0ad75e9138e --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Azure.AI.Speech.Transcription.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.Speech.Transcription client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.Speech.Transcription for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.Speech.Transcription + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/AISpeechTranscriptionClientBuilderExtensions.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/AISpeechTranscriptionClientBuilderExtensions.cs new file mode 100644 index 000000000000..3489ad1a005c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/AISpeechTranscriptionClientBuilderExtensions.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.Speech.Transcription; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AISpeechTranscriptionClientBuilderExtensions + { + /// 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 AddTranscriptionClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new TranscriptionClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddTranscriptionClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/AISpeechTranscriptionModelFactory.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/AISpeechTranscriptionModelFactory.cs new file mode 100644 index 000000000000..467d5f1e4ece --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/AISpeechTranscriptionModelFactory.cs @@ -0,0 +1,84 @@ +// 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.Speech.Transcription +{ + /// Model factory for models. + public static partial class AISpeechTranscriptionModelFactory + { + /// Initializes a new instance of . + /// Metadata for a 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. + /// A new instance for mocking. + public static TranscribeRequest TranscribeRequest(TranscriptionOptions options = null, Stream audio = null) + { + return new TranscribeRequest(options, audio, serializedAdditionalRawData: null); + } + + /// 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 TranscriptionResult TranscriptionResult(int durationMilliseconds = default, IEnumerable combinedPhrases = null, IEnumerable phrases = null) + { + combinedPhrases ??= new List(); + phrases ??= new List(); + + return new TranscriptionResult(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 TranscribedWord TranscribedWord(string text = null, int offsetMilliseconds = default, int durationMilliseconds = default) + { + return new TranscribedWord(text, offsetMilliseconds, durationMilliseconds, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/ChannelCombinedPhrases.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/ChannelCombinedPhrases.Serialization.cs new file mode 100644 index 000000000000..e1064c1731b2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.Transcription/src/Generated/ChannelCombinedPhrases.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/ChannelCombinedPhrases.cs new file mode 100644 index 000000000000..279a39f3bfee --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + /// 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.Speech.Transcription/src/Generated/Docs/TranscriptionClient.xml b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Docs/TranscriptionClient.xml new file mode 100644 index 000000000000..dbfd3b09e4fe --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Docs/TranscriptionClient.xml @@ -0,0 +1,223 @@ + + + + + +This sample shows how to call TranscribeAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +TranscribeRequest body = new TranscribeRequest(null); +Response response = await client.TranscribeAsync(body); +]]> +This sample shows how to call TranscribeAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +TranscribeRequest body = new TranscribeRequest(null) +{ + Options = new TranscriptionOptions + { + Locales = { "" }, + Models = + { + ["key"] = new Uri("http://localhost:3000") + }, + ProfanityFilterMode = ProfanityFilterMode.None, + DiarizationOptions = new TranscriptionDiarizationOptions + { + Enabled = true, + MaxSpeakers = 1234, + }, + ActiveChannels = { 1234 }, + }, +}; +Response response = await client.TranscribeAsync(body); +]]> + + + +This sample shows how to call Transcribe. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +TranscribeRequest body = new TranscribeRequest(null); +Response response = client.Transcribe(body); +]]> +This sample shows how to call Transcribe with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +TranscribeRequest body = new TranscribeRequest(null) +{ + Options = new TranscriptionOptions + { + Locales = { "" }, + Models = + { + ["key"] = new Uri("http://localhost:3000") + }, + ProfanityFilterMode = ProfanityFilterMode.None, + DiarizationOptions = new TranscriptionDiarizationOptions + { + Enabled = true, + MaxSpeakers = 1234, + }, + ActiveChannels = { 1234 }, + }, +}; +Response response = client.Transcribe(body); +]]> + + + +This sample shows how to call TranscribeAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +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(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +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(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +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(""); +TranscriptionClient client = new TranscriptionClient(endpoint, credential); + +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.Speech.Transcription/src/Generated/Internal/Argument.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..f7300d83d72b --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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.Speech.Transcription/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..e01597dc4bf1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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.Speech.Transcription/src/Generated/Internal/ChangeTrackingList.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..77d58589fa88 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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.Speech.Transcription/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..20cda16a3f52 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// 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.Speech.Transcription +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + 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.Speech.Transcription/src/Generated/Internal/MultipartFormDataRequestContent.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/MultipartFormDataRequestContent.cs new file mode 100644 index 000000000000..15d0a18f86b6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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.Speech.Transcription/src/Generated/Internal/Optional.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..e4dce3223742 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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.Speech.Transcription/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..d8cda3de5867 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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.Speech.Transcription/src/Generated/ProfanityFilterMode.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/ProfanityFilterMode.cs new file mode 100644 index 000000000000..76d2e82b1c2a --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + /// 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.Speech.Transcription/src/Generated/TranscribeRequest.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribeRequest.Serialization.cs new file mode 100644 index 000000000000..10b01b20dad6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + public 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(Options)) + { + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Options, 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), ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + } + TranscriptionOptions 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 = TranscriptionOptions.DeserializeTranscriptionOptions(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(Options)) + { + content.Add(ModelReaderWriter.Write(Options, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.Transcription/src/Generated/TranscribeRequest.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribeRequest.cs new file mode 100644 index 000000000000..9353675784fa --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + /// The TranscribeRequest. + public 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. + public TranscribeRequest(Stream audio) + { + Argument.AssertNotNull(audio, nameof(audio)); + + Audio = audio; + } + + /// Initializes a new instance of . + /// Metadata for a 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(TranscriptionOptions options, Stream audio, IDictionary serializedAdditionalRawData) + { + Options = options; + Audio = audio; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscribeRequest() + { + } + + /// Metadata for a transcription request. This field contains a JSON-serialized object of type `TranscribeDefinition`. + public TranscriptionOptions Options { get; set; } + /// 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.Speech.Transcription/src/Generated/TranscribedPhrase.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribedPhrase.Serialization.cs new file mode 100644 index 000000000000..019ebd1daf64 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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(TranscribedWord.DeserializeTranscribedWord(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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.Speech.Transcription/src/Generated/TranscribedPhrase.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribedPhrase.cs new file mode 100644 index 000000000000..657a878f7d36 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription +{ + /// 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.Speech.Transcription/src/Generated/TranscribedWord.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribedWord.Serialization.cs new file mode 100644 index 000000000000..af54f794845c --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribedWord.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.Speech.Transcription +{ + public partial class TranscribedWord : 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(TranscribedWord)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscribedWord 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(TranscribedWord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribedWord(document.RootElement, options); + } + + internal static TranscribedWord DeserializeTranscribedWord(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 TranscribedWord(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(TranscribedWord)} does not support writing '{options.Format}' format."); + } + } + + TranscribedWord 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscribedWord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribedWord)} 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 TranscribedWord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscribedWord(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.Speech.Transcription/src/Generated/TranscribedWord.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribedWord.cs new file mode 100644 index 000000000000..53659408bf79 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscribedWord.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.Speech.Transcription +{ + /// Time-stamped word in the display form. + public partial class TranscribedWord + { + /// + /// 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 TranscribedWord(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 TranscribedWord(string text, int offsetMilliseconds, int durationMilliseconds, IDictionary serializedAdditionalRawData) + { + Text = text; + OffsetMilliseconds = offsetMilliseconds; + DurationMilliseconds = durationMilliseconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscribedWord() + { + } + + /// 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.Speech.Transcription/src/Generated/TranscriptionClient.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionClient.cs new file mode 100644 index 000000000000..272d39ebd975 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionClient.cs @@ -0,0 +1,204 @@ +// 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.Speech.Transcription +{ + // Data plane generated client. + /// The Transcription service client. + public partial class TranscriptionClient + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// 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 TranscriptionClient for mocking. + protected TranscriptionClient() + { + } + + /// Initializes a new instance of TranscriptionClient. + /// 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 TranscriptionClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new TranscriptionClientOptions()) + { + } + + /// Initializes a new instance of TranscriptionClient. + /// 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 TranscriptionClient(Uri endpoint, AzureKeyCredential credential, TranscriptionClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new TranscriptionClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Transcribes the provided audio stream. + /// The body of the multipart request. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> TranscribeAsync(TranscribeRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using MultipartFormDataRequestContent content = body.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await TranscribeAsync(content, content.ContentType, context).ConfigureAwait(false); + return Response.FromValue(TranscriptionResult.FromResponse(response), response); + } + + /// Transcribes the provided audio stream. + /// The body of the multipart request. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Transcribe(TranscribeRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using MultipartFormDataRequestContent content = body.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Transcribe(content, content.ContentType, context); + return Response.FromValue(TranscriptionResult.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("TranscriptionClient.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("TranscriptionClient.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); + uri.AppendQuery("api-version", _apiVersion, 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.Speech.Transcription/src/Generated/TranscriptionClientOptions.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionClientOptions.cs new file mode 100644 index 000000000000..ce907807f350 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.Speech.Transcription +{ + /// Client options for TranscriptionClient. + public partial class TranscriptionClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_11_15; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-11-15". + V2024_11_15 = 1, + } + + internal string Version { get; } + + /// Initializes new instance of TranscriptionClientOptions. + public TranscriptionClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_11_15 => "2024-11-15", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionDiarizationOptions.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionDiarizationOptions.Serialization.cs new file mode 100644 index 000000000000..7885f4e3e3d2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionDiarizationOptions.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.Speech.Transcription +{ + public partial class TranscriptionDiarizationOptions : 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(TranscriptionDiarizationOptions)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionDiarizationOptions 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(TranscriptionDiarizationOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionDiarizationOptions(document.RootElement, options); + } + + internal static TranscriptionDiarizationOptions DeserializeTranscriptionDiarizationOptions(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 TranscriptionDiarizationOptions(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(TranscriptionDiarizationOptions)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionDiarizationOptions 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionDiarizationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionDiarizationOptions)} 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 TranscriptionDiarizationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionDiarizationOptions(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.Speech.Transcription/src/Generated/TranscriptionDiarizationOptions.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionDiarizationOptions.cs new file mode 100644 index 000000000000..6183976fcf5f --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionDiarizationOptions.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.Speech.Transcription +{ + /// The Speaker Identification settings. Diarization settings must be specified to enable speaker identification. + public partial class TranscriptionDiarizationOptions + { + /// + /// 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 TranscriptionDiarizationOptions() + { + } + + /// 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 TranscriptionDiarizationOptions(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.Speech.Transcription/src/Generated/TranscriptionOptions.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionOptions.Serialization.cs new file mode 100644 index 000000000000..84c03e924a8e --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionOptions.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.Speech.Transcription +{ + public partial class TranscriptionOptions : 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(TranscriptionOptions)} 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(DiarizationOptions)) + { + writer.WritePropertyName("diarization"u8); + writer.WriteObjectValue(DiarizationOptions, options); + } + if (Optional.IsCollectionDefined(ActiveChannels)) + { + writer.WritePropertyName("channels"u8); + writer.WriteStartArray(); + foreach (var item in ActiveChannels) + { + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionOptions 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(TranscriptionOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionOptions(document.RootElement, options); + } + + internal static TranscriptionOptions DeserializeTranscriptionOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList locales = default; + IDictionary models = default; + ProfanityFilterMode? profanityFilterMode = default; + TranscriptionDiarizationOptions 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 = TranscriptionDiarizationOptions.DeserializeTranscriptionDiarizationOptions(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 TranscriptionOptions( + 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(TranscriptionOptions)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionOptions 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionOptions)} 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 TranscriptionOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionOptions(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.Speech.Transcription/src/Generated/TranscriptionOptions.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionOptions.cs new file mode 100644 index 000000000000..743865181fbc --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionOptions.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.Speech.Transcription +{ + /// Metadata for a transcription request. + public partial class TranscriptionOptions + { + /// + /// 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 TranscriptionOptions() + { + Locales = new ChangeTrackingList(); + Models = new ChangeTrackingDictionary(); + ActiveChannels = 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 TranscriptionOptions(IList locales, IDictionary models, ProfanityFilterMode? profanityFilterMode, TranscriptionDiarizationOptions diarizationOptions, IList activeChannels, IDictionary serializedAdditionalRawData) + { + Locales = locales; + Models = models; + ProfanityFilterMode = profanityFilterMode; + DiarizationOptions = diarizationOptions; + ActiveChannels = activeChannels; + _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 TranscriptionDiarizationOptions DiarizationOptions { 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 ActiveChannels { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionResult.Serialization.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionResult.Serialization.cs new file mode 100644 index 000000000000..957faa5969c0 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionResult.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.Speech.Transcription +{ + public partial class TranscriptionResult : 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(TranscriptionResult)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TranscriptionResult 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(TranscriptionResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscriptionResult(document.RootElement, options); + } + + internal static TranscriptionResult DeserializeTranscriptionResult(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 TranscriptionResult(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(TranscriptionResult)} does not support writing '{options.Format}' format."); + } + } + + TranscriptionResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscriptionResult)} 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 TranscriptionResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTranscriptionResult(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.Speech.Transcription/src/Generated/TranscriptionResult.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionResult.cs new file mode 100644 index 000000000000..d347e9c0cbd1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Generated/TranscriptionResult.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.Speech.Transcription +{ + /// The result of the transcribe operation. + public partial class TranscriptionResult + { + /// + /// 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 TranscriptionResult(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 TranscriptionResult(int durationMilliseconds, IReadOnlyList combinedPhrases, IReadOnlyList phrases, IDictionary serializedAdditionalRawData) + { + DurationMilliseconds = durationMilliseconds; + CombinedPhrases = combinedPhrases; + Phrases = phrases; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TranscriptionResult() + { + } + + /// 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.Speech.Transcription/src/Properties/AssemblyInfo.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..06d7756742df --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/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.Speech.Transcription.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.Speech.Transcription/tests/Azure.AI.Speech.Transcription.Tests.csproj b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tests/Azure.AI.Speech.Transcription.Tests.csproj new file mode 100644 index 000000000000..9e48a49ccb21 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tests/Azure.AI.Speech.Transcription.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tests/Generated/Samples/Samples_TranscriptionClient.cs b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tests/Generated/Samples/Samples_TranscriptionClient.cs new file mode 100644 index 000000000000..880baf056b40 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tests/Generated/Samples/Samples_TranscriptionClient.cs @@ -0,0 +1,250 @@ +// 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.Speech.Transcription.Samples +{ + public partial class Samples_TranscriptionClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Transcription_Transcribe_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + 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_Transcription_Transcribe_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + 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_Transcription_Transcribe_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + TranscribeRequest body = new TranscribeRequest(null); + Response response = client.Transcribe(body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Transcription_Transcribe_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + TranscribeRequest body = new TranscribeRequest(null); + Response response = await client.TranscribeAsync(body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Transcription_Transcribe_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + 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_Transcription_Transcribe_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + 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_Transcription_Transcribe_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + TranscribeRequest body = new TranscribeRequest(null) + { + Options = new TranscriptionOptions + { + Locales = { "" }, + Models = +{ +["key"] = new Uri("http://localhost:3000") +}, + ProfanityFilterMode = ProfanityFilterMode.None, + DiarizationOptions = new TranscriptionDiarizationOptions + { + Enabled = true, + MaxSpeakers = 1234, + }, + ActiveChannels = { 1234 }, + }, + }; + Response response = client.Transcribe(body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Transcription_Transcribe_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + TranscriptionClient client = new TranscriptionClient(endpoint, credential); + + TranscribeRequest body = new TranscribeRequest(null) + { + Options = new TranscriptionOptions + { + Locales = { "" }, + Models = +{ +["key"] = new Uri("http://localhost:3000") +}, + ProfanityFilterMode = ProfanityFilterMode.None, + DiarizationOptions = new TranscriptionDiarizationOptions + { + Enabled = true, + MaxSpeakers = 1234, + }, + ActiveChannels = { 1234 }, + }, + }; + Response response = await client.TranscribeAsync(body); + } + } +} diff --git a/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tsp-location.yaml b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tsp-location.yaml new file mode 100644 index 000000000000..b410f14d39d7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.AI.Speech.Transcription/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/Speech.Transcription +commit: 42d832f4bd16b04dd3cb124ca3e8dfaef1211bc2 +repo: Azure/azure-rest-api-specs +additionalDirectories: