diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/LICENSE.txt b/sdk/cognitiveservices/cognitiveservices-speaker-identification/LICENSE.txt new file mode 100644 index 000000000000..2d3163745319 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/README.md b/sdk/cognitiveservices/cognitiveservices-speaker-identification/README.md new file mode 100644 index 000000000000..e6ad4b794fde --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/README.md @@ -0,0 +1,106 @@ +## An isomorphic javascript sdk for - SpeakerIdentificationAPI + +This package contains an isomorphic SDK (runs both in node.js and in browsers) for SpeakerIdentificationAPI. + +### Currently supported environments + +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. + +### Prerequisites + +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/cognitiveservices-speaker-identification` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: +```bash +npm install --save @azure/cognitiveservices-speaker-identification @azure/identity +``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + +### How to use + +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. + +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. +#### nodejs - Authentication, client creation, and listProfiles textIndependent as an example written in JavaScript. + +##### Sample code + +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { SpeakerIdentificationAPI } = require("@azure/cognitiveservices-speaker-identification"); +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new SpeakerIdentificationAPI(creds, subscriptionId); +const top = 1; +client.textIndependent.listProfiles(top).then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log("An error occurred:"); + console.error(err); +}); +``` + +#### browser - Authentication, client creation, and listProfiles textIndependent as an example written in JavaScript. + +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. + +##### Sample code + +- index.html + +```html + + + + @azure/cognitiveservices-speaker-identification sample + + + + + +``` + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-speaker-identification/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/package.json b/sdk/cognitiveservices/cognitiveservices-speaker-identification/package.json new file mode 100644 index 000000000000..6d836cb93dc6 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/package.json @@ -0,0 +1,58 @@ +{ + "name": "@azure/cognitiveservices-speaker-identification", + "author": "Microsoft Corporation", + "description": "SpeakerIdentificationAPI Library with typescript type definitions for node.js and browser.", + "version": "1.0.0", + "dependencies": { + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", + "tslib": "^1.10.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/cognitiveservices-speaker-identification.js", + "module": "./esm/speakerIdentificationAPI.js", + "types": "./esm/speakerIdentificationAPI.d.ts", + "devDependencies": { + "typescript": "^3.6.0", + "rollup": "^1.18.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.6.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-speaker-identification", + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "esm/**/*.js", + "esm/**/*.js.map", + "esm/**/*.d.ts", + "esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-speaker-identification.js.map'\" -o ./dist/cognitiveservices-speaker-identification.min.js ./dist/cognitiveservices-speaker-identification.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false, + "autoPublish": true +} diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-speaker-identification/rollup.config.js new file mode 100644 index 000000000000..ff543d9a04b5 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/rollup.config.js @@ -0,0 +1,37 @@ +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/speakerIdentificationAPI.js", + external: [ + "@azure/ms-rest-js", + "@azure/ms-rest-azure-js" + ], + output: { + file: "./dist/cognitiveservices-speaker-identification.js", + format: "umd", + name: "Azure.CognitiveservicesSpeakerIdentification", + sourcemap: true, + globals: { + "@azure/ms-rest-js": "msRest", + "@azure/ms-rest-azure-js": "msRestAzure" + }, + banner: `/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */` + }, + plugins: [ + nodeResolve({ mainFields: ['module', 'main'] }), + sourcemaps() + ] +}; + +export default config; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/index.ts new file mode 100644 index 000000000000..3e6472bdae8a --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/index.ts @@ -0,0 +1,285 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + + +import * as msRest from "@azure/ms-rest-js"; + +/** + * Speaker profile locale + */ +export interface LocaleInfo { + locale: string; +} + +/** + * Text-Independent Speaker profile info list + */ +export interface TiProfileInfoList { + profiles?: any; + nextLink?: string; +} + +/** + * Text-Independent Speaker profile info + */ +export interface TiProfileInfo { + profileId?: string; + locale?: string; + /** + * Possible values include: 'Enrolling', 'Training', 'Enrolled' + */ + enrollmentStatus?: TrainingStatusType; + createdDateTime?: string; + lastUpdatedDateTime?: string; + enrollmentsCount?: number; + enrollmentsLength?: number; + enrollmentsSpeechLength?: number; + remainingEnrollmentsSpeechLength?: number; + modelVersion?: string; +} + +/** + * Speaker profile enrollment info + */ +export interface TiEnrollmentInfo { + profileId?: string; + /** + * Possible values include: 'Enrolling', 'Training', 'Enrolled' + */ + enrollmentStatus?: TrainingStatusType; + enrollmentsCount?: number; + enrollmentsLength?: number; + enrollmentsSpeechLength?: number; + remainingEnrollmentsSpeechLength?: number; + /** + * This enrolment audio length in seconds. + */ + audioLength?: number; + /** + * This enrollment audio pure speech (which is the amount of audio after removing silence and + * non-speech segments) length in seconds. + */ + audioSpeechLength?: number; +} + +/** + * Identified speaker info + */ +export interface IdentifyInfo { + /** + * ID of identified of profile. If no candidate is identified as the right speaker, the value is + * set to empty GUID. + */ + profileId?: string; + /** + * A float number indicating the similarity between input audio and targeted voice print. This + * number must be between 0 and 1. A higher number means higher similarity. + */ + score?: number; +} + +/** + * An interface representing IdentifiedSingleSpeakerInfo. + */ +export interface IdentifiedSingleSpeakerInfo { + /** + * Object containing data of identified profile. + */ + identifiedProfile?: IdentifyInfo; + /** + * Object containing data of the top 5 profiles (including identified profile) sorted in + * descending order by score. + */ + profilesRanking?: any; +} + +/** + * An interface representing ErrorError. + */ +export interface ErrorError { + code?: string; + message?: string; +} + +/** + * An interface representing ErrorModel. + */ +export interface ErrorModel { + error: ErrorError; +} + +/** + * Optional Parameters. + */ +export interface TextIndependentCreateProfileOptionalParams extends msRest.RequestOptionsBase { + /** + * Provide following detail info when creating a new profile. + * Fields | Description + * ------- | ------------ + * locale | Locale for the language of this speaker profile. A complete supported locale list is + * here: + */ + profileInfo?: LocaleInfo; +} + +/** + * Optional Parameters. + */ +export interface TextIndependentListProfilesOptionalParams extends msRest.RequestOptionsBase { + /** + * The number of profiles to return. Default is 100 and the maximum is 500 + */ + top?: number; +} + +/** + * Optional Parameters. + */ +export interface TextIndependentCreateEnrollmentOptionalParams extends msRest.RequestOptionsBase { + /** + * If true, a voice print will be created immediately for this profile regardless of how much + * speech is supplied or stored. Default is false. + */ + ignoreMinLength?: boolean; +} + +/** + * Optional Parameters. + */ +export interface TextIndependentIdentifySingleSpeakerOptionalParams extends msRest.RequestOptionsBase { + /** + * If true, the minimum amount of speech needed for identification is skipped. Default is false. + */ + ignoreMinLength?: boolean; +} + +/** + * Defines headers for CreateProfile operation. + */ +export interface TextIndependentCreateProfileHeaders { + /** + * url location of new resource + */ + location: string; +} + +/** + * Defines values for TrainingStatusType. + * Possible values include: 'Enrolling', 'Training', 'Enrolled' + * @readonly + * @enum {string} + */ +export type TrainingStatusType = 'Enrolling' | 'Training' | 'Enrolled'; + +/** + * Contains response data for the createProfile operation. + */ +export type TextIndependentCreateProfileResponse = TiProfileInfo & TextIndependentCreateProfileHeaders & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: TextIndependentCreateProfileHeaders; + + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: TiProfileInfo; + }; +}; + +/** + * Contains response data for the listProfiles operation. + */ +export type TextIndependentListProfilesResponse = TiProfileInfoList & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: TiProfileInfoList; + }; +}; + +/** + * Contains response data for the getProfile operation. + */ +export type TextIndependentGetProfileResponse = TiProfileInfo & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: TiProfileInfo; + }; +}; + +/** + * Contains response data for the createEnrollment operation. + */ +export type TextIndependentCreateEnrollmentResponse = TiEnrollmentInfo & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: TiEnrollmentInfo; + }; +}; + +/** + * Contains response data for the identifySingleSpeaker operation. + */ +export type TextIndependentIdentifySingleSpeakerResponse = IdentifiedSingleSpeakerInfo & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: IdentifiedSingleSpeakerInfo; + }; +}; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/mappers.ts new file mode 100644 index 000000000000..e57738c99d13 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/mappers.ts @@ -0,0 +1,292 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + + +export const LocaleInfo: msRest.CompositeMapper = { + serializedName: "LocaleInfo", + type: { + name: "Composite", + className: "LocaleInfo", + modelProperties: { + locale: { + required: true, + serializedName: "locale", + type: { + name: "String" + } + } + } + } +}; + +export const TiProfileInfoList: msRest.CompositeMapper = { + serializedName: "TiProfileInfoList", + type: { + name: "Composite", + className: "TiProfileInfoList", + modelProperties: { + profiles: { + serializedName: "profiles", + type: { + name: "Object" + } + }, + nextLink: { + serializedName: "@nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const TiProfileInfo: msRest.CompositeMapper = { + serializedName: "TiProfileInfo", + type: { + name: "Composite", + className: "TiProfileInfo", + modelProperties: { + profileId: { + serializedName: "profileId", + type: { + name: "Uuid" + } + }, + locale: { + serializedName: "locale", + type: { + name: "String" + } + }, + enrollmentStatus: { + serializedName: "enrollmentStatus", + type: { + name: "Enum", + allowedValues: [ + "Enrolling", + "Training", + "Enrolled" + ] + } + }, + createdDateTime: { + serializedName: "createdDateTime", + type: { + name: "String" + } + }, + lastUpdatedDateTime: { + serializedName: "lastUpdatedDateTime", + type: { + name: "String" + } + }, + enrollmentsCount: { + serializedName: "enrollmentsCount", + type: { + name: "Number" + } + }, + enrollmentsLength: { + serializedName: "enrollmentsLength", + type: { + name: "Number" + } + }, + enrollmentsSpeechLength: { + serializedName: "enrollmentsSpeechLength", + type: { + name: "Number" + } + }, + remainingEnrollmentsSpeechLength: { + serializedName: "remainingEnrollmentsSpeechLength", + type: { + name: "Number" + } + }, + modelVersion: { + serializedName: "modelVersion", + type: { + name: "String" + } + } + } + } +}; + +export const TiEnrollmentInfo: msRest.CompositeMapper = { + serializedName: "TiEnrollmentInfo", + type: { + name: "Composite", + className: "TiEnrollmentInfo", + modelProperties: { + profileId: { + serializedName: "profileId", + type: { + name: "Uuid" + } + }, + enrollmentStatus: { + serializedName: "enrollmentStatus", + type: { + name: "Enum", + allowedValues: [ + "Enrolling", + "Training", + "Enrolled" + ] + } + }, + enrollmentsCount: { + serializedName: "enrollmentsCount", + type: { + name: "Number" + } + }, + enrollmentsLength: { + serializedName: "enrollmentsLength", + type: { + name: "Number" + } + }, + enrollmentsSpeechLength: { + serializedName: "enrollmentsSpeechLength", + type: { + name: "Number" + } + }, + remainingEnrollmentsSpeechLength: { + serializedName: "remainingEnrollmentsSpeechLength", + type: { + name: "Number" + } + }, + audioLength: { + serializedName: "audioLength", + type: { + name: "Number" + } + }, + audioSpeechLength: { + serializedName: "audioSpeechLength", + type: { + name: "Number" + } + } + } + } +}; + +export const IdentifyInfo: msRest.CompositeMapper = { + serializedName: "IdentifyInfo", + type: { + name: "Composite", + className: "IdentifyInfo", + modelProperties: { + profileId: { + nullable: false, + serializedName: "profileId", + constraints: { + Pattern: /^([0-9a-fA-F]){8}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){12}$/ + }, + type: { + name: "Uuid" + } + }, + score: { + serializedName: "score", + type: { + name: "Number" + } + } + } + } +}; + +export const IdentifiedSingleSpeakerInfo: msRest.CompositeMapper = { + serializedName: "IdentifiedSingleSpeakerInfo", + type: { + name: "Composite", + className: "IdentifiedSingleSpeakerInfo", + modelProperties: { + identifiedProfile: { + serializedName: "identifiedProfile", + type: { + name: "Composite", + className: "IdentifyInfo" + } + }, + profilesRanking: { + serializedName: "profilesRanking", + type: { + name: "Object" + } + } + } + } +}; + +export const ErrorError: msRest.CompositeMapper = { + serializedName: "Error_error", + type: { + name: "Composite", + className: "ErrorError", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const ErrorModel: msRest.CompositeMapper = { + serializedName: "Error", + type: { + name: "Composite", + className: "ErrorModel", + modelProperties: { + error: { + required: true, + serializedName: "error", + type: { + name: "Composite", + className: "ErrorError" + } + } + } + } +}; + +export const TextIndependentCreateProfileHeaders: msRest.CompositeMapper = { + serializedName: "textindependent-createprofile-headers", + type: { + name: "Composite", + className: "TextIndependentCreateProfileHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/parameters.ts new file mode 100644 index 000000000000..56ad4554c0df --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/parameters.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +export const endpoint: msRest.OperationURLParameter = { + parameterPath: "endpoint", + mapper: { + required: true, + serializedName: "Endpoint", + defaultValue: '', + type: { + name: "String" + } + }, + skipEncoding: true +}; +export const ignoreMinLength: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "ignoreMinLength" + ], + mapper: { + serializedName: "ignoreMinLength", + type: { + name: "Boolean" + } + } +}; +export const profileId: msRest.OperationURLParameter = { + parameterPath: "profileId", + mapper: { + required: true, + serializedName: "profileId", + constraints: { + Pattern: /^([0-9a-fA-F]){8}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){12}$/ + }, + type: { + name: "Uuid" + } + } +}; +export const profileIds: msRest.OperationQueryParameter = { + parameterPath: "profileIds", + mapper: { + required: true, + serializedName: "profileIds", + type: { + name: "String" + } + } +}; +export const top: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "top" + ], + mapper: { + serializedName: "$top", + type: { + name: "Number" + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/textIndependentMappers.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/textIndependentMappers.ts new file mode 100644 index 000000000000..69b2164944cf --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/models/textIndependentMappers.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ErrorError, + ErrorModel, + IdentifiedSingleSpeakerInfo, + IdentifyInfo, + LocaleInfo, + TextIndependentCreateProfileHeaders, + TiEnrollmentInfo, + TiProfileInfo, + TiProfileInfoList +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/operations/index.ts new file mode 100644 index 000000000000..94ef0771222c --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/operations/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export * from "./textIndependent"; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/operations/textIndependent.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/operations/textIndependent.ts new file mode 100644 index 000000000000..ad8fc8b8f9f3 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/operations/textIndependent.ts @@ -0,0 +1,526 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/textIndependentMappers"; +import * as Parameters from "../models/parameters"; +import { SpeakerIdentificationAPIContext } from "../speakerIdentificationAPIContext"; + +/** Class representing a TextIndependent. */ +export class TextIndependent { + private readonly client: SpeakerIdentificationAPIContext; + + /** + * Create a TextIndependent. + * @param {SpeakerIdentificationAPIContext} client Reference to the service client. + */ + constructor(client: SpeakerIdentificationAPIContext) { + this.client = client; + } + + /** + * Creates a new speaker profile with specified locale. + * One subscription can create 10,000 speaker profiles at most. + * @summary Create Profile + * @param [options] The optional parameters + * @returns Promise + */ + createProfile(options?: Models.TextIndependentCreateProfileOptionalParams): Promise; + /** + * @param callback The callback + */ + createProfile(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + createProfile(options: Models.TextIndependentCreateProfileOptionalParams, callback: msRest.ServiceCallback): void; + createProfile(options?: Models.TextIndependentCreateProfileOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + createProfileOperationSpec, + callback) as Promise; + } + + /** + * Retrieves a set of profiles. + * Profiles are sorted alphabetically by ProfileId + * @summary List Profile + * @param [options] The optional parameters + * @returns Promise + */ + listProfiles(options?: Models.TextIndependentListProfilesOptionalParams): Promise; + /** + * @param callback The callback + */ + listProfiles(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listProfiles(options: Models.TextIndependentListProfilesOptionalParams, callback: msRest.ServiceCallback): void; + listProfiles(options?: Models.TextIndependentListProfilesOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listProfilesOperationSpec, + callback) as Promise; + } + + /** + * Retrieves a single profile by ID. + * @summary Retrieve Single Profile + * @param profileId Unique identifier for profile id (guid). + * @param [options] The optional parameters + * @returns Promise + */ + getProfile(profileId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param profileId Unique identifier for profile id (guid). + * @param callback The callback + */ + getProfile(profileId: string, callback: msRest.ServiceCallback): void; + /** + * @param profileId Unique identifier for profile id (guid). + * @param options The optional parameters + * @param callback The callback + */ + getProfile(profileId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getProfile(profileId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + profileId, + options + }, + getProfileOperationSpec, + callback) as Promise; + } + + /** + * Deletes an existing profile. + * @summary Delete Profile + * @param profileId Unique identifier for profile id (guid). + * @param [options] The optional parameters + * @returns Promise + */ + deleteProfile(profileId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param profileId Unique identifier for profile id (guid). + * @param callback The callback + */ + deleteProfile(profileId: string, callback: msRest.ServiceCallback): void; + /** + * @param profileId Unique identifier for profile id (guid). + * @param options The optional parameters + * @param callback The callback + */ + deleteProfile(profileId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteProfile(profileId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + profileId, + options + }, + deleteProfileOperationSpec, + callback); + } + + /** + * Resets existing profile to its original creation state. The reset operation does the following: + * * Updates enrollmentStatus to Enrolling. + * * Updates lastUpdatedDateTime. + * * Updates enrollmentsCount to 0. + * * Updates enrollmentsLength to 0. + * * Updates enrollmentsSpeechLength to 0. + * * Updates remainingEnrollmentsSpeechLength to the required number. + * * Removes all associated enrollments from storage. + * * Removes chosen passphrase association. + * * Resets value of modelVersion. + * @summary Reset Profile + * @param profileId Unique identifier for profile id (guid). + * @param [options] The optional parameters + * @returns Promise + */ + resetProfile(profileId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param profileId Unique identifier for profile id (guid). + * @param callback The callback + */ + resetProfile(profileId: string, callback: msRest.ServiceCallback): void; + /** + * @param profileId Unique identifier for profile id (guid). + * @param options The optional parameters + * @param callback The callback + */ + resetProfile(profileId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + resetProfile(profileId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + profileId, + options + }, + resetProfileOperationSpec, + callback); + } + + /** + * Adds an enrollment to existing profile. + * If the minimum number of requested enrollment audios is reached, a voice print is created. + * If the voice print was created before, it gets recreated from all existing enrollment audios + * including the new one. + * + * Limitations: + * * Minimum audio input length per request is **1 second** + * * Maximum audio input length per request is **120 seconds** + * * Minimum total effective speech length (excluding silence and other non-speech frames) for + * creating a voiceprint is **20 seconds** + * This limitation can be disabled by setting ignoreMinLength to **true**. + * + * * Maximum total audio input length allowed for creating a voiceprint is **300 seconds** + * * Minimum audio Signal-to-noise ratio (SNR) is **0dB** + * @summary Enroll Profile + * @param audioData Binary audio file. Supported formats are audio/wav; codecs=audio/pcm. Supports + * audio up to 5MB. + * @param profileId Unique identifier for profile id (guid). + * @param [options] The optional parameters + * @returns Promise + */ + createEnrollment(audioData: msRest.HttpRequestBody, profileId: string, options?: Models.TextIndependentCreateEnrollmentOptionalParams): Promise; + /** + * @param audioData Binary audio file. Supported formats are audio/wav; codecs=audio/pcm. Supports + * audio up to 5MB. + * @param profileId Unique identifier for profile id (guid). + * @param callback The callback + */ + createEnrollment(audioData: msRest.HttpRequestBody, profileId: string, callback: msRest.ServiceCallback): void; + /** + * @param audioData Binary audio file. Supported formats are audio/wav; codecs=audio/pcm. Supports + * audio up to 5MB. + * @param profileId Unique identifier for profile id (guid). + * @param options The optional parameters + * @param callback The callback + */ + createEnrollment(audioData: msRest.HttpRequestBody, profileId: string, options: Models.TextIndependentCreateEnrollmentOptionalParams, callback: msRest.ServiceCallback): void; + createEnrollment(audioData: msRest.HttpRequestBody, profileId: string, options?: Models.TextIndependentCreateEnrollmentOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + audioData, + profileId, + options + }, + createEnrollmentOperationSpec, + callback) as Promise; + } + + /** + * Identifies who is speaking in input audio among a list of candidate profiles. + * + * Limitations: + * * Minimum audio input length is **1 second** + * * Maximum audio input length is **120 seconds** + * * Minimum candidate speakers count is **1** + * * Maximum candidate speakers count is **50** + * * Minimum effective speech length (excluding silence and other non-speech frames) is **4 + * seconds** + * This limitation can be disabled by setting "ignoreMinLength" to **true**. + * + * * Minimum audio Signal-to-noise ratio (SNR) is **0dB** + * @summary Identify Single Speaker Profile + * @param profileIds Comma-delimited profile IDs. Maximum supported number is 50 IDs. + * @param audioData Binary audio file. Supported formats are audio/wav; codecs=audio/pcm. Supports + * audio up to 5MB. + * @param [options] The optional parameters + * @returns Promise + */ + identifySingleSpeaker(profileIds: string, audioData: msRest.HttpRequestBody, options?: Models.TextIndependentIdentifySingleSpeakerOptionalParams): Promise; + /** + * @param profileIds Comma-delimited profile IDs. Maximum supported number is 50 IDs. + * @param audioData Binary audio file. Supported formats are audio/wav; codecs=audio/pcm. Supports + * audio up to 5MB. + * @param callback The callback + */ + identifySingleSpeaker(profileIds: string, audioData: msRest.HttpRequestBody, callback: msRest.ServiceCallback): void; + /** + * @param profileIds Comma-delimited profile IDs. Maximum supported number is 50 IDs. + * @param audioData Binary audio file. Supported formats are audio/wav; codecs=audio/pcm. Supports + * audio up to 5MB. + * @param options The optional parameters + * @param callback The callback + */ + identifySingleSpeaker(profileIds: string, audioData: msRest.HttpRequestBody, options: Models.TextIndependentIdentifySingleSpeakerOptionalParams, callback: msRest.ServiceCallback): void; + identifySingleSpeaker(profileIds: string, audioData: msRest.HttpRequestBody, options?: Models.TextIndependentIdentifySingleSpeakerOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + profileIds, + audioData, + options + }, + identifySingleSpeakerOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const createProfileOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "text-independent/profiles", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: [ + "options", + "profileInfo" + ], + mapper: Mappers.LocaleInfo + }, + responses: { + 201: { + bodyMapper: Mappers.TiProfileInfo, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + 400: { + bodyMapper: Mappers.ErrorModel, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + 401: { + bodyMapper: Mappers.ErrorModel, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + 403: { + bodyMapper: Mappers.ErrorModel, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + 415: { + bodyMapper: Mappers.ErrorModel, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + 429: { + bodyMapper: Mappers.ErrorModel, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + 500: { + bodyMapper: Mappers.ErrorModel, + headersMapper: Mappers.TextIndependentCreateProfileHeaders + }, + default: {} + }, + serializer +}; + +const listProfilesOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "text-independent/profiles", + urlParameters: [ + Parameters.endpoint + ], + queryParameters: [ + Parameters.top + ], + responses: { + 200: { + bodyMapper: Mappers.TiProfileInfoList + }, + 400: { + bodyMapper: Mappers.ErrorModel + }, + 401: { + bodyMapper: Mappers.ErrorModel + }, + 429: { + bodyMapper: Mappers.ErrorModel + }, + 500: { + bodyMapper: Mappers.ErrorModel + }, + default: {} + }, + serializer +}; + +const getProfileOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "text-independent/profiles/{profileId}", + urlParameters: [ + Parameters.endpoint, + Parameters.profileId + ], + responses: { + 200: { + bodyMapper: Mappers.TiProfileInfo + }, + 401: { + bodyMapper: Mappers.ErrorModel + }, + 404: { + bodyMapper: Mappers.ErrorModel + }, + 429: { + bodyMapper: Mappers.ErrorModel + }, + 500: { + bodyMapper: Mappers.ErrorModel + }, + default: {} + }, + serializer +}; + +const deleteProfileOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "text-independent/profiles/{profileId}", + urlParameters: [ + Parameters.endpoint, + Parameters.profileId + ], + responses: { + 204: {}, + 401: { + bodyMapper: Mappers.ErrorModel + }, + 429: { + bodyMapper: Mappers.ErrorModel + }, + 500: { + bodyMapper: Mappers.ErrorModel + }, + default: {} + }, + serializer +}; + +const resetProfileOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "text-independent/profiles/{profileId}/reset", + urlParameters: [ + Parameters.endpoint, + Parameters.profileId + ], + responses: { + 204: {}, + 401: { + bodyMapper: Mappers.ErrorModel + }, + 404: { + bodyMapper: Mappers.ErrorModel + }, + 429: { + bodyMapper: Mappers.ErrorModel + }, + 500: { + bodyMapper: Mappers.ErrorModel + }, + default: {} + }, + serializer +}; + +const createEnrollmentOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "text-independent/profiles/{profileId}/enrollments", + urlParameters: [ + Parameters.endpoint, + Parameters.profileId + ], + queryParameters: [ + Parameters.ignoreMinLength + ], + requestBody: { + parameterPath: "audioData", + mapper: { + required: true, + serializedName: "audioData", + type: { + name: "Stream" + } + } + }, + contentType: "audio/wav; codecs=audio/pcm", + responses: { + 201: { + bodyMapper: Mappers.TiEnrollmentInfo + }, + 400: { + bodyMapper: Mappers.ErrorModel + }, + 401: { + bodyMapper: Mappers.ErrorModel + }, + 403: { + bodyMapper: Mappers.ErrorModel + }, + 404: { + bodyMapper: Mappers.ErrorModel + }, + 409: { + bodyMapper: Mappers.ErrorModel + }, + 415: { + bodyMapper: Mappers.ErrorModel + }, + 429: { + bodyMapper: Mappers.ErrorModel + }, + 500: { + bodyMapper: Mappers.ErrorModel + }, + default: {} + }, + serializer +}; + +const identifySingleSpeakerOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "text-independent/profiles/identifySingleSpeaker", + urlParameters: [ + Parameters.endpoint + ], + queryParameters: [ + Parameters.profileIds, + Parameters.ignoreMinLength + ], + requestBody: { + parameterPath: "audioData", + mapper: { + required: true, + serializedName: "audioData", + type: { + name: "Stream" + } + } + }, + contentType: "audio/wav; codecs=audio/pcm", + responses: { + 200: { + bodyMapper: Mappers.IdentifiedSingleSpeakerInfo + }, + 400: { + bodyMapper: Mappers.ErrorModel + }, + 401: { + bodyMapper: Mappers.ErrorModel + }, + 415: { + bodyMapper: Mappers.ErrorModel + }, + 429: { + bodyMapper: Mappers.ErrorModel + }, + 500: { + bodyMapper: Mappers.ErrorModel + }, + default: {} + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/speakerIdentificationAPI.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/speakerIdentificationAPI.ts new file mode 100644 index 000000000000..de83018d4f57 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/speakerIdentificationAPI.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as operations from "./operations"; +import { SpeakerIdentificationAPIContext } from "./speakerIdentificationAPIContext"; + +class SpeakerIdentificationAPI extends SpeakerIdentificationAPIContext { + // Operation groups + textIndependent: operations.TextIndependent; + + /** + * Initializes a new instance of the SpeakerIdentificationAPI class. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus.api.cognitive.microsoft.com). + * @param credentials Subscription credentials which uniquely identify client subscription. + * Credentials implementing the TokenCredential interface from the @azure/identity package are + * recommended. For more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, endpoint: string, options?: msRest.ServiceClientOptions) { + super(credentials, endpoint, options); + this.textIndependent = new operations.TextIndependent(this); + } +} + +// Operation Specifications + +export { + SpeakerIdentificationAPI, + SpeakerIdentificationAPIContext, + Models as SpeakerIdentificationAPIModels, + Mappers as SpeakerIdentificationAPIMappers +}; +export * from "./operations"; diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/speakerIdentificationAPIContext.ts b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/speakerIdentificationAPIContext.ts new file mode 100644 index 000000000000..32d958523372 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/src/speakerIdentificationAPIContext.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +const packageName = "@azure/cognitiveservices-speaker-identification"; +const packageVersion = "1.0.0"; + +export class SpeakerIdentificationAPIContext extends msRest.ServiceClient { + endpoint: string; + credentials: msRest.ServiceClientCredentials | TokenCredential; + + /** + * Initializes a new instance of the SpeakerIdentificationAPIContext class. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus.api.cognitive.microsoft.com). + * @param credentials Subscription credentials which uniquely identify client subscription. + * Credentials implementing the TokenCredential interface from the @azure/identity package are + * recommended. For more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, endpoint: string, options?: msRest.ServiceClientOptions) { + if (endpoint == undefined) { + throw new Error("'endpoint' cannot be null."); + } + if (credentials == undefined) { + throw new Error("'credentials' cannot be null."); + } + + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = msRest.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.baseUri = "{Endpoint}/speaker/identification/v2.0"; + this.requestContentType = "application/json; charset=utf-8"; + this.endpoint = endpoint; + this.credentials = credentials; + } +} diff --git a/sdk/cognitiveservices/cognitiveservices-speaker-identification/tsconfig.json b/sdk/cognitiveservices/cognitiveservices-speaker-identification/tsconfig.json new file mode 100644 index 000000000000..422b584abd5e --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-speaker-identification/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es5", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6", "dom"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./src/**/*.ts"], + "exclude": ["node_modules"] +}