Skip to content

Commit a4c24ac

Browse files
committed
video translation api refresh
1 parent 32e1fa6 commit a4c24ac

File tree

2 files changed

+72
-32
lines changed

2 files changed

+72
-32
lines changed

articles/ai-services/speech-service/includes/how-to/video-translation/rest.md

Lines changed: 72 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ To create a video translation, you need to construct an HTTP PUT request path an
6666
- Specify `subtitleMaxCharCountPerSegment`: The maximum number of characters allowed per subtitle segment. This is an optional parameter, and you can set it to 30 if you're unsure.
6767
- Specify `exportSubtitleInVideo`: A boolean value indicating whether to export subtitles in the video. This is an optional parameter, and you can set it to `true` if you want to include subtitles in the video.
6868
- Specify the `videoFileUrl`: The URL of the video file you want to translate. The video must be in .mp4 format, less than 500 MB, and shorter than 60 minutes. You can upload the video to Azure Blob Storage and use the Blob URL. For testing purposes, you can use the sample video file provided by Microsoft at [https://speechstudioprodpublicsa.blob.core.windows.net/ttsvoice/VideoTranslation/PublicDoc/SampleData/es-ES-TryOutOriginal.mp4](https://speechstudioprodpublicsa.blob.core.windows.net/ttsvoice/VideoTranslation/PublicDoc/SampleData/es-ES-TryOutOriginal.mp4).
69-
- Specify `Operation-Id`: The `Operation-Id` must be unique for each operation. The operation ID is valid until the translation is deleted. In the example, `My-Operation-Id-1` is used. Replace `My-Operation-Id-1` with an operation ID of your choice.
70-
- Specify `translationId`: The `translationId` must be unique. Replace `My-Translation-Id` with a translation ID of your choice.
71-
- Replace `YourSpeechResourceKey` with your Speech resource key and replace `YourSpeechResourceRegion` with your Speech resource region.
7269

73-
To create a translation, run the following command with the settings as previously described.
70+
For authentication and authorization, you need to include the following headers and path IDs in your request:
71+
- Set the `Operation-Id` header: The `Operation-Id` must be unique for each operation, such as creating each iteration. Replace `Your-Operation-Id` with a unique ID for this operation.
72+
- Replace `Your-Translation-Id` in the path. The `translationId` must be unique. Replace `Your-Translation-Id` with a translation ID of your choice. You use this ID to refer to the translation in subsequent API calls.
73+
- Replace `YourSpeechResourceKey` with your Speech resource key and replace `YourSpeechResourceRegion` with your Speech resource region.
7474

7575
```azurecli-interactive
76-
curl -v -X PUT -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" -H "Operation-Id: My-Operation-Id-1" -H "Content-Type: application/json" -d '{
76+
curl -v -X PUT -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" -H "Operation-Id: Your-Operation-Id-1" -H "Content-Type: application/json" -d '{
7777
"displayName": "My translation object",
7878
"description": "My translation object for video translation iterations",
7979
"input": {
@@ -85,7 +85,7 @@ curl -v -X PUT -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" -H "Operati
8585
"exportSubtitleInVideo": false,
8686
"videoFileUrl": "https://speechstudioprodpublicsa.blob.core.windows.net/ttsvoice/VideoTranslation/PublicDoc/SampleData/es-ES-TryOutOriginal.mp4"
8787
}
88-
}' "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/My-Translation-Id?api-version=2024-05-20-preview"
88+
}' "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id?api-version=2024-05-20-preview"
8989
```
9090

9191
> [!IMPORTANT]
@@ -105,7 +105,7 @@ You should receive a response body in the following format:
105105
},
106106
"status": "NotStarted",
107107
"lastActionDateTime": "2025-03-06T19:13:35.669Z",
108-
"id": "My-Translation-Id",
108+
"id": "Your-Translation-Id",
109109
"displayName": "My translation object",
110110
"description": "My translation object for video translation iterations",
111111
"createdDateTime": "2025-03-06T19:13:35.669Z"
@@ -118,26 +118,27 @@ You can use the operation ID that you specified and use the [Get operation by op
118118

119119
To start translating your video or update an iteration for an existing translation, you need to construct an HTTP PUT request path and body according to the following instructions:
120120

121-
- Specify `Operation-Id`: The `Operation-Id` must be unique for each operation, such as creating each iteration. Replace `My-Operation-Id` with a unique ID for this operation.
122-
- Specify `translationId`: If multiple iterations are performed under a single translation, the translation ID remains unchanged.
123-
- Specify `iterationId`: The `iterationId` must be unique for each operation. Replace `My-Iteration-Id` with an iteration ID of your choice.
124121
- Set the required input: Include details like `speakerCount`, `subtitleMaxCharCountPerSegment`,`exportSubtitleInVideo`, or `webvttFile`. No subtitles are embedded in the output video by default. When creating an iteration, if you already specified the optional parameters `speakerCount`, `subtitleMaxCharCountPerSegment`, and `exportSubtitleInVideo` during the creation of translation, you don’t need to specify them again. The values inherit from translation settings. Once these parameters are defined when creating an iteration, the new values override the original settings.
122+
- Optionally, you can specify a WebVTT file with subtitles for your original video. The `webvttFile` input parameter isn't required when creating the first iteration. However, [starting from the second iteration](#step-4-create-additional-iterations-optional), you must specify the `webvttFile` parameter in the iteration process.
123+
124+
For authentication and authorization, you need to include the following headers and path IDs in your request:
125+
- Set the `Operation-Id` header: The `Operation-Id` must be unique for each operation, such as creating each iteration. Replace `Your-Operation-Id` with a unique ID for this operation.
126+
- Replace `Your-Translation-Id` in the path. Use the same translation ID that you specified when you [created the translation](#step-1-create-a-translation). The translation ID remains unchanged.
127+
- Specify a new `iterationId` in the path. The iteration ID must be unique for each operation. Replace `Your-Iteration-Id-1` with an iteration ID of your choice.
125128
- Replace `YourSpeechResourceKey` with your Speech resource key and replace `YourSpeechResourceRegion` with your Speech resource region.
126129

127130
```azurecli-interactive
128131
curl -v -X PUT -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" \
129-
-H "Operation-Id: My-Operation-Id" \
132+
-H "Operation-Id: Your-Operation-Id" \
130133
-H "Content-Type: application/json" \
131134
-d '{
132135
"input": {
133136
"subtitleMaxCharCountPerSegment": 30,
134137
"exportSubtitleInVideo": true
135138
}
136-
}' "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/My-Translation-Id/iterations/My-Iteration-Id?api-version=2024-05-20-preview"
139+
}' "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id/iterations/Your-Iteration-Id-1?api-version=2024-05-20-preview"
137140
```
138141

139-
140-
141142
You should receive a response body in the following format:
142143

143144
```json
@@ -148,7 +149,7 @@ You should receive a response body in the following format:
148149
},
149150
"status": "NotStarted",
150151
"lastActionDateTime": "2025-03-06T19:15:38.722Z",
151-
"id": "My-Iteration-Id",
152+
"id": "Your-Iteration-Id",
152153
"createdDateTime": "2025-03-06T19:15:38.722Z"
153154
}
154155
```
@@ -159,10 +160,10 @@ You can use the operation ID that you specified and use the [Get operation by op
159160

160161
You can download the translated video and subtitles once the iteration status is `Succeeded`. The translated video and subtitles are available in the response body of the [Get an iteration by iteration ID](/rest/api/aiservices/videotranslation/iteration-operations/get-iteration) API.
161162

162-
To retrieve details of a specific iteration by its ID, use the HTTP GET request. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, `My-Translation-Id` with the translation ID you want to check, and `My-Iteration-Id` with the iteration ID you want to check.
163+
To retrieve details of a specific iteration by its ID, use the HTTP GET request. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, `Your-Translation-Id` with the translation ID you want to check, and `Your-Iteration-Id` with the iteration ID you want to check.
163164

164165
```azurecli-interactive
165-
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/My-Translation-Id/iterations/My-Iteration-Id?api-version=2024-05-20-preview"
166+
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id/iterations/Your-Iteration-Id?api-version=2024-05-20-preview"
166167
```
167168

168169
You should receive a response body in the following format:
@@ -182,7 +183,7 @@ You should receive a response body in the following format:
182183
},
183184
"status": "Succeeded",
184185
"lastActionDateTime": "2025-03-06T19:17:06.270Z",
185-
"id": "My-Iteration-Id-7",
186+
"id": "Your-Iteration-Id-7",
186187
"createdDateTime": "2025-03-06T19:15:38.723Z"
187188
}
188189
```
@@ -530,46 +531,85 @@ WEBVTT
530531

531532
## Step 4: Create additional iterations (Optional)
532533

533-
You can create additional iterations to improve the translation quality. The process is similar to creating the first iteration. You can specify different settings for the new iteration, such as `speakerCount`, `subtitleMaxCharCountPerSegment`, and `exportSubtitleInVideo`.
534+
You can create additional iterations to improve the translation quality. The process is similar to creating the first iteration.
535+
536+
The `webvttFile` parameter isn't required when creating the first iteration. However, starting from the second iteration, you must specify the `webvttFile` parameter in the iteration process. You need to download the webvtt file, make necessary edits, and then upload it to your Azure Blob storage. You need to specify the Blob URL.
537+
538+
To start translating your video or update an iteration for an existing translation, you need to construct an HTTP PUT request path and body according to the following instructions:
539+
540+
- Specify the required `webvttFile` input parameter. The `webvttFile` parameter is required starting from the second iteration. You need to [download the most recent webvtt file](#download-from-the-result-urls), make the desired edits, and then upload it to your Azure Blob storage. You need to specify the Blob URL. The subtitle file can be in WebVTT or JSON format.
541+
- Optionally, you can specify new settings for the new iteration, such as `speakerCount`, `subtitleMaxCharCountPerSegment`, and `exportSubtitleInVideo`.
542+
543+
For authentication and authorization, you need to include the following headers and path IDs in your request:
544+
- Set the `Operation-Id` header: The `Operation-Id` must be unique for each operation, such as creating each iteration. Replace `Your-Operation-Id` with a unique ID for this operation.
545+
- Replace `Your-Translation-Id` in the path. Use the same translation ID that you specified when you [created the translation](#step-1-create-a-translation). The translation ID remains unchanged.
546+
- Specify a new `iterationId` in the path. The iteration ID must be unique for each operation. Replace `Your-Iteration-Id-2` with an iteration ID of your choice.
547+
- Replace `YourSpeechResourceKey` with your Speech resource key and replace `YourSpeechResourceRegion` with your Speech resource region.
548+
549+
```azurecli-interactive
550+
curl -v -X PUT -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" \
551+
-H "Operation-Id: Your-Operation-Id" \
552+
-H "Content-Type: application/json" \
553+
-d '{
554+
"input": {
555+
"webvttFile": {
556+
"url": "https://YourBlobStorageUrl/YourWebVTTFile.vtt"
557+
}
558+
}
559+
}' "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id/iterations/Your-Iteration-Id-2?api-version=2024-05-20-preview"
560+
```
534561

535-
The `webvttFile` parameter isn't required when creating the first iteration. However, starting from the second iteration, you must specify the `webvttFile` parameter in the iteration process. You need to download the webvtt file, make necessary edits, and then upload it to your Azure Blob storage. You need to specify the Blob URL in the curl code.
562+
You should receive a response body in the following format:
536563

537-
The subtitle file can be in WebVTT or JSON format. If you're unsure about how to prepare a WebVTT file, refer to the following sample formats.
564+
```json
565+
{
566+
"input": {
567+
"webvttFile": {
568+
"url": "https://YourBlobStorageUrl/YourWebVTTFile.vtt"
569+
}
570+
},
571+
"status": "NotStarted",
572+
"lastActionDateTime": "2025-03-06T19:15:38.722Z",
573+
"id": "Your-Iteration-Id-2",
574+
"createdDateTime": "2025-03-06T19:15:38.722Z"
575+
}
576+
```
538577

578+
You can use the operation ID that you specified and use the [Get operation by operation ID](#get-operation-by-operation-id) API periodically until the returned status is `Succeeded` or `Failed`. This operation allows you to monitor the progress of your creating the iteration process. The status property should progress from `NotStarted` to `Running`, and finally to `Succeeded` or `Failed`.
539579

540580
## Get operation by operation ID
541581

542582
Check the status of an operation using its operation ID. The operation ID is unique for each operation, so you can track each operation separately. The operation ID is valid until the translation is deleted.
543583

544-
- Specify the same `Operation-Id` that you used when creating the translation. In the example, `My-Operation-Id-1` is used. Replace `My-Operation-Id-1` with an operation ID of your choice.
584+
- Specify the same `Operation-Id` that you used when creating the translation. In the example, `Your-Operation-Id-1` is used. Replace `Your-Operation-Id-1` with an operation ID of your choice.
545585
- Replace `YourSpeechResourceKey` with your Speech resource key and replace `YourSpeechResourceRegion` with your Speech resource region.
546586

547587
```azurecli-interactive
548-
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/operations/My-Operation-Id-1?api-version=2024-05-20-preview"
588+
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/operations/Your-Operation-Id-1?api-version=2024-05-20-preview"
549589
```
550590

551591
You should receive a response body in the following format:
552592

553593
```json
554594
{
555-
"id": "My-Operation-Id-1",
595+
"id": "Your-Operation-Id-1",
556596
"status": "Running"
557597
}
558598
```
559599

560600
## Delete a translation by translation ID
561601

562-
Remove a specific translation identified by `translationId`. This operation also removes all iterations associated with this translation. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, and `My-Translation-Id` with the translation ID you want to delete. If not deleted manually, the service retains the translation history for up to 31 days.
602+
Remove a specific translation identified by `translationId`. This operation also removes all iterations associated with this translation. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, and `Your-Translation-Id` with the translation ID you want to delete. If not deleted manually, the service retains the translation history for up to 31 days.
563603

564604
```azurecli-interactive
565-
curl -v -X DELETE -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/My-Translation-Id?api-version=2024-05-20-preview"
605+
curl -v -X DELETE -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id?api-version=2024-05-20-preview"
566606
```
567607

568608
The response headers include `HTTP/1.1 204 No Content` if the delete request was successful.
569609

570-
## Additional information
610+
## More REST API examples
571611

572-
This section provides curl commands for other API calls that aren't described in detail previously. You can explore each API using the following commands.
612+
This section provides curl commands for other video translation API calls that aren't described in detail previously.
573613

574614
### List translations
575615

@@ -581,18 +621,18 @@ curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://Yo
581621

582622
### Get a translation by translation ID
583623

584-
This operation retrieves detailed information about a specific translation, identified by its unique `translationId`. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, and `My-Translation-Id` with the translation ID you want to check.
624+
This operation retrieves detailed information about a specific translation, identified by its unique `translationId`. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, and `Your-Translation-Id` with the translation ID you want to check.
585625

586626
```azurecli-interactive
587-
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/My-Translation-Id?api-version=2024-05-20-preview"
627+
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id?api-version=2024-05-20-preview"
588628
```
589629

590630
### List iterations
591631

592-
List all iterations for a specific translation. This request lists all iterations without detailed information. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, and `My-Translation-Id` with the translation ID you want to check.
632+
List all iterations for a specific translation. This request lists all iterations without detailed information. Replace `YourSpeechResourceKey` with your Speech resource key, `YourSpeechResourceRegion` with your Speech resource region, and `Your-Translation-Id` with the translation ID you want to check.
593633

594634
```azurecli-interactive
595-
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/My-Translation-Id/iterations?api-version=2024-05-20-preview"
635+
curl -v -X GET -H "Ocp-Apim-Subscription-Key: YourSpeechResourceKey" "https://YourSpeechResourceRegion.api.cognitive.microsoft.com/videotranslation/translations/Your-Translation-Id/iterations?api-version=2024-05-20-preview"
596636
```
597637

598638
## HTTP status codes

0 commit comments

Comments
 (0)