### Set up Node.js Express Project Source: https://learn.microsoft.com/en-us/azure/ai-services/immersive-reader/quickstarts/client-libraries This snippet outlines the initial setup for a Node.js web application using the Express framework. It covers installing the `express-generator` globally, creating a new Express project, and then installing project dependencies including `request`, `dotenv`, `axios`, and `qs` using either yarn or npm. ```bash npm install express-generator -g express --view=pug quickstart-nodejs cd quickstart-nodejs yarn yarn add request yarn add dotenv npm install axios qs ``` -------------------------------- ### List Speech SDK Contents for Go Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform Lists the contents of the top-level directory of the extracted Speech SDK package to validate the installation. ```bash ls -l "$SPEECHSDK_ROOT" ``` -------------------------------- ### Install QnA Maker Client Library Source: https://learn.microsoft.com/en-us/azure/ai-services/qnamaker/quickstarts/quickstart-sdk_source=recommendations Installs the QnA Maker client library for Python using pip. Ensure you have Python 3.x installed. This command fetches version 0.2.0 of the library. ```console pip install azure-cognitiveservices-knowledge-qnamaker==0.2.0 ``` -------------------------------- ### Start Node.js Application (Bash) Source: https://learn.microsoft.com/en-us/azure/ai-services/immersive-reader/how-to-multiple-resources This command initiates the Node.js web server for the Immersive Reader quickstart application. It assumes the project dependencies have been installed. ```bash npm start ``` -------------------------------- ### Install QnA Maker NPM Packages Source: https://learn.microsoft.com/en-us/azure/ai-services/qnamaker/quickstarts/quickstart-sdk Installs the necessary NPM packages for interacting with the QnA Maker service. These include the core QnA Maker client, the runtime client, and the MS REST client. ```bash npm install @azure/cognitiveservices-qnamaker npm install @azure/cognitiveservices-qnamaker-runtime npm install @azure/ms-rest-js ``` -------------------------------- ### Install Linux System Libraries for Speech SDK Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform_pivots=programming-language-java&tabs=jre These commands install necessary system libraries on Ubuntu/Debian-based Linux distributions for the Speech SDK. Ensure you have the latest LTS release of your distribution. ```bash sudo apt-get update sudo apt-get install build-essential ca-certificates libasound2-dev libssl-dev wget ``` ```bash sudo yum update sudo yum install alsa-lib ca-certificates openssl wget ``` ```bash sudo tdnf update sudo tdnf install alsa-lib ca-certificates openssl wget ``` -------------------------------- ### Install QnA Maker Client Library Source: https://learn.microsoft.com/en-us/azure/ai-services/qnamaker/quickstarts/quickstart-sdk Installs the QnA Maker client library for Python version 0.2.0 using pip. This library is necessary for interacting with the QnA Maker API. ```bash pip install azure-cognitiveservices-knowledge-qnamaker==0.2.0 ``` -------------------------------- ### Transcriptions - Submit Response Example Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-get-speech-session-id_source=recommendations This example shows the structure of a response from the Transcriptions - Submit request. The 'self' element contains the Transcription ID (a GUID) which is needed for further operations. ```APIDOC ## POST /speechtotext/v3.1/transcriptions ### Description Submits a batch transcription request. The response contains a `self` URL that includes the Transcription ID. ### Method POST ### Endpoint /speechtotext/v3.1/transcriptions ### Parameters #### Request Body - **audioFileUrl** (string) - Required - The URL of the audio file to transcribe. - **locale** (string) - Required - The language of the audio. - **displayName** (string) - Optional - A display name for the transcription. ### Request Example ```json { "audioFileUrl": "https://example.com/audio.wav", "locale": "en-US", "displayName": "My Transcription" } ``` ### Response #### Success Response (200 or 201) - **self** (string) - The URL of the transcription resource, containing the Transcription ID (GUID). - **model** (object) - Information about the transcription model used. - **links** (object) - Links to related resources, such as transcription files. - **properties** (object) - Additional properties of the transcription. - **lastActionDateTime** (string) - The date and time of the last action. - **status** (string) - The current status of the transcription. - **createdDateTime** (string) - The date and time the transcription was created. - **locale** (string) - The locale of the transcription. - **displayName** (string) - The display name of the transcription. #### Response Example ```json { "self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/transcriptions/aaaabbbb-0000-cccc-1111-dddd2222eeee", "model": { "self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/models/base/bbbbcccc-1111-dddd-2222-eeee3333ffff" }, "links": { "files": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/transcriptions/537216f8-0620-4a10-ae2d-00bdb423b36f/files" }, "properties": { "diarizationEnabled": false, "wordLevelTimestampsEnabled": false, "channels": [ 0, 1 ], "punctuationMode": "DictatedAndAutomatic", "profanityFilterMode": "Masked" }, "lastActionDateTime": "2021-11-19T14:09:51Z", "status": "NotStarted", "createdDateTime": "2021-11-19T14:09:51Z", "locale": "ru-RU", "displayName": "transcriptiontest" } ``` **Note**: The Transcription ID is the GUID value (e.g., `aaaabbbb-0000-cccc-1111-dddd2222eeee`) found in the `self` element of the response body. ``` -------------------------------- ### Create and Navigate Project Directory Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-to-text_pivots=programming-language-csharp&tabs=linux This command creates a new directory named 'transcription-quickstart' and then navigates into it. This is a standard first step for setting up a new project. ```shell mkdir transcription-quickstart && cd transcription-quickstart ``` -------------------------------- ### Go SDK Setup Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically_source=recommendations&tabs=csharp Instructions for setting up the Go SDK, including creating a project, adding code samples, and setting credentials. ```APIDOC ## Go SDK Setup ### Description Instructions for setting up the Go SDK, including creating a project, adding code samples, and setting credentials. ### Method N/A (Setup Instructions) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Setup Steps 1. Create a new Go project. 2. Add the provided Go code sample. 3. Set your endpoint, key, and container URL values. 4. Save the file with a `.go` extension. 5. Open a command prompt on a computer with Go installed. 6. Build the file (e.g., `go build example-code.go`). 7. Run the file (e.g., `example-code`). ``` -------------------------------- ### Install Personalizer client library for .NET Source: https://learn.microsoft.com/en-us/azure/ai-services/personalizer/how-to-thick-client_source=recommendations This command installs version 2.0.0-beta.2 of the Azure.AI.Personalizer client library for .NET into the application. This library is required to interact with the Personalizer service. ```bash dotnet add package Azure.AI.Personalizer --version 2.0.0-beta.2 ``` -------------------------------- ### Get Dictionary Examples in Java Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/translator-text-apis This Java example outlines the setup for calling the Translator API's dictionary examples endpoint using OkHttp and Gson. It defines the endpoint, route, and necessary keys, and includes placeholders for the core request logic which would typically involve building the request body and sending it via OkHttpClient. ```java import java.io.*; import java.net.*; import java.util.*; import com.google.gson.*; import com.squareup.okhttp.*; public class TranslatorText { private static String key = ""; public String endpoint = "https://api.cognitive.microsofttranslator.com"; public String route = "/dictionary/examples?api-version=3.0&from=en&to=es"; public String url = endpoint.concat(route); // location, also known as region. // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page. private static String location = ""; // Instantiates the OkHttpClient. OkHttpClient client = new OkHttpClient(); // Placeholder for the actual request execution logic public void getDictionaryExamples() throws IOException { // Example of how to build the request body (requires Gson) // Gson gson = new Gson(); // String requestBody = gson.toJson(new Object[]{new HashMap() {{ put("Text", "sunlight"); put("Translation", "luz solar"); }}}); // Request request = new Request.Builder() // .url(url) // .post(RequestBody.create(MediaType.parse("application/json"), requestBody)) // .addHeader("Ocp-Apim-Subscription-Key", key) // .addHeader("Ocp-Apim-Subscription-Region", location) // .build(); // Response response = client.newCall(request).execute(); // String result = response.body().string(); // System.out.println(result); } public static void main(String[] args) { TranslatorText translator = new TranslatorText(); try { translator.getDictionaryExamples(); } catch (IOException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Initialize project folder and npm package Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-stt-diarization_source=recommendations Creates a new project directory named 'transcription-quickstart' and initializes an npm package within it. This is the first step in setting up the project. ```bash mkdir transcription-quickstart && cd transcription-quickstart npm init -y ``` -------------------------------- ### Main Application Entry Point (Java) Source: https://learn.microsoft.com/en-us/azure/ai-services/qnamaker/quickstarts/quickstart-sdk The main method to run the Quickstart application, orchestrating the creation, update, publishing, downloading, querying, and deletion of a knowledge base. It includes basic exception handling. ```Java public static void main(String[] args) { try { Quickstart quickstart = new Quickstart(); String kb_id = quickstart.create_kb(); // quickstart.list_kbs(); quickstart.update_kb(kb_id); quickstart.publish_kb(kb_id); quickstart.download_kb(kb_id); quickstart.query_kb(kb_id); quickstart.delete_kb(kb_id); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } ``` -------------------------------- ### Get Dictionary Examples in C# Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/text-translation/how-to/use-rest-api Retrieves dictionary examples by sending a POST request to the '/dictionary/examples' endpoint. Requires the Translator API key, resource location, source text, and target translation. Outputs the results as a JSON string. Ensure Newtonsoft.Json is installed via NuGet. ```csharp using System; using Newtonsoft.Json; // Install Newtonsoft.Json with NuGet using System.Net.Http; using System.Text; using System.Threading.Tasks; class Program { private static readonly string key = ""; private static readonly string endpoint = "https://api.cognitive.microsofttranslator.com"; // location, also known as region. // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page. private static readonly string location = ""; static async Task Main(string[] args) { // See examples of terms in context string route = "/dictionary/examples?api-version=3.0&from=en&to=es"; object[] body = new object[] { new { Text = "sunlight", Translation = "luz solar" } } ; var requestBody = JsonConvert.SerializeObject(body); using (var client = new HttpClient()) using (var request = new HttpRequestMessage()) { // Build the request. request.Method = HttpMethod.Post; request.RequestUri = new Uri(endpoint + route); request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json"); request.Headers.Add("Ocp-Apim-Subscription-Key", key); // location required if you're using a multi-service or regional (not global) resource. request.Headers.Add("Ocp-Apim-Subscription-Region", location); // Send the request and get response. HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false); // Read response as a string. string result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); } } } ``` -------------------------------- ### Create Gradle Project and Initialize Source: https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/quickstarts-sdk/image-analysis-client-library_pivots=programming-language-csharp&source=recommendations&tabs=linux%2Cvisual-studio Commands to create a new directory for the application and initialize a basic Gradle project with Kotlin DSL. This sets up the foundational build files for the Java application. ```console mkdir myapp && cd myapp gradle init --type basic ``` -------------------------------- ### Project Setup: Install Azure SDK for JavaScript Source: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-blocklist_tabs=visual-studio%2Clinux This snippet details the command to install the necessary Azure SDK package for Content Safety in a Node.js project. It uses npm to install the `@azure-rest/ai-content-safety` package and configures the project to use ES modules. Dependencies: Node.js, npm. ```bash npm install @azure-rest/ai-content-safety npm pkg set type=module ``` -------------------------------- ### Console command to create a new directory and navigate Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/quickstarts/get-started-sdks-rest-api_view=doc-intel-4.0 This command creates a new directory for your application and then navigates into it. It's a common setup step for new projects. This example uses a combination of 'mkdir' and 'cd' commands. ```bash mkdir doc-intel-app && doc-intel-app ``` ```powershell mkdir doc-intel-app; cd doc-intel-app ``` -------------------------------- ### Get Dictionary Examples in Java Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/text-translation/how-to/use-rest-api_tabs=csharp This Java code snippet outlines the setup for calling the Azure AI Services Dictionary Examples API using OkHttp and Gson. It defines the endpoint, route, and necessary keys and locations. The full implementation for sending the request and handling the response would follow. ```java import java.io.*; import java.net.*; import java.util.*; import com.google.gson.*; import com.squareup.okhttp.*; public class TranslatorText { private static String key = ""; public String endpoint = "https://api.cognitive.microsofttranslator.com"; public String route = "/dictionary/examples?api-version=3.0&from=en&to=es"; public String url = endpoint.concat(route); private static String location = ""; // Azure region OkHttpClient client = new OkHttpClient(); // ... (rest of the implementation for request and response handling would go here) } ``` -------------------------------- ### Create Project Directory and Navigate Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-translation_source=recommendations This shell command creates a new directory named `translation-quickstart` and then changes the current directory to the newly created folder. This is a common setup step for new projects. ```shell mkdir translation-quickstart && cd translation-quickstart ``` -------------------------------- ### Go Project Setup for Azure AI Services Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically_source=recommendations&tabs=csharp Instructions for creating a new Go project, adding the Go code sample, setting endpoint and key values, saving the file with a .go extension, building, and running the executable. ```go package main import ( "fmt" "log" "os" ) func main() { endpoint := os.Getenv("AZURE_AI_ENDPOINT") key := os.Getenv("AZURE_AI_KEY") containerUrl := "YOUR_CONTAINER_URL" if endpoint == "" || key == "" { log.Fatal("Please set AZURE_AI_ENDPOINT and AZURE_AI_KEY environment variables.") } fmt.Println("Go Azure AI Services setup initiated.") // Replace with your specific Azure AI Service logic } ``` -------------------------------- ### Get Dictionary Examples using Go Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/text-translation/how-to/use-rest-api_source=recommendations&tabs=csharp This Go code snippet shows how to use the dictionary examples API. It constructs an HTTP POST request with the necessary headers and JSON body, then sends it using Go's http package. The JSON response is decoded and printed. ```go package main import ( "bytes" "encoding/json" "fmt" "log" "net/http" "net/url" ) func main() { key := "" // location, also known as region. // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page. location := "" endpoint := "https://api.cognitive.microsofttranslator.com/" uri := endpoint + "/dictionary/examples?api-version=3.0" // Build the request URL. See: https://go.dev/pkg/net/url/#example_URL_Parse u, _ := url.Parse(uri) q := u.Query() q.Add("from", "en") q.Add("to", "es") u.RawQuery = q.Encode() // Create an anonymous struct for your request body and encode it to JSON body := []struct { Text string Translation string }{ { Text: "sunlight", Translation: "luz solar", }, } b, _ := json.Marshal(body) // Build the HTTP POST request req, err := http.NewRequest("POST", u.String(), bytes.NewBuffer(b)) if err != nil { log.Fatal(err) } // Add required headers to the request req.Header.Add("Ocp-Apim-Subscription-Key", key) // location required if you're using a multi-service or regional (not global) resource. req.Header.Add("Ocp-Apim-Subscription-Region", location) req.Header.Add("Content-Type", "application/json") // Call the Translator Text API res, err := http.DefaultClient.Do(req) if err != nil { log.Fatal(err) } // Decode the JSON response var result interface{} if err := json.NewDecoder(res.Body).Decode(&result); err != nil { log.Fatal(err) } // Format and print the response to terminal prettyJSON, _ := json.MarshalIndent(result, "", " ") fmt.Printf("%s\n", prettyJSON) } ``` -------------------------------- ### C# SDK Setup Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically_source=recommendations&tabs=csharp Instructions for setting up the C# SDK, including creating a project, replacing the code sample, and setting credentials. ```APIDOC ## C# SDK Setup ### Description Instructions for setting up the C# SDK, including creating a project, replacing the code sample, and setting credentials. ### Method N/A (Setup Instructions) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Setup Steps 1. Create a new project. 2. Replace `Program.cs` with the C# code sample. 3. Set your endpoint, key, and container URL values in `Program.cs`. 4. Add `Newtonsoft.Json` package using .NET CLI for processing JSON data. 5. Run the program from the project directory. ``` -------------------------------- ### Document Intelligence Layout Model - Get Started Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/layout_preserve-view=tru&view=doc-intel-3.0 This section provides an overview of how to get started with the Document Intelligence layout model, including necessary resources and development options. ```APIDOC ## Get started with the layout model See how data, including text, tables, table headers, selection marks, and structure information, is extracted from documents by using Document Intelligence. ### Resources: * An Azure subscription. * A Document Intelligence instance in the Azure portal. ### Development Options: * REST API * Client libraries (C#, Python, Java, JavaScript) * Document Intelligence Studio ``` -------------------------------- ### Layout Model - Get Started Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/layout_source=recommendations&tabs=rest%2Csample-code&view=doc-intel-4.0 This section provides an overview of how to get started with the Document Intelligence layout model, including required resources and development options. ```APIDOC ## Overview The Document Intelligence layout model extracts structural elements from documents. You can use the REST API, client libraries, or Document Intelligence Studio to interact with this model. ### Resources Required * An Azure subscription. * A Document Intelligence instance in the Azure portal. ### Development Options * REST API * Client libraries (C#, Python, Java, JavaScript) * Document Intelligence Studio ``` -------------------------------- ### Initialize a basic Gradle project Source: https://learn.microsoft.com/en-us/azure/ai-services/anomaly-detector/quickstarts/client-libraries-multivariate_pivots=programming-language-java&tabs=command-line This command initializes a new Gradle project with basic build files. It prompts the user to select a DSL, and Kotlin is recommended for this quickstart. ```bash gradle init --type basic ``` -------------------------------- ### Java SDK Setup Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically_source=recommendations&tabs=csharp Instructions for setting up the Java SDK using Gradle, including project initialization, dependency management, and running the sample. ```APIDOC ## Java SDK Setup ### Description Instructions for setting up the Java SDK using Gradle, including project initialization, dependency management, and running the sample. ### Method N/A (Setup Instructions) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Setup Steps 1. Create a working directory for your project (e.g., `mkdir sample-project`). 2. In your project directory, create the subdirectory structure: `src/main/java/` (`mkdir -p src/main/java/`). 3. Initialize your project with Gradle: `gradle init --type basic`. 4. When prompted to choose a **DSL**, select **Kotlin**. 5. Update the `build.gradle.kts` file, ensuring `mainClassName` is set correctly. ```kotlin plugins { java application } application { mainClassName = "{NAME OF YOUR CLASS}" } repositories { mavenCentral() } dependencies { compile("com.squareup.okhttp:okhttp:2.5.0") } ``` 6. Create a Java file in the `src/main/java/` directory and paste the sample code, including your key and endpoint. 7. Build and run the sample from the root directory: `gradle build` and `gradle run`. ``` -------------------------------- ### Python SDK Setup Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically_source=recommendations&tabs=csharp Instructions for setting up the Python SDK, including creating a project, pasting code samples, and setting credentials. ```APIDOC ## Python SDK Setup ### Description Instructions for setting up the Python SDK, including creating a project, pasting code samples, and setting credentials. ### Method N/A (Setup Instructions) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Setup Steps 1. Create a new project. 2. Copy and paste the code from one of the samples into your project. 3. Set your endpoint, key, and container URL values. 4. Run the program. For example: `python translate.py`. ``` -------------------------------- ### Browser Samples No Longer Require Separate JavaScript Library Download Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/releasenotes_source=recommendations Simplifies the usage of browser samples by eliminating the need for separate JavaScript library file downloads. This makes it easier for developers to get started with Speech SDK examples in a web environment. ```javascript // Conceptual update to browser samples. // The examples now likely include necessary SDK code directly or use a CDN. console.log('Browser samples updated for easier integration.'); ``` -------------------------------- ### Transliterate Text Java Example Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/text-translation/how-to/use-rest-api_source=recommendations This Java code snippet outlines the setup for transliterating text using the Translator API. It defines the API endpoint, route, and keys. The provided code is a starting point and would require further implementation to send the request and process the response. ```java import java.io.IOException; import com.google.gson.*; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; public class TranslatorText { private static String key = ""; public String endpoint = "https://api.cognitive.microsofttranslator.com"; public String route = "/transliterate?api-version=3.0&language=th&fromScript=thai&toScript=latn"; public String url = endpoint.concat(route); // location, also known as region. ``` -------------------------------- ### Get Analyze Document Result PDF (HTTP Example) Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/read_preserve-view=tru&view=doc-intel-3.1 An example HTTP GET request to retrieve the PDF output of a document analysis operation. This demonstrates the structure of the request and the expected response. ```http GET https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-invoice/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034/pdf?api-version=2024-11-30 Status code: 200 Content-Type: application/pdf "{pdfBinary}" ``` -------------------------------- ### Create .NET Console Project Source: https://learn.microsoft.com/en-us/azure/ai-services/agents/quickstart Initializes a new .NET Console project. This is the first step in setting up the development environment. ```bash dotnet new console ``` -------------------------------- ### Get Started with Document Intelligence Layout Model Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/layout_preserve-view=true&tabs=rest%2Csample-code&view=doc-intel-4.0 This section provides an overview of how to get started with the Document Intelligence layout model, including necessary resources and development options. ```APIDOC ## Overview This API allows for the extraction of structural elements from documents using the Document Intelligence layout model. It supports various document formats and provides detailed information about pages, paragraphs, text, and more. ### Resources Required * An Azure subscription. * A Document Intelligence instance in the Azure portal. ### Development Options * REST API * Client libraries (C#, Python, Java, JavaScript) * Document Intelligence Studio ``` -------------------------------- ### Create Directory and Navigate Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/how-to-guides/use-sdk-rest-api_pivots=programming-language-csharp&source=recommendations&tabs=linux&view=doc-intel-4.0 Creates a new directory for your application and changes the current directory to it. This is a common first step in setting up a new project. ```bash mkdir doc-intelligence-app cd doc-intelligence-app ``` -------------------------------- ### Install the Azure AI Personalizer client library for .NET Source: https://learn.microsoft.com/en-us/azure/ai-services/personalizer/how-to-thick-client This command adds the Personalizer client library (version 2.0.0-beta.2) to your .NET Core project. This library is required to interact with the Azure AI Personalizer service. ```bash dotnet add package Azure.AI.Personalizer --version 2.0.0-beta.2 ``` -------------------------------- ### Install Computer Vision and async npm packages Source: https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/quickstarts-sdk/image-analysis-client-library_source=recommendations Installs the '@azure/cognitiveservices-computervision' and 'async' npm packages required for the Computer Vision quickstart. ```bash npm install @azure/cognitiveservices-computervision npm install async ``` -------------------------------- ### Initialize Node.js App and Install Dependencies Source: https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/quickstarts-sdk/client-library_view=doc-intel-3.0 Commands to create a new Node.js project directory, initialize npm, and install necessary Azure AI Vision and utility packages. ```bash mkdir myapp cd myapp npm init npm install ms-rest-azure npm install @azure/cognitiveservices-computervision npm install async ``` -------------------------------- ### Create Project Directory and Initialize npm Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-text-to-speech_pivots=programming-language-go&tabs=linux These commands are used to create a new project directory for the synthesis quickstart and initialize a Node.js project by creating a package.json file. This sets up the basic structure for a JavaScript project using npm. ```shell mkdir synthesis-quickstart && cd synthesis-quickstart ``` ```shell npm init -y ``` -------------------------------- ### Authenticate Personalizer Client with Azure Key Source: https://learn.microsoft.com/en-us/azure/ai-services/personalizer/how-to-thick-client Demonstrates how to authenticate the Personalizer client using an Azure Key Credential. It requires the service endpoint and resource key, which should be kept secure and not publicly exposed. This setup is crucial for establishing a connection to the Personalizer service. ```csharp private const string ServiceEndpoint = "https://REPLACE-WITH-YOUR-PERSONALIZER-RESOURCE-NAME.cognitiveservices.azure.com"; private const string ResourceKey = ""; static PersonalizerClient InitializePersonalizerClient(Uri url) { // Set the local inference flag to true when initializing the client. return new PersonalizerClient(url, new AzureKeyCredential(ResourceKey), new PersonalizerClientOptions(useLocalInference: true)); } ``` -------------------------------- ### Create and Navigate to Application Directory (Bash/Zsh) Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/quickstarts/get-started-sdks-rest-api_pivots=programming-language-rest-api&preserve-view=true&view=doc-intel-4.0 These commands create a new directory for your application named 'doc-intel-app' and then navigate into that directory. This is a common first step for setting up a new project. ```bash mkdir doc-intel-app && cd doc-intel-app ``` -------------------------------- ### Get Dictionary Examples in Java Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/text-translation/how-to/use-rest-api_source=recommendations This Java code snippet provides the setup for calling the '/dictionary/examples' endpoint of the Translator Text API using OkHttp and Gson. It initializes the endpoint, route, and URL, and sets up the OkHttpClient. The code requires the Translator API key and resource location, and defines the structure for sending text and translation pairs. ```java import java.io.*; import java.net.*; import java.util.*; import com.google.gson.*; import com.squareup.okhttp.*; public class TranslatorText { private static String key = ""; public String endpoint = "https://api.cognitive.microsofttranslator.com"; public String route = "/dictionary/examples?api-version=3.0&from=en&to=es"; public String url = endpoint.concat(route); // location, also known as region. // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page. private static String location = ""; // Instantiates the OkHttpClient. OkHttpClient client = new OkHttpClient(); // TODO: Add method to construct request body and send request. } ``` -------------------------------- ### Create Project Directory and Navigate Source: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-image_pivots=programming-language-rest&tabs=visual-studio%2Clinux Creates a new directory for your project and changes the current directory to it. This is the initial step for setting up any new project. ```bash mkdir content-safety-image-analysis cd content-safety-image-analysis code . ``` -------------------------------- ### Provide Session ID using Speech to Text REST API Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-get-speech-session-id This example demonstrates how to include a generated Session ID (as a GUID without dashes) in the REST API request header using the 'X-ConnectionId' parameter. This is required for the speech to text REST API for short audio. ```http https://eastus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&X-ConnectionId=9f4ffa5113a846eba289aa98b28e766f ``` -------------------------------- ### Combined Entity Resolution Example Source: https://learn.microsoft.com/en-us/azure/ai-services/LUIS/luis-reference-prebuilt-geographyv2_source=recommendations&tabs=V3 An example showing the resolution of various entities, including geography and person names, with start and end index information. ```APIDOC ## GET /analyze ### Description Analyzes text to extract various entities including geography and person names, providing their location within the text. ### Method GET ### Endpoint /analyze ### Query Parameters - **text** (string) - Required - The text to analyze. - **verbose** (boolean) - Optional - If true, includes instance-level details. Defaults to false. ### Request Example `GET /analyze?text=Carol is visiting the sphinx in gizah egypt in africa before heading to texas.&verbose=true` ### Response #### Success Response (200) - **entities** (array) - A list of all extracted entities. - **entity** (string) - The extracted entity value. - **type** (string) - The type of the entity (e.g., builtin.geographyV2.poi, builtin.personName). - **startIndex** (integer) - The starting index of the entity in the text. - **endIndex** (integer) - The ending index of the entity in the text. #### Response Example ```json { "entities": [ { "entity": "the sphinx", "type": "builtin.geographyV2.poi", "startIndex": 18, "endIndex": 27 }, { "entity": "gizah", "type": "builtin.geographyV2.city", "startIndex": 32, "endIndex": 36 }, { "entity": "egypt", "type": "builtin.geographyV2.countryRegion", "startIndex": 38, "endIndex": 42 }, { "entity": "africa", "type": "builtin.geographyV2.continent", "startIndex": 47, "endIndex": 52 }, { "entity": "texas", "type": "builtin.geographyV2.state", "startIndex": 72, "endIndex": 76 }, { "entity": "carol", "type": "builtin.personName", "startIndex": 0, "endIndex": 4 } ] } ``` ``` -------------------------------- ### Create Speech SDK Directory for Go Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform Creates the Speech SDK directory specified by the SPEECHSDK_ROOT environment variable if it does not already exist. ```bash mkdir -p "$SPEECHSDK_ROOT" ``` -------------------------------- ### Include Speech SDK for JavaScript (Browser) Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform_pivots=programming-language-javascript&tabs=linux%2Cubuntu%2Cdotnetcli%2Cjre%2Cmaven%2Cnodejs%2Cmac%2Cpypi Integrate the Speech SDK for JavaScript into a web page using an HTML script tag. This example shows how to directly link to the SDK's bundled JavaScript file, making it available globally in the browser. ```html ``` -------------------------------- ### Create Project Directory (Shell) Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-text-to-speech_pivots=cpp&tabs=windows This command creates a new directory named 'synthesis-quickstart' and changes the current directory to it, preparing the environment for the speech synthesis quickstart. ```shell mkdir synthesis-quickstart && cd synthesis-quickstart ``` -------------------------------- ### Get All Dataset Indexes - Bash Examples Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/custom-translator/azure-ai-foundry/concepts/adaptive-custom-translation Fetches a list of all dataset indexes within a specified workspace. Requires the workspaceId as a query parameter. Examples provided for Windows and Linux/macOS. ```Bash curl -X GET "https://.cognitiveservices.azure.com/translator/customtranslator/api/texttranslator/v1.0/index?workspaceId=" ``` ```Bash curl -X GET "https://.cognitiveservices.azure.com/translator/customtranslator/api/texttranslator/v1.0/index?workspaceId=" ``` -------------------------------- ### Node.js SDK Setup Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically_source=recommendations&tabs=csharp Instructions for setting up the Node.js SDK, including creating a project, installing dependencies, and setting credentials. ```APIDOC ## Node.js SDK Setup ### Description Instructions for setting up the Node.js SDK, including creating a project, installing dependencies, and setting credentials. ### Method N/A (Setup Instructions) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Setup Steps 1. Create a new Node.js project. 2. Install the Axios library with `npm i axios`. 3. Copy/paste the JavaScript sample code into your project. 4. Set your endpoint, key, and container URL values. 5. Run the program. ``` -------------------------------- ### Set up Speech SDK environment on Linux Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform_pivots=programming-language-javascript&tabs=windows%2Cubuntu%2Cdotnetcli%2Cjre%2Cmaven%2Cnodejs%2Cmac%2Cpypi Configures the SPEECHSDK_ROOT environment variable on Linux to point to the directory where the Speech SDK files will be stored. This simplifies referencing SDK files in subsequent commands. ```bash export SPEECHSDK_ROOT="$HOME/speechsdk" mkdir -p "$SPEECHSDK_ROOT" ``` -------------------------------- ### Get Dataset Files Example Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/bring-your-own-storage-speech-resource-speech-to-text_source=recommendations Example of a request URL to retrieve dataset files from a BYOS-enabled Speech resource, using the `sasValidityInSeconds` parameter set to 0 for maximum security. ```APIDOC ## GET /speechtotext/v3.1/datasets/{datasetId}/files ### Description Retrieves a list of files associated with a specific dataset. When using a BYOS-enabled Speech resource, this request interacts with the BYOS-associated Storage account Blob storage. ### Method GET ### Endpoint `/speechtotext/v3.1/datasets/{datasetId}/files` ### Parameters #### Query Parameters - **sasValidityInSeconds** (integer) - Optional - Specifies the validity period in seconds for the generated SAS token. Setting to `0` ensures that URLs returned do not contain SAS tokens, requiring Microsoft Entra identity for access. ### Request Example ``` https://eastus.api.cognitive.microsoft.com/speechtotext/v3.1/datasets/bbbbcccc-1111-dddd-2222-eeee3333ffff/files?sasValidityInSeconds=0 ``` ### Response #### Success Response (200) - **links** (object) - Contains links to the data files. - **contentUrl** (string) - The direct URL to the data file in the BYOS-associated Storage Account. #### Response Example ```json { "links": { "contentUrl": "https://.blob.core.windows.net/customspeech-artifacts/AcousticData/8427b92a-cb50-4cda-bf04-964ea1b1781b/4a61ddac-5b1c-4c21-b87d-22001b0f18ab.zip" } } ``` ``` -------------------------------- ### Combined Entity Resolution Example Source: https://learn.microsoft.com/en-us/azure/ai-services/LUIS/luis-reference-prebuilt-geographyv2 This example demonstrates a consolidated response that includes both geographical entities and other recognized entities like person names, along with their start and end indices. ```APIDOC ## GET /recognize/entities ### Description Retrieves a comprehensive list of all recognized entities from the provided text, including geographical and personal entities, with their positional information. ### Method GET ### Endpoint /recognize/entities ### Query Parameters - **text** (string) - Required - The input text to analyze. ### Request Example ``` GET /recognize/entities?text=Carol%20is%20visiting%20the%20sphinx%20in%20gizah%20egypt%20in%20africa%20before%20heading%20to%20texas. ``` ### Response #### Success Response (200) - **entities** (array) - An array containing all recognized entities. - **entity** (string) - The recognized entity text. - **type** (string) - The type of the entity (e.g., builtin.geographyV2.poi, builtin.personName). - **startIndex** (integer) - The starting character index of the entity in the input text. - **endIndex** (integer) - The ending character index of the entity in the input text. #### Response Example ```json { "entities": [ { "entity": "the sphinx", "type": "builtin.geographyV2.poi", "startIndex": 18, "endIndex": 27 }, { "entity": "gizah", "type": "builtin.geographyV2.city", "startIndex": 32, "endIndex": 36 }, { "entity": "egypt", "type": "builtin.geographyV2.countryRegion", "startIndex": 38, "endIndex": 42 }, { "entity": "africa", "type": "builtin.geographyV2.continent", "startIndex": 47, "endIndex": 52 }, { "entity": "texas", "type": "builtin.geographyV2.state", "startIndex": 72, "endIndex": 76 }, { "entity": "carol", "type": "builtin.personName", "startIndex": 0, "endIndex": 4 } ] } ``` ``` -------------------------------- ### Download and Extract Speech SDK for Go Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform Downloads the Speech SDK for Linux binaries as a .tar.gz archive and extracts its contents into the directory specified by SPEECHSDK_ROOT. ```bash wget -O SpeechSDK-Linux.tar.gz https://aka.ms/csspeech/linuxbinary tar --strip 1 -xzf SpeechSDK-Linux.tar.gz -C "$SPEECHSDK_ROOT" ``` -------------------------------- ### Get Dictionary Examples in C# Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/translator-text-apis This C# code snippet demonstrates how to call the Translator API's dictionary examples endpoint. It requires the Newtonsoft.Json library and uses HttpClient to send a POST request with the text and its translation. The response contains example sentences. ```csharp using System; using Newtonsoft.Json; // Install Newtonsoft.Json with NuGet using System.Net.Http; using System.Text; using System.Threading.Tasks; class Program { private static readonly string key = ""; private static readonly string endpoint = "https://api.cognitive.microsofttranslator.com"; // location, also known as region. // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page. private static readonly string location = ""; static async Task Main(string[] args) { // See examples of terms in context string route = "/dictionary/examples?api-version=3.0&from=en&to=es"; object[] body = new object[] { new { Text = "sunlight", Translation = "luz solar" } } ; var requestBody = JsonConvert.SerializeObject(body); using (var client = new HttpClient()) using (var request = new HttpRequestMessage()) { // Build the request. request.Method = HttpMethod.Post; request.RequestUri = new Uri(endpoint + route); request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json"); request.Headers.Add("Ocp-Apim-Subscription-Key", key); // location required if you're using a multi-service or regional (not global) resource. request.Headers.Add("Ocp-Apim-Subscription-Region", location); // Send the request and get response. HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false); // Read response as a string. string result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); } } } ``` -------------------------------- ### Create and Build a .NET Console Application Source: https://learn.microsoft.com/en-us/azure/ai-services/language-service/question-answering/quickstart/sdk_source=recommendations Commands to create a new .NET console application named 'question-answering-quickstart' and then build it. This process sets up the basic C# project structure required for the Azure AI Language Question Answering quickstart. The build command verifies the project's integrity. ```bash dotnet new console -n question-answering-quickstart ``` ```bash dotnet build ``` -------------------------------- ### Install Speech SDK Dependencies on SUSE/OpenSUSE Source: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform_pivots=programming-language-cpp Installs essential build tools and libraries required for the Speech SDK on SUSE and OpenSUSE Linux distributions. This includes alsa-lib, ca-certificates, openssl, and wget. ```bash sudo tdnf update sudo tdnf install alsa-lib ca-certificates openssl wget ``` -------------------------------- ### Console Commands for Project Setup Source: https://learn.microsoft.com/en-us/azure/ai-services/translator/text-translation/quickstart/rest-api_tabs=python Basic console commands for creating directories and navigating within a file system. 'mkdir' creates new directories, and 'cd' changes the current directory. These are fundamental for setting up project structures. ```bash mkdir translator-text-app && cd translator-text-app ``` ```bash mkdir -p src/main/java ``` -------------------------------- ### Get Analyze Document Result PDF - HTTP Example Source: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/read_view=doc-intel-3.0 Provides a sample HTTP GET request to retrieve the analyzed document results directly as a PDF. This example demonstrates the structure of the request, including the endpoint, model ID, result ID, and API version, along with a successful 200 response indicating the PDF binary content. ```http GET https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-invoice/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034/pdf?api-version=2024-11-30 Status code: 200 JSON Copy "{pdfBinary}" ```