# Speech To Text API

## Bước 1: Đăng ký webhook url để nhận kết quả ASR

<mark style="color:green;">`POST`</mark> [`https://public-v1-stg.omicrm.com/api/ai/register_webhook_ai`](https://public-v1-stg.omicrm.com/api/ai/register_webhook_ai)

#### Headers

| Name                                     | Type   | Description                    |
| ---------------------------------------- | ------ | ------------------------------ |
| apiKey<mark style="color:red;">\*</mark> | String | Token xác thực để truy cập API |

#### Request Body

| Name                                  | Type   | Description            |
| ------------------------------------- | ------ | ---------------------- |
| url<mark style="color:red;">\*</mark> | String | Đường dẫn nhận dữ liệu |

{% tabs %}
{% tab title="200: OK Thành công" %}

{% endtab %}
{% endtabs %}

Kết Quả Từ Hook

<figure><img src="https://3454047468-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LukDt3aTxo8xMLonIwO%2Fuploads%2FVdu6UfWt0QWhLwQVOQyk%2Fimage.png?alt=media&#x26;token=d2d52877-1959-40d0-b138-0f8995954e0e" alt=""><figcaption></figcaption></figure>

| Name            | Type   | Description                                                                |
| --------------- | ------ | -------------------------------------------------------------------------- |
| from            | String | thời gian bắt đầu của đoạn text                                            |
| to              | String | thời gian kết thúc của đoạn text                                           |
| word\_alignment | String | mảng các từ được cắt theo thời gian                                        |
| text            | String | Chuỗi text được dịch từ speech                                             |
| tracking\_id    | String | ID truyền vào lúc gửi request phân tích qua để Mapping kết quả với request |

##

## Bước 2: Upload audio, kết quả ASR sẽ được trả về webhook url&#x20;

<mark style="color:green;">`POST`</mark> [`https://public-v1-stg.omicrm.com/api/ai/speech_to_text`](https://public-v1-stg.omicrm.com/api/ai/speech_to_text)

#### Headers

| Name                                     | Type   | Description                    |
| ---------------------------------------- | ------ | ------------------------------ |
| apiKey<mark style="color:red;">\*</mark> | String | Token xác thực để truy cập API |
| Content-Type                             | String | multipart/form-data;           |

#### Request Body ( Form Data)

| Name                                           | Type   | Description                                                            |
| ---------------------------------------------- | ------ | ---------------------------------------------------------------------- |
| file<mark style="color:red;">\*</mark>         | String | audio file (định dạng hỗ trợ  .wav/ . mp3/.m4a ) muốn chuyển sang text |
| tracking\_id<mark style="color:red;">\*</mark> | String | String chứa ID để khi nhận Webhook client biết kết quả của request nào |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}
