|

|  How to Integrate Microsoft Azure Cognitive Services with Atom

How to Integrate Microsoft Azure Cognitive Services with Atom

January 24, 2025

Discover how to seamlessly integrate Microsoft Azure Cognitive Services with Atom to enhance your application’s capabilities in our step-by-step guide.

How to Connect Microsoft Azure Cognitive Services to Atom: a Simple Guide

 

Preparation

 

  • Create a Microsoft Azure account if you don’t have one. Go to the Azure portal and set up a Cognitive Services resource. Note your API Key and Endpoint.
  •  

  • Ensure you have Node.js installed as it is required for Atom packages that interface with Azure Cognitive Services.

 

Install Atom and Required Packages

 

  • Download and install Atom if it isn’t already installed on your system.
  •  

  • Open Atom and go to "File" > "Settings" (or use Ctrl + ,), then navigate to the “Install” section. Type "atom-node" and install any package that provides node.js integration.

 

Set Up Environment

 

  • In Atom, open a new project directory where you want to integrate Azure Cognitive Services.
  •  

  • Open the terminal (you can use the built-in terminal in Atom by installing a package like “platformio-ide-terminal”).
  •  

  • Initialize a new Node.js project by running the following command. This will create a `package.json` file:

 

npm init -y

 

Install and Configure Azure SDK

 

  • Install the Azure Cognitive Services SDK for Node.js by running:

 

npm install @azure/cognitiveservices-textanalytics azure-cognitiveservices-keyvault

 

  • Open your project directory in Atom and create a new file, e.g., `app.js`, where you’ll write your integration code.
  •  

  • In `app.js`, set up the SDK with your API Key and Endpoint:

 

const msRest = require("@azure/ms-rest-js");
const CognitiveServicesCredentials = msRest.ApiKeyCredentials;
const TextAnalyticsClient = require("@azure/cognitiveservices-textanalytics");

const apiKey = 'YOUR_API_KEY';
const endpoint = 'YOUR_ENDPOINT';

const credentials = new CognitiveServicesCredentials(apiKey);
const textAnalyticsClient = new TextAnalyticsClient(credentials, endpoint);

 

Working with Azure Services

 

  • To perform text analysis, such as sentiment analysis, add the following function in `app.js`:

 

async function sentimentAnalysis(client, inputText) {
  const sentimentInput = {
    documents: [
      { id: "1", language: "en", text: inputText }
    ]
  };

  const result = await client.sentiment(sentimentInput);
  console.log(JSON.stringify(result.documents));
}

sentimentAnalysis(textAnalyticsClient, "I love programming with Atom and Azure!");

 

  • Use Atom's editor features to save your file.
  •  

  • Run your script from the terminal to ensure everything works as expected:

 

node app.js

 

Troubleshoot and Extend

 

  • If you encounter errors, ensure that your API credentials and endpoint are correctly specified.
  •  

  • Explore other Cognitive Services such as language understanding or vision by referring to the Azure SDK documentation for the necessary Node.js packages.
  •  

  • Utilize Atom with additional packages like “linter” to help detect errors in your code directly in the editor.

 

Secure Your Credentials

 

  • To ensure security, avoid hardcoding the API Key and Endpoint. Use environment variables or config files to manage sensitive data.
  •  

  • Create a `.env` file and use packages like `dotenv` to load environment variables into your Node.js application.

 

Omi Necklace

The #1 Open Source AI necklace: Experiment with how you capture and manage conversations.

Build and test with your own Omi.

How to Use Microsoft Azure Cognitive Services with Atom: Usecases

 

Efficient Document Translation and Text Analytics with Microsoft Azure Cognitive Services and Atom

 

  • Integrate Cognitive Services with Atom
  •  

  • Start by installing the Microsoft Azure Cognitive Services SDK for Python, which can be seamlessly integrated into the Atom editor via packages or a command line interface.
  •  

  • Enable the Language Understanding service from Cognitive Services to recognize and analyze natural language documents directly within Atom.
  •  

  • Atom can be configured to auto-trigger language processing upon opening a text document, facilitating seamless document analysis.
  •  

  • Automate Language Translation
  •  

  • Leverage the Translator Text API from Azure Cognitive Services to perform real-time document translation within Atom.
  •  

  • Enable scripts or packages in Atom to automatically detect document language and translate it into a target language, enhancing cross-language collaboration.
  •  

  • Extract Key Phrases and Sentiment Analysis
  •  

  • Utilize Text Analytics API to automatically extract key phrases from documents opened in Atom, enabling quicker insights into document content.
  •  

  • Employ sentiment analysis to determine the tone of documents. This can help users prioritize responses to customer feedback by understanding sentiment context.
  •  

  • Advanced Text Summarization
  •  

  • Implement the use of Text Analytics for summarization directly within Atom to provide users with condensed versions of lengthy documents.
  •  

  • This functionality aids in reducing information overload by presenting concise and pertinent information quickly and accurately to the user.

 

from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential

# Fill in your key and endpoint here
key = "YOUR_COGNITIVE_SERVICES_KEY"
endpoint = "https://<your-resource-name>.cognitiveservices.azure.com/"

text_analytics_client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key))

# Text to be analyzed
document = "The AI revolution is changing technology."

response = text_analytics_client.extract_key_phrases(documents=[document])[0]
print("Key Phrases:", response.key_phrases)

 

This use case demonstrates how Atom can be a development powerhouse when used alongside Microsoft Azure Cognitive Services by drastically increasing productivity in language understanding, translation, and text analytics directly within the editor.

 

Real-Time Image Processing and Code Annotation using Microsoft Azure Cognitive Services and Atom

 

  • Setup Azure Cognitive Services in Atom
  •  

  • Install the Azure SDK for Python and configure it in Atom to facilitate seamless integration with Azure Cognitive Services.
  •  

  • Utilize Azure Computer Vision API to access features such as image tagging and OCR to handle image files within Atom.
  •  

  • Configure Atom scripts or packages to auto-invoke image processing with Azure services when images are opened or modified in the editor.
  •  

  • Automate Image Tagging and Annotation
  •  

  • Leverage the Computer Vision API for automatic tagging and generation of descriptive metadata for images opened in Atom.
  •  

  • Automate the insertion of image metadata as code annotations, which can improve clarity and documentation quality in projects involving images.
  •  

  • Enable Optical Character Recognition (OCR)
  •  

  • Use OCR capabilities from Azure to extract text from images directly in Atom, allowing for easy editing and data extraction.
  •  

  • These extracted texts can be directly placed into your codebase or documentation, increasing productivity and reducing manual errors.
  •  

  • Advanced Integrated Code Suggestions
  •  

  • Integrate code suggestion plugins in Atom that utilize processed image data to offer intelligent code completion and guidance.
  •  

  • Such integration ensures that image data is efficiently utilized in decision-making processes directly within your development environment.

 

from azure.ai.vision import VisionClient
from azure.core.credentials import AzureKeyCredential

# Replace with your credentials
key = "YOUR_COGNITIVE_SERVICES_KEY"
endpoint = "https://<your-resource-name>.cognitiveservices.azure.com/"

vision_client = VisionClient(endpoint=endpoint, credential=AzureKeyCredential(key))

# Path to the local image file
image_file_path = "path/to/your/image.jpg"

with open(image_file_path, "rb") as image_stream:
    response = vision_client.describe(image_stream)
    print("Description:", response.description.captions[0].text)

 

This use case exemplifies how Microsoft Azure Cognitive Services, when combined with Atom, can efficiently automate image-tagging and OCR processes, thereby enhancing coding and documentation workflows directly within the development environment.

Omi App

Fully Open-Source AI wearable app: build and use reminders, meeting summaries, task suggestions and more. All in one simple app.

Github →

OMI NECKLACE + OMI APP
First & only open-source AI wearable platform

a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded