Skip to content

Commit 30aeb64

Browse files
authored
Add video cropping instructions for avatar.
1 parent ebcea69 commit 30aeb64

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

articles/ai-services/speech-service/text-to-speech-avatar/real-time-synthesis-avatar.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,22 @@ With this approach, you can get an animated canvas that plays like a video, whic
233233

234234
After you have a transparent-background avatar, you can set the background to any dynamic content (like a video) by placing the dynamic content behind the canvas.
235235

236+
## Crop video
237+
238+
The avatar video is by default in a 16:9 aspect ratio. If you want to crop the video to a different aspect ratio, you can crop the video to a rectangle subarea of the original video. You need speficy the rectangle area by giving the coordinates of its top-left vertex and bottom-right vertex. The following code snippet shows how to crop the video:
239+
240+
```JavaScript
241+
const videoFormat = new SpeechSDK.AvatarVideoFormat()
242+
const topLeftCoordinate = new SpeechSDK.Coordinate(640, 0) // coordinate of top-left vertex, with X=640, Y=0
243+
const bottomRightCoordinate = new SpeechSDK.Coordinate(1320, 1080) // coordinate of bottom-right vertex, with X=1320, Y=1080
244+
videoFormat.setCropRange(topLeftCoordinate, bottomRightCoordinate)
245+
const avatarConfig = new SpeechSDK.AvatarConfig(
246+
"lisa", // Set avatar character here.
247+
"casual-sitting", // Set avatar style here.
248+
videoFormat, // Set video format here.
249+
)
250+
```
251+
236252
## Code samples
237253

238254
You can find text to speech avatar code samples in the Speech SDK repository on GitHub. The samples demonstrate how to use real-time text to speech avatars in your web applications.

0 commit comments

Comments
 (0)