Skip to content

Instantly share code, notes, and snippets.

View csiebler's full-sized avatar
😊

Clemens Siebler csiebler

😊
View GitHub Profile
@csiebler
csiebler / test_read_latency.py
Created February 15, 2022 08:07
Test Read API performance using different methologies
View test_read_latency.py
import requests
import io
import logging
import threading
import time
import concurrent.futures
import Levenshtein as lev
from datetime import datetime
@csiebler
csiebler / invoke_speech.py
Created February 3, 2022 13:23
Short example on how to secure use Speech API on a frontend client
View invoke_speech.py
import azure.cognitiveservices.speech as speechsdk
import requests
# Access key to Speech API from Azure (this needs to be stored in the backend and show not get to the client)
access_key = 'xxxxxxxxxxxx'
region = "westeurope"
# This method should run in the backend, so that access_key is not needed in the client
def get_auth_token(access_key):
fetch_token_url = f"https://{region}.api.cognitive.microsoft.com/sts/v1.0/issueToken"
@csiebler
csiebler / lexicon.xml
Created December 15, 2021 16:39
A lexicon for most French words, that are used in German language
View lexicon.xml
<?xml version="1.0" encoding="utf-8"?>
<lexicon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd" version="1.0" alphabet="ipa" xml:lang="de-DE" xmlns="http://www.w3.org/2005/01/pronunciation-lexicon">
<lexeme>
<grapheme>passieren</grapheme>
<phoneme>paˈsiːʁən</phoneme>
</lexeme>
<lexeme>
<grapheme>Reserve</grapheme>
<phoneme>ʁeˈzɛʁvə</phoneme>
</lexeme>
@csiebler
csiebler / indexer.json
Created November 3, 2021 10:15
Run Skill on individual fields in nested array structure in Cognitive Search
View indexer.json
{
"@odata.type": "#Microsoft.Skills.Text.V3.SentimentSkill",
"name": "#4",
"description": null,
"context": "/document/transcript/*",
"defaultLanguageCode": "en",
"modelVersion": null,
"includeOpinionMining": false,
"inputs": [
{
@csiebler
csiebler / compare.py
Last active October 26, 2021 13:18
Comparison of sequential vs parallel Azure Read API processing time
View compare.py
import requests
import io
import time
n = 50
# Enter your resource details here
url = "https://xxxxxxx.cognitiveservices.azure.com/vision/v3.2/read/analyze?language=en&pages=1&readingOrder=natural"
key = "xxxxxxx"
@csiebler
csiebler / bing_search_example.py
Created October 20, 2021 08:40
Bing Search v7 example
View bing_search_example.py
import requests, json
key = "xxxxx" # Paste your API key here
url = "https://api.bing.microsoft.com/v7.0/search"
search_term = "Azure Cognitive Services"
headers = {"Ocp-Apim-Subscription-Key" : key}
params = {"q": search_term, "textDecorations": True, "textFormat": "HTML"}
@csiebler
csiebler / enforce_init_script.json
Created July 19, 2021 10:41
Enforce an init script for Azure Machine Learning Compute Instance via Azure Policy
View enforce_init_script.json
{
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.MachineLearningServices/workspaces/computes"
},
{
@csiebler
csiebler / package_model.py
Created May 3, 2021 13:55
Package existing model as container in Azure Machine Learning
View package_model.py
from azureml.core import Workspace, Model
from azureml.core.model import InferenceConfig
from azureml.core.environment import Environment
from azureml.core.conda_dependencies import CondaDependencies
ws = Workspace.from_config()
env = Environment("inference-env")
env.docker.enabled = True
# Replace with your conda enviroment file
@csiebler
csiebler / conda.yml
Created February 11, 2021 11:54
Conda Environment examples
View conda.yml
name: conda-env
dependencies:
- pip
- pip:
- --index-url https://xxxxx
- --extra-index-url https://xxxxxx
- xxxxxx==x.x.x
- -e git+https://github.com/xxxxxxxxxxx
- -e ./xxxxxxx
@csiebler
csiebler / private_repo.md
Last active February 9, 2022 13:48
Adding private Azure DevOps Artifact feeds to Azure Machine Learning
View private_repo.md

Steps:

  • Create private Feed in Azure DevOps
  • Create Personal Access Token (PAT) in Azure DevOps with Feed Read permission (details)
  • Navigate to the Azure DevOps Artifacts Feed page where you can see the details for the next steps (you'll need feed name, project name, organization name and later also package name): feed terminology
  • Create Build pipeline in Azure DevOps to create package and push to private feed:
trigger: