# Azure - AI Speech

> Execute production-grade Automatic Speech Recognition (ASR) on audio streams using Microsoft Azure AI Speech.

Source: https://docs.sommatic.ai/en/nodes/integrations.microsoft.azure.speech/

- Slug: `integrations.microsoft.azure.speech`
- Family: Integrations
- Version: 1.0.0
- Status: Available
- Execution: async

Execute production-grade Automatic Speech Recognition (ASR) on audio streams using Microsoft Azure AI Speech.

Authenticates with your own Azure resource via `connection_id` (api-key credential with `region` metadata); execution costs are billed by Azure to your subscription.

**Operations:**
- **Continuous recognition:** Streams audio of any length through the long-running recognition endpoint — meetings, calls, long-form media.
- **Speaker diarization:** When `diarization.enabled` is true, uses the ConversationTranscriber to tag each segment with a speaker identifier and return a structured `speakers` array.
- **Custom vocabulary bias:** Phrase list injected into the recognizer to improve accuracy on names, acronyms, product terms, and jargon.
- **Locale selection:** 100+ BCP-47 locales (`es-CO`, `en-US`, `pt-BR`, `fr-FR`, ...); auto-detection is available in the underlying API when no locale is supplied.
- **Segment timestamps:** Per-segment start/end timestamps returned in `segments` for subtitles, chaptering, and evidence anchoring.

## Configuration

- `connection_id` (string, required): Connection credential with region + api-key for your Azure AI Speech resource.
- `language` (string, optional, accepts expressions): BCP-47 locale (e.g., es-CO, en-US, pt-BR, fr-FR). Leave empty for auto-detection.
- `diarization` (object, optional)
  - `enabled` (boolean, optional): Enable speaker diarization (ConversationTranscriber). Default: `false`.
- `custom_vocabulary` (array<string>, optional): Phrase list to bias the recognizer toward names, acronyms, or domain terminology.

Its configuration shows the shared execution settings, but this node does not apply retries (`retryOnFail`, `maxTries`) yet. `continueOnFail` is not applied by any node.

## Output ports

- `extracted` (default): Transcribed
- `empty`: No Speech
- `error`: Error

## Input contract

- `content_base64` (string, optional)
- `file_path` (string, optional)

## Output contract

- `text` (string, optional)
- `chars` (number, optional)
- `empty` (boolean, optional)
- `method` (string, optional)
- `metadata` (object, optional)
- `segments` (array, optional)
- `speakers` (array, optional)

## In expressions

What a later node can read from this node's output with `$("Azure - AI Speech").item.json.<path>` (write your node's label instead of `Azure - AI Speech`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `extracted`, from the output shown in Ports.

- `$("Azure - AI Speech").item.json.text` (string) = `"Good morning, I am calling about order 123."`
- `$("Azure - AI Speech").item.json.chars` (number) = `43`
- `$("Azure - AI Speech").item.json.empty` (boolean) = `false`
- `$("Azure - AI Speech").item.json.method` (string) = `"azure-speech-diarized"`
- `$("Azure - AI Speech").item.json.metadata` (object) = `{…}`
- `$("Azure - AI Speech").item.json.segments` (array) = `[…] (1)`
- `$("Azure - AI Speech").item.json.speakers` (array) = `[…] (1)`
- `$("Azure - AI Speech").item.json.metadata.language` (string) = `"en-US"` (Not suggested by the editor)
- `$("Azure - AI Speech").item.json.metadata.region` (string) = `"eastus"` (Not suggested by the editor)
- `$("Azure - AI Speech").item.json.metadata.diarization_enabled` (boolean) = `true` (Not suggested by the editor)
- `$("Azure - AI Speech").item.json.metadata.segments_count` (number) = `1` (Not suggested by the editor)
- `$("Azure - AI Speech").item.json.metadata.speakers_count` (number) = `1` (Not suggested by the editor)


## How it works

Transcribes an audio file with Azure AI Speech using your own resource, optionally with speaker diarization, and returns the text with timed segments. Routes to `empty` when no speech is recognized.

1. Resolves the node config. Reads `content_base64` or `file_path` from the config first and then from the incoming item; requires `connection_id` and one of them.
2. Resolves the credential on the server: the secret must contain `apiKey` (or `api_key`) and `region` is read from the credential config or the secret.
3. Runs a Python process. Base64 content is written to a temporary `audio.wav`; an existing `file_path` is used directly.
4. Recognizes continuously with `language` when set. With `diarization.enabled` it uses the conversation transcriber and tags each segment with `speaker`.
5. Builds `{ text, chars, empty, method, metadata, segments, speakers }` and chooses `empty` when the text is blank, otherwise `extracted`.

## In a workflow

### Node

```json
{
  "node_id": "node-transcribe-call",
  "label": "Transcribe call",
  "operator_slug": "integrations.microsoft.azure.speech",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "language": "en-US",
    "diarization": {
      "enabled": true
    }
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "text": "Good morning, I am calling about order 123.",
    "chars": 43,
    "empty": false,
    "method": "azure-speech-diarized",
    "metadata": {
      "language": "en-US",
      "region": "eastus",
      "diarization_enabled": true,
      "segments_count": 1,
      "speakers_count": 1
    },
    "segments": [
      {
        "start_ms": 420,
        "duration_ms": 2860,
        "speaker": "Guest-1",
        "text": "Good morning, I am calling about order 123."
      }
    ],
    "speakers": [
      {
        "id": "Guest-1",
        "segment_indexes": [
          0
        ]
      }
    ]
  },
  "port": "extracted"
}
```

## Output ports (behaviour in the code)

### `extracted`

Speech was recognized.

```json
{
  "text": "Good morning, I am calling about order 123.",
  "chars": 43,
  "empty": false,
  "method": "azure-speech-diarized",
  "metadata": {
    "language": "en-US",
    "region": "eastus",
    "diarization_enabled": true,
    "segments_count": 1,
    "speakers_count": 1
  },
  "segments": [
    {
      "start_ms": 420,
      "duration_ms": 2860,
      "speaker": "Guest-1",
      "text": "Good morning, I am calling about order 123."
    }
  ],
  "speakers": [
    {
      "id": "Guest-1",
      "segment_indexes": [
        0
      ]
    }
  ]
}
```

### `empty`

Recognition ended without text. A canceled session (for example an invalid key or an unsupported audio format) also ends here, because cancellation stops recognition without raising an error.

```json
{
  "text": "",
  "chars": 0,
  "empty": true,
  "method": "azure-speech",
  "metadata": {
    "language": "en-US",
    "region": "eastus",
    "diarization_enabled": false,
    "segments_count": 0,
    "speakers_count": 0
  },
  "segments": [],
  "speakers": []
}
```

### `error`

Validation, credential resolution or the Python process failed.

```json
{
  "error": "connection must provide region + apiKey"
}
```

## Behaviour in the code

- `language`: When empty, no recognition language is set and the Speech SDK default applies; the worker does not configure language auto-detection.
- `custom_vocabulary`: Not applied in this version: the phrase list is attached to a recognizer that is discarded before transcription starts.
- `execution`: Only `timeout_ms` is read (default 900000). The retry settings are not applied.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `connection_id is required.` | `error` | No credential configured. |
| `Either content_base64 or file_path is required.` | `error` | The incoming item carries neither field. |
| `connection must provide region + apiKey` | `error` | The credential secret is not an object with `apiKey`, or no `region` is stored. |
| `Python timed out after <ms>ms` | `error` | Transcription took longer than `execution.timeout_ms` (default 900000). |

## Notes and limits

- The audio is read as a WAV file. Convert other formats (MP3, OGG) to WAV before this node.
- `start_ms` and `duration_ms` are in milliseconds. `speakers` lists each speaker id with the indexes of its segments.
- The first run on a host installs the Python dependencies, which can take minutes. Azure usage is billed to your own resource.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "integrations.microsoft.azure.speech",
  "name": "Azure - AI Speech",
  "category": "integrations",
  "group": [
    {
      "key": "microsoft",
      "name": "Microsoft",
      "icon_url": "/icons/integrations/microsoft/microsoft.svg"
    },
    {
      "key": "foundry",
      "name": "Microsoft Foundry",
      "icon_url": "/icons/integrations/microsoft/foundry.webp"
    }
  ],
  "icon_url": "/icons/integrations/microsoft/microsoft.svg",
  "version": "1.0.0",
  "description": "Execute production-grade Automatic Speech Recognition (ASR) on audio streams using Microsoft Azure AI Speech.\n\n  Authenticates with your own Azure resource via `connection_id` (api-key credential with `region` metadata); execution costs are billed by Azure to your subscription.\n\n  **Operations:**\n  - **Continuous recognition:** Streams audio of any length through the long-running recognition endpoint — meetings, calls, long-form media.\n  - **Speaker diarization:** When `diarization.enabled` is true, uses the ConversationTranscriber to tag each segment with a speaker identifier and return a structured `speakers` array.\n  - **Custom vocabulary bias:** Phrase list injected into the recognizer to improve accuracy on names, acronyms, product terms, and jargon.\n  - **Locale selection:** 100+ BCP-47 locales (`es-CO`, `en-US`, `pt-BR`, `fr-FR`, ...); auto-detection is available in the underlying API when no locale is supplied.\n  - **Segment timestamps:** Per-segment start/end timestamps returned in `segments` for subtitles, chaptering, and evidence anchoring.",
  "capabilities": [
    "speech",
    "asr",
    "transcription",
    "diarization",
    "azure",
    "cloud"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "Azure AI Speech Credential",
        "description": "Connection credential with region + api-key for your Azure AI Speech resource.",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "api-key",
            "object"
          ],
          "providers": [
            "azure"
          ]
        }
      },
      "language": {
        "type": "string",
        "title": "Recognition Language",
        "description": "BCP-47 locale (e.g., es-CO, en-US, pt-BR, fr-FR). Leave empty for auto-detection.",
        "format": "expression"
      },
      "diarization": {
        "type": "object",
        "title": "Diarization",
        "properties": {
          "enabled": {
            "type": "boolean",
            "default": false,
            "description": "Enable speaker diarization (ConversationTranscriber)."
          }
        }
      },
      "custom_vocabulary": {
        "type": "array",
        "title": "Custom Vocabulary",
        "items": {
          "type": "string"
        },
        "description": "Phrase list to bias the recognizer toward names, acronyms, or domain terminology."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    },
    "required": [
      "connection_id"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "content_base64": {
        "type": "string"
      },
      "file_path": {
        "type": "string"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string"
      },
      "chars": {
        "type": "number"
      },
      "empty": {
        "type": "boolean"
      },
      "method": {
        "type": "string"
      },
      "metadata": {
        "type": "object"
      },
      "segments": {
        "type": "array"
      },
      "speakers": {
        "type": "array"
      }
    }
  },
  "ports": [
    {
      "port_id": "extracted",
      "label": "Transcribed",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "empty",
      "label": "No Speech",
      "is_default": false,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io",
    "cloud-io"
  ],
  "tags": [
    "azure",
    "speech",
    "asr",
    "diarization"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://sommatic.ai",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "connection_id": {
      "type": "string",
      "title": "Azure AI Speech Credential",
      "description": "Connection credential with region + api-key for your Azure AI Speech resource.",
      "ui_widget": "connection_picker",
      "ui_options": {
        "credential_types": [
          "api-key",
          "object"
        ],
        "providers": [
          "azure"
        ]
      }
    },
    "language": {
      "type": "string",
      "title": "Recognition Language",
      "description": "BCP-47 locale (e.g., es-CO, en-US, pt-BR, fr-FR). Leave empty for auto-detection.",
      "format": "expression"
    },
    "diarization": {
      "type": "object",
      "title": "Diarization",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": false,
          "description": "Enable speaker diarization (ConversationTranscriber)."
        }
      }
    },
    "custom_vocabulary": {
      "type": "array",
      "title": "Custom Vocabulary",
      "items": {
        "type": "string"
      },
      "description": "Phrase list to bias the recognizer toward names, acronyms, or domain terminology."
    },
    "execution": {
      "type": "object",
      "title": "Execution Settings",
      "properties": {
        "alwaysOutputData": {
          "type": "boolean",
          "title": "Always Output Data",
          "description": "Always output data, even on error (if configured).",
          "default": false
        },
        "retryOnFail": {
          "type": "boolean",
          "title": "Retry On Fail",
          "description": "Retry the execution if it fails.",
          "default": false
        },
        "maxTries": {
          "type": "integer",
          "title": "Max Retries",
          "description": "Number of retries.",
          "default": 3,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "waitBetweenTries": {
          "type": "integer",
          "title": "Wait Between Retries (ms)",
          "default": 1000,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "continueOnFail": {
          "type": "boolean",
          "title": "Continue On Fail",
          "description": "Do not crash workflow on error.",
          "default": false
        },
        "timeout_ms": {
          "type": "integer",
          "title": "Timeout (ms)",
          "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
          "default": 300000
        }
      }
    }
  },
  "required": [
    "connection_id"
  ]
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "content_base64": {
      "type": "string"
    },
    "file_path": {
      "type": "string"
    }
  }
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "text": {
      "type": "string"
    },
    "chars": {
      "type": "number"
    },
    "empty": {
      "type": "boolean"
    },
    "method": {
      "type": "string"
    },
    "metadata": {
      "type": "object"
    },
    "segments": {
      "type": "array"
    },
    "speakers": {
      "type": "array"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "extracted",
    "label": "Transcribed",
    "is_default": true,
    "supports_condition": true
  },
  {
    "port_id": "empty",
    "label": "No Speech",
    "is_default": false,
    "supports_condition": true
  },
  {
    "port_id": "error",
    "label": "Error",
    "is_default": false,
    "supports_condition": false
  }
]
```
