Enhance speech synthesis and video technology fashions with RLHF utilizing audio and video segmentation in Amazon SageMaker
As generative AI fashions advance in creating multimedia content material, the distinction between good and nice output typically lies within the particulars that solely human suggestions can seize. Audio and video segmentation supplies a structured method to collect this detailed suggestions, permitting fashions to be taught by reinforcement studying from human suggestions (RLHF) and supervised fine-tuning (SFT). Annotators can exactly mark and consider particular moments in audio or video content material, serving to fashions perceive what makes content material really feel genuine to human viewers and listeners.
Take, for example, text-to-video technology, the place fashions must be taught not simply what to generate however tips on how to preserve consistency and pure movement throughout time. When making a scene of an individual performing a sequence of actions, elements just like the timing of actions, visible consistency, and smoothness of transitions contribute to the standard. Through exact segmentation and annotation, human annotators can present detailed suggestions on every of those features, serving to fashions be taught what makes a generated video sequence really feel pure slightly than synthetic. Similarly, in text-to-speech functions, understanding the refined nuances of human speech—from the size of pauses between phrases to adjustments in emotional tone—requires detailed human suggestions at a section stage. This granular enter helps fashions learn to produce speech that sounds pure, with acceptable pacing and emotional consistency. As giant language fashions (LLMs) more and more combine extra multimedia capabilities, human suggestions turns into much more essential in coaching them to generate wealthy, multi-modal content material that aligns with human high quality requirements.
The path to creating efficient AI fashions for audio and video technology presents a number of distinct challenges. Annotators must determine exact moments the place generated content material matches or deviates from pure human expectations. For speech technology, this implies marking actual factors the place intonation adjustments, the place pauses really feel unnatural, or the place emotional tone shifts unexpectedly. In video technology, annotators should pinpoint frames the place movement turns into jerky, the place object consistency breaks, or the place lighting adjustments seem synthetic. Traditional annotation instruments, with primary playback and marking capabilities, typically fall quick in capturing these nuanced particulars.
Amazon SageMaker Ground Truth permits RLHF by permitting groups to combine detailed human suggestions instantly into mannequin coaching. Through {custom} human annotation workflows, organizations can equip annotators with instruments for high-precision segmentation. This setup permits the mannequin to be taught from human-labeled information, refining its skill to provide content material that aligns with pure human expectations.
In this publish, we present you tips on how to implement an audio and video segmentation resolution within the accompanying GitHub repository utilizing SageMaker Ground Truth. We information you thru deploying the required infrastructure utilizing AWS CloudFormation, creating an inner labeling workforce, and establishing your first labeling job. We exhibit tips on how to use Wavesurfer.js for exact audio visualization and segmentation, configure each segment-level and full-content annotations, and construct the interface to your particular wants. We cowl each console-based and programmatic approaches to creating labeling jobs, and supply steering on extending the answer with your personal annotation wants. By the tip of this publish, you should have a completely purposeful audio/video segmentation workflow that you may adapt for numerous use circumstances, from coaching speech synthesis fashions to bettering video technology capabilities.
Feature Overview
The integration of Wavesurfer.js in our UI supplies an in depth waveform visualization the place annotators can immediately see patterns in speech, silence, and audio depth. For occasion, when engaged on speech synthesis, annotators can visually determine unnatural gaps between phrases or abrupt adjustments in quantity which may make generated speech sound robotic. The skill to zoom into these waveform patterns means they’ll work with millisecond precision—marking precisely the place a pause is simply too lengthy or the place an emotional transition occurs too abruptly.
In this snapshot of audio segmentation, we’re capturing a customer-representative dialog, annotating speaker segments, feelings, and transcribing the dialogue. The UI permits for playback velocity adjustment and zoom performance for exact audio evaluation.

The multi-track characteristic lets annotators create separate tracks for evaluating completely different features of the content material. In a text-to-speech activity, one monitor would possibly concentrate on pronunciation accuracy, one other on emotional consistency, and a 3rd on pure pacing. For video technology duties, annotators can mark segments the place movement flows naturally, the place object consistency is maintained, and the place scene transitions work properly. They can alter playback velocity to catch refined particulars, and the visible timeline for exact begin and finish factors for every marked section.
In this snapshot of video segmentation, we’re annotating a scene with canine, monitoring particular person animals, their colours, feelings, and gaits. The UI additionally permits general video high quality evaluation, scene change detection, and object presence classification.

Annotation course of
Annotators start by selecting Add New Track and choosing acceptable classes and tags for his or her annotation activity. After you create the monitor, you’ll be able to select Begin Recording on the level the place you need to begin a section. As the content material performs, you’ll be able to monitor the audio waveform or video frames till you attain the specified finish level, then select Stop Recording. The newly created section seems in the best pane, the place you’ll be able to add classifications, transcriptions, or different related labels. This course of might be repeated for as many segments as wanted, with the power to regulate section boundaries, delete incorrect segments, or create new tracks for various annotation functions.

Importance of high-quality information and decreasing labeling errors
High-quality information is crucial for coaching generative AI fashions that may produce pure, human-like audio and video content material. The efficiency of those fashions relies upon instantly on the accuracy and element of human suggestions, which stems from the precision and completeness of the annotation course of. For audio and video content material, this implies capturing not simply what sounds or appears to be like unnatural, however precisely when and the way these points happen.
Our objective constructed UI in SageMaker Ground Truth addresses widespread challenges in audio and video annotation that always result in inconsistent or imprecise suggestions. When annotators work with lengthy audio or video information, they should mark exact moments the place generated content material deviates from pure human expectations. For instance, in speech technology, an unnatural pause would possibly final solely a fraction of a second, however its impression on perceived high quality is critical. The device’s zoom performance permits annotators to develop these transient moments throughout their display, making it doable to mark the precise begin and finish factors of those refined points. This precision helps fashions be taught the nice particulars that separate pure from artificial-sounding speech.
Solution overview
This audio/video segmentation resolution combines a number of AWS companies to create a strong annotation workflow. At its core, Amazon Simple Storage Service (Amazon S3) serves because the safe storage for enter information, manifest information, annotation outputs, and the online UI elements. SageMaker Ground Truth supplies annotators with an online portal to entry their labeling jobs and manages the general annotation workflow. The following diagram illustrates the answer structure.

The UI template, which incorporates our specialised audio/video segmentation interface constructed with Wavesurfer.js, requires particular JavaScript and CSS information. These information are hosted by Amazon CloudFront distribution, offering dependable and environment friendly supply to annotators’ browsers. By utilizing CloudFront with an origin entry id and acceptable bucket insurance policies, we permit the UI elements to be served to annotators. This setup follows AWS finest practices for least-privilege entry, ensuring CloudFront can solely entry the particular UI information wanted for the annotation interface.
Pre-annotation and post-annotation AWS Lambda features are elective elements that may improve the workflow. The pre-annotation Lambda perform can course of the enter manifest file earlier than information is offered to annotators, enabling any crucial formatting or modifications. Similarly, the post-annotation Lambda perform can remodel the annotation outputs into particular codecs required for mannequin coaching. These features present flexibility to adapt the workflow to particular wants with out requiring adjustments to the core annotation course of.
The resolution makes use of AWS Identity and Access Management (IAM) roles to handle permissions:
- A SageMaker Ground Truth IAM position permits entry to Amazon S3 for studying enter information and writing annotation outputs
- If used, Lambda perform roles present the required permissions for preprocessing and postprocessing duties
Let’s stroll by the method of establishing your annotation workflow. We begin with a easy state of affairs: you may have an audio file saved in Amazon S3, together with some metadata like a name ID and its transcription. By the tip of this walkthrough, you should have a completely purposeful annotation system the place your group can section and classify this audio content material.
Prerequisites
For this walkthrough, be sure to have the next:
- Familiarity with SageMaker Ground Truth labeling jobs and the workforce portal
- Basic understanding of CloudFormation templates
- An AWS account with permissions to deploy CloudFormation stacks
- A SageMaker Ground Truth non-public workforce configured for labeling jobs
- Permissions to launch CloudFormation stacks that create and configure S3 buckets, CloudFront distributions, and Lambda features robotically
Create your inner workforce
Before we dive into the technical setup, let’s create a personal workforce in SageMaker Ground Truth. This means that you can take a look at the annotation workflow along with your inner group earlier than scaling to a bigger operation.
- On the SageMaker console, select Labeling workforces.
- Choose Private for the workforce sort and create a brand new non-public group.
- Add group members utilizing their electronic mail addresses—they’ll obtain directions to arrange their accounts.
Deploy the infrastructure
Although this demonstrates utilizing a CloudFormation template for fast deployment, you can even arrange the elements manually. The belongings (JavaScript and CSS information) can be found in our GitHub repository. Complete the next steps for guide deployment:
- Download these belongings instantly from the GitHub repository.
- Host them in your personal S3 bucket.
- Set up your personal CloudFront distribution to serve these information.
- Configure the required permissions and CORS settings.
This guide strategy offers you extra management over infrastructure setup and is perhaps most well-liked if in case you have current CloudFront distributions or a must customise safety controls and belongings.
The remainder of this publish will concentrate on the CloudFormation deployment strategy, however the labeling job configuration steps stay the identical no matter the way you select to host the UI belongings.
This CloudFormation template creates and configures the next AWS assets:
- S3 bucket for UI elements:
- Stores the UI JavaScript and CSS information
- Configured with CORS settings required for SageMaker Ground Truth
- Accessible solely by CloudFront, indirectly public
- Permissions are set utilizing a bucket coverage that grants learn entry solely to the CloudFront Origin Access Identity (OAI)
- CloudFront distribution:
- Provides safe and environment friendly supply of UI elements
- Uses an OAI to securely entry the S3 bucket
- Is configured with acceptable cache settings for optimum efficiency
- Access logging is enabled, with logs being saved in a devoted S3 bucket
- S3 bucket for CloudFront logs:
- Stores entry logs generated by CloudFront
- Is configured with the required bucket insurance policies and ACLs to permit CloudFront to jot down logs
- Object possession is ready to ObjectAuthor to allow ACL utilization for CloudFront logging
- Lifecycle configuration is ready to robotically delete logs older than 90 days to handle storage
- Lambda perform:
- Downloads UI information from our GitHub repository
- Stores them within the S3 bucket for UI elements
- Runs solely throughout preliminary setup and makes use of least privilege permissions
- Permissions embrace Amazon CloudWatch Logs for monitoring and particular S3 actions (learn/write) restricted to the created bucket
After the CloudFormation stack deployment is full, you could find the CloudFront URLs for accessing the JavaScript and CSS information on the AWS CloudFormation console. You want these CloudFront URLs to replace your UI template earlier than creating the labeling job. Note these values—you’ll use them when creating the labeling job.
Prepare your enter manifest
Before you create the labeling job, it is advisable to put together an enter manifest file that tells SageMaker Ground Truth what information to current to annotators. The manifest construction is versatile and might be personalized primarily based in your wants. For this publish, we use a easy construction:
{
"supply": "s3://YOUR-BUCKET/audio/sample1.mp3",
"call-id": "call-123",
"transcription": "Customer: I'm actually joyful along with your sensible house safety system. However, I've characteristic request that may make it betternRepresentative: We're at all times keen to listen to from our clients. What characteristic would you wish to see added ? "
}
You can adapt this construction to incorporate extra metadata that your annotation workflow requires. For instance, you would possibly need to add speaker data, timestamps, or different contextual information. The key’s ensuring your UI template is designed to course of and show these attributes appropriately.
Create your labeling job
With the infrastructure deployed, let’s create the labeling job in SageMaker Ground Truth. For full directions, check with Accelerate {custom} labeling workflows in Amazon SageMaker Ground Truth with out utilizing AWS Lambda.
- On the SageMaker console, select Create labeling job.
- Give your job a reputation.
- Specify your enter information location in Amazon S3.
- Specify an output bucket the place annotations will likely be saved.
- For the duty sort, choose Custom labeling activity.
- In the UI template subject, find the placeholder values for the JavaScript and CSS information and replace as follows:
- Replace
audiovideo-wavesufer.jsalong with your CloudFront JavaScript URL from the CloudFormation stack outputs. - Replace
audiovideo-stylesheet.cssalong with your CloudFront CSS URL from the CloudFormation stack outputs.
- Replace
<!-- Custom Javascript and Stylesheet -->
<script src="audiovideo-wavesufer.js"></script>
<hyperlink rel="stylesheet" href="audiovideo-stylesheet.css">
- Before you launch the job, use the Preview characteristic to confirm your interface.
You ought to see the Wavesurfer.js interface load accurately with all controls working correctly. This preview step is essential—it confirms that your CloudFront URLs are accurately specified and the interface is correctly configured.
Programmatic setup
Alternatively, you’ll be able to create your labeling job programmatically utilizing the CreateLabelingJob API. This is especially helpful for automation or when it is advisable to create a number of jobs. See the next code:
response = sagemaker.create_labeling_job(
LabelingJobName="audio-segmentation-job-demo",
LabelAttributeName="label",
InputConfig={
"DataSource": {
"S3DataSource": {
"ManifestS3Uri": "s3://your-bucket-name/path-to-manifest"
}
}
},
OutputConfig={
"S3OutputPath": "s3://your-bucket-name/path-to-output-file"
},
RoleArn="arn:aws:iam::012345678910:position/SagemakerExecutionRole",
# Optionally add PreHumanJobLambdaArn or AnnotationConsolidationConfig
HumanTaskConfig={
"TaskAvailabilityLifetimeInSeconds": 21600,
"TaskTimeLimitInSeconds": 3600,
"WorkteamArn": "arn:aws:sagemaker:us-east-1:012345678910:workteam/private-crowd/work-team-name",
"TaskDescription": " Evaluate model-generated textual content responses primarily based on a reference picture.",
"MaxConcurrentTaskCount": 1000,
"TaskTitle": " Evaluate Model Responses Based on Image References",
"NumberOfHumanWorkersPerDataObject": 1,
"UiConfig": {
"UiTemplateS3Uri": "s3://your-bucket-name/path-to-ui-template"
The API strategy affords the identical performance because the SageMaker console, however permits for automation and integration with current workflows. Whether you select the SageMaker console or API strategy, the consequence is similar: a completely configured labeling job prepared to your annotation group.
Understanding the output
After your annotators full their work, SageMaker Ground Truth will generate an output manifest in your specified S3 bucket. This manifest comprises wealthy data at two ranges:
- Segment-level classifications – Details about every marked section, together with begin and finish occasions and assigned classes
- Full-content classifications – Overall scores and classifications for your complete file
Let’s take a look at a pattern output to grasp its construction:
{
"solutions": [
{
"acceptanceTime": "2024-11-04T18:33:38.658Z",
"answerContent": {
"annotations": {
"categories": {
"language": [
"English",
"Hindi",
"Spanish",
"French",
"German",
"Dutch"
],
"speaker": [
"Customer",
"Representative"
]
},
"startTimestamp": 1730745219028,
"startUTCTime": "Mon, 04 Nov 2024 18:33:39 GMT",
"streams": {
"language": [
{
"id": "English",
"start": 0,
"end": 334.808635,
"text": "Sample text in English",
"emotion": "happy"
},
{
"id": "Spanish",
"start": 334.808635,
"end": 550.348471,
"text": "Texto de ejemplo en español",
"emotion": "neutral"
}
]
},
"endTimestamp": 1730745269602,
"endUTCTime": "Mon, 04 Nov 2024 18:34:29 GMT",
"elapsedTime": 50574
},
"backgroundNoise": {
"ambient": false,
"music": true,
"visitors": false
},
"emotiontag": "Neutral",
"environmentalSounds": {
"birdsChirping": false,
"doorbell": true,
"footsteps": false
},
"price": {
"1": false,
"2": false,
"3": false,
"4": false,
"5": true
},
"textTranslationFinal": "pattern textual content for transcription"
}
}
]
}
This two-level annotation construction supplies precious coaching information to your AI fashions, capturing each fine-grained particulars and general content material evaluation.
Customizing the answer
Our audio/video segmentation resolution is designed to be extremely customizable. Let’s stroll by how one can adapt the interface to match your particular annotation necessities.
Customize segment-level annotations
The segment-level annotations are managed within the report() perform of the JavaScript code. The following code snippet reveals how one can modify the annotation choices for every section:
ranges.forEach(perform (r) {
// ... current code ...
// Example: Adding a {custom} dropdown for speaker identification
var speakerDropdown = $('<choose>').attr({
identify: 'speaker',
class: 'custom-dropdown-width'
});
var speakerOptions = ['Speaker A', 'Speaker B', 'Multiple Speakers', 'Background Noise'];
speakerOptions.forEach(perform(choice) {
speakerDropdown.append($('<choice>').val(choice).textual content(choice));
});
// Example: Adding a checkbox for high quality points
var qualityCheck = $('<enter>').attr({
sort: 'checkbox',
identify: 'quality_issue'
});
var qualityLabel = $('<label>').textual content('Contains Quality Issues');
tr.append($('<TD>').append(speakerDropdown));
tr.append($('<TD>').append(qualityCheck).append(qualityLabel));
// Add occasion listeners to your new fields
speakerDropdown.on('change', perform() {
r.speaker = $(this).val();
replaceTrackListData(r);
});
qualityCheck.on('change', perform() {
r.hasQualityIssues = $(this).is(':checked');
replaceTrackListData(r);
});
});
You can take away current fields or add new ones primarily based in your wants. Make certain you’re updating the info mannequin (replaceTrackListData perform) to deal with your {custom} fields.
Modify full-content classifications
For classifications that apply to your complete audio/video file, you’ll be able to modify the HTML template. The following code is an instance of including {custom} classification choices:
<div class="row">
<div class="col-6">
<p><robust>Audio Quality Assessment:</robust></p>
<label class="radio">
<enter sort="radio" identify="audioQuality" worth="wonderful" model="width: 20px;">
Excellent
</label>
<label class="radio">
<enter sort="radio" identify="audioQuality" worth="good" model="width: 20px;">
Good
</label>
<label class="radio">
<enter sort="radio" identify="audioQuality" worth="poor" model="width: 20px;">
Poor
</label>
</div>
<div class="col-6">
<p><robust>Content Type:</robust></p>
<label class="checkbox">
<enter sort="checkbox" identify="content materialType" worth="interview" model="width: 20px;">
Interview
</label>
<label class="checkbox">
<enter sort="checkbox" identify="content materialType" worth="presentation" model="width: 20px;">
Presentation
</label>
</div>
</div>
The classifications you add right here will likely be included in your output manifest, permitting you to seize each segment-level and full-content annotations.
Extending Wavesurfer.js performance
Our resolution makes use of Wavesurfer.js, an open supply audio visualization library. Although we’ve carried out core performance for segmentation and annotation, you’ll be able to lengthen this additional utilizing Wavesurfer.js’s wealthy characteristic set. For instance, you would possibly need to:
- Add spectrogram visualization
- Implement extra playback controls
- Enhance zoom performance
- Add timeline markers
For these customizations, we advocate consulting the Wavesurfer.js documentation. When implementing extra Wavesurfer.js options, keep in mind to check completely within the SageMaker Ground Truth preview to evaluation compatibility with the labeling workflow.
Wavesurfer.js is distributed beneath the BSD-3-Clause license. Although we’ve examined the combination completely, modifications you make to the Wavesurfer.js implementation ought to be examined in your surroundings. The Wavesurfer.js group supplies wonderful documentation and assist for implementing extra options.
Clean up
To clear up the assets created throughout this tutorial, observe these steps:
- Stop the SageMaker Ground Truth labeling job if it’s nonetheless operating and also you now not want it. This will halt ongoing labeling duties and cease extra fees from accruing.
- Empty the S3 buckets by deleting all objects inside them. S3 buckets have to be emptied earlier than they are often deleted, so eradicating all saved information facilitates a easy cleanup course of.
- Delete the CloudFormation stack to take away all of the AWS assets provisioned by the template. This motion will robotically delete related companies just like the S3 buckets, CloudFront distribution, Lambda perform, and associated IAM roles.
Conclusion
In this publish, we walked by implementing an audio and video segmentation resolution utilizing SageMaker Ground Truth. We noticed tips on how to deploy the required infrastructure, configure the annotation interface, and create labeling jobs each by the SageMaker console and programmatically. The resolution’s skill to seize exact segment-level annotations together with general content material classifications makes it notably precious for producing high-quality coaching information for generative AI fashions, whether or not you’re engaged on speech synthesis, video technology, or different multimedia AI functions. As you develop your AI fashions for audio and video technology, keep in mind that the standard of human suggestions instantly impacts your mannequin’s efficiency—whether or not you’re coaching fashions to generate extra natural-sounding speech, create coherent video sequences, or perceive complicated audio patterns.
We encourage you to go to our GitHub repository to discover the answer additional and adapt it to your particular wants. You can improve your annotation workflows by customizing the interface, including new classification classes, or implementing extra Wavesurfer.js options. To be taught extra about creating {custom} labeling workflows in SageMaker Ground Truth, go to Accelerate {custom} labeling workflows in Amazon SageMaker Ground Truth with out utilizing AWS Lambda and Custom labeling workflows.
If you’re on the lookout for a turnkey information labeling resolution, take into account Amazon SageMaker Ground Truth Plus, which supplies entry to an professional workforce educated in numerous machine studying duties. With SageMaker Ground Truth Plus, you’ll be able to rapidly obtain high-quality annotations with out the necessity to construct and handle your personal labeling workflows, decreasing prices by as much as 40% and accelerating the supply of labeled information at scale.
Start constructing your annotation workflow right now and contribute to the following technology of AI fashions that push the boundaries of what’s doable in audio and video technology.
About the Authors
Sundar Raghavan is an AI/ML Specialist Solutions Architect at AWS, serving to clients leverage SageMaker and Bedrock to construct scalable and cost-efficient pipelines for pc imaginative and prescient functions, pure language processing, and generative AI. In his free time, Sundar loves exploring new locations, sampling native eateries and embracing the nice outside.
Vineet Agarwal is a Senior Manager of Customer Delivery within the Amazon Bedrock group accountable for Human within the Loop companies. He has been in AWS for over 2 years managing Go-to-Market actions, enterprise and technical operations. Prior to AWS, he labored in SaaS , Fintech and Telecommunications business in companies management position. He has MBA from the Indian School of Business and B. Tech in Electronics and Communications Engineering from National Institute of Technology, Calicut (India). In his free time, Vineet loves enjoying racquetball and having fun with out of doors actions along with his household.
HI-FI News
by way of AWS Machine Learning Blog https://ift.tt/Qw6sMAZ
November 21, 2024 at 06:33PM
-
Product on sale
Audiophile Vinyl Records Cleaning BundleOriginal price was: €69.90.€59.90Current price is: €59.90. incl. VAT -
Product on sale
Easy Start Vinyl Records Cleaning KitOriginal price was: €69.90.€59.90Current price is: €59.90. incl. VAT -
Vinyl Records Cleaner Easy Groove Concentrate€34.95 incl. VAT -
Easy Groove Super Set€199.00 incl. VAT -
Easy Groove Enzycaster – vinyl records prewash cleaner€34.95 incl. VAT -
Easy Groove Extreme MK. II- vinyl records prewash cleaner€45.00 incl. VAT -
Vinyl Records Cleaner – Easy Groove Virgin Concentrate€35.00 incl. VAT -
Easy Groove Spray&Wipe vinyl records cleaner€34.95 incl. VAT








