# AI Transcript

An AI Transcript is the text of an audio file you upload. It is the other half of [AI Speech](https://docs.starkinfra.com/api/v2/ai-speech.md): speech turns text into audio, transcript turns audio into text.

Transcription is synchronous. The call returns the finished transcript in `success` status with its `text` filled, or fails and produces nothing.

Pair it with an [AI Agent](https://docs.starkinfra.com/api/v2/ai-agent.md) to close the voice loop: transcribe what the caller said, post that text as a message, then synthesize the reply's `speech`.

### The AI Transcript object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the AI Transcript. |
| `text` | STRING | Text transcribed from the audio. |
| `status` | STRING | Current status of the transcript. Options: "processing", "success", "failed". |
| `errors` | LIST OF STRINGS | Reasons the transcription failed. Empty while the transcript is healthy. |
| `created` | STRING | Creation datetime. Example: "2022-01-01T00:00:00.000000+00:00". |
| `updated` | STRING | Last update datetime. Example: "2022-01-01T00:00:00.000000+00:00". |

### Create an AI Transcript

`POST /v2/ai-transcript`

Upload an audio file and get its text back. The format is detected from the audio's own header — MP3, WAV, OGG, FLAC and WebM are all accepted.

No voice is involved: transcription reads any speaker, not only the ones you cloned.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `audio` | REQUIRED | Base64-encoded audio to transcribe. Up to 10000000 characters. |

**Request**

```python
import base64
import starkinfra

with open("call.wav", "rb") as recording:
    audio = base64.b64encode(recording.read()).decode()

transcript = starkinfra.aitranscript.create(
    starkinfra.AiTranscript(
        audio=audio
    )
)

print(transcript)
```

**Response**

```python
AiTranscript(
    audio=None,
    created=2022-01-01 00:00:00,
    errors=[],
    id=9898989898989898,
    status=success,
    text=My order 1234 was supposed to arrive yesterday and it did not. What can I do?,
    updated=2022-01-01 00:00:02
)
```

### List AI Transcripts

`GET /v2/ai-transcript`

Get the transcripts in your workspace, newest first, in chunks of at most 100.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `cursor` | OPTIONAL | String used to get the next batch of results, returned by the previous call. |

**Request**

```python
import starkinfra

transcripts = starkinfra.aitranscript.query()

for transcript in transcripts:
    print(transcript)
```

**Response**

```python
AiTranscript(
    audio=None,
    created=2022-01-01 00:00:00,
    errors=[],
    id=9898989898989898,
    status=success,
    text=My order 1234 was supposed to arrive yesterday and it did not. What can I do?,
    updated=2022-01-01 00:00:02
)
```

## Available Languages

Code samples on this page are in Python. The same content is available with samples in:

- [Python](https://docs.starkinfra.com/api/v2/ai-transcript-python.md)
- [Node.js](https://docs.starkinfra.com/api/v2/ai-transcript-node.md)
- [PHP](https://docs.starkinfra.com/api/v2/ai-transcript-php.md)
- [Java](https://docs.starkinfra.com/api/v2/ai-transcript-java.md)
- [Ruby](https://docs.starkinfra.com/api/v2/ai-transcript-ruby.md)
- [Elixir](https://docs.starkinfra.com/api/v2/ai-transcript-elixir.md)
- [.NET](https://docs.starkinfra.com/api/v2/ai-transcript-dotnet.md)
- [Go](https://docs.starkinfra.com/api/v2/ai-transcript-go.md)
- [Clojure](https://docs.starkinfra.com/api/v2/ai-transcript-clojure.md)
- [cURL](https://docs.starkinfra.com/api/v2/ai-transcript-curl.md)
