<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yusufgbagci</title>
    <description>The latest articles on DEV Community by yusufgbagci (@yusufgbagci).</description>
    <link>https://dev.to/yusufgbagci</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1727780%2Fa434184c-24e3-4403-ad41-1aa6c9834eb8.jpeg</url>
      <title>DEV Community: yusufgbagci</title>
      <link>https://dev.to/yusufgbagci</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yusufgbagci"/>
    <language>en</language>
    <item>
      <title>Scalable and Responsive EC2 Management Application</title>
      <dc:creator>yusufgbagci</dc:creator>
      <pubDate>Fri, 17 Jan 2025 09:56:43 +0000</pubDate>
      <link>https://dev.to/yusufgbagci/scalable-and-responsive-ec2-management-application-2obf</link>
      <guid>https://dev.to/yusufgbagci/scalable-and-responsive-ec2-management-application-2obf</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Managing workloads on high-cost EC2 instances, such as the g5.2xlarge, demands a scalable and responsive approach. This article explores how a Flask web application can efficiently manage these instances, specifically focusing on a project called Metaverse Avatar running on Unreal Engine.&lt;/p&gt;

&lt;p&gt;This project showcases a Flask-based web application designed to optimize EC2 instance management. By incorporating a suite of AWS services—DynamoDB for data storage, Cognito for user authentication, Kinesis for event streaming, and EC2 for instance management—the application ensures seamless and efficient handling of EC2 instances that are running the application. This integration not only enhances resource utilization but also ensures cost efficiency, making it a powerful tool for managing high-cost, performance-intensive workloads like in our case Metaverse Avatar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Authentication&lt;/strong&gt;&lt;br&gt;
The application employs AWS Cognito for secure user authentication. This ensures that only authorized users can access and manage EC2 instances, enhancing the overall security of the system. Cognito handles the authentication flow, storing user credentials, and managing session tokens.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;EC2 Instance Management&lt;/strong&gt;&lt;br&gt;
The core functionality of the application revolves around managing EC2 instances. Users can start, stop, and terminate instances based on their needs. The application interacts with AWS EC2 to perform these actions, ensuring that the instances are managed efficiently and cost-effectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Warm Pool Management&lt;/strong&gt; &lt;br&gt;
To reduce the startup time of new EC2 instances, the application maintains a warm pool of pre-warmed instances. This pool is managed in a separate thread to ensure it doesn't interfere with other operations. The warm pool ensures that instances are readily available, reducing the wait time for users and optimizing resource usage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-time Event Streaming&lt;/strong&gt;&lt;br&gt;
For real-time capabilities, the application integrates AWS Kinesis. This service streams events and logs in real-time, allowing users to monitor the state and performance of their EC2 instances continuously. This feature is crucial for maintaining an immersive and responsive user experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup and Running
&lt;/h2&gt;

&lt;p&gt;To set up and run the project, follow these steps:&lt;br&gt;
 &lt;strong&gt;Install the required dependencies&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure you have Python 3. x installed.&lt;/li&gt;
&lt;li&gt;Also other libraries:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;boto3==1.34.36
botocore==1.34.36
cachetools==5.3.2
Flask==3.0.2
isodate==0.6.1
Jinja2==3.1.2
pydantic==1.10.13
python-dateutil==2.8.2
requests==2.31.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Ensure you have the necessary permissions to access the required AWS services (EC2, the database service, authentication service, and event streaming service).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Run the Flask&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The application will start running on the &lt;a href="https://localhost:5000" rel="noopener noreferrer"&gt;https://localhost:5000&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** Algorithm Logic:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygy367t69butlp0z5km2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygy367t69butlp0z5km2.jpg" alt="Logic" width="800" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Running the Flask Application&lt;/strong&gt;&lt;br&gt;
First, you'll need to run the application. You can do this either on an AWS instance or your local machine. Once the script is running, the Flask app will be accessible via the domain in our case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;metaverse.genai-avatar.com.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: User Authentication with AWS Cognito&lt;/strong&gt;&lt;br&gt;
To access the application, you need to log in with the credentials created in Amazon Cognito. The login page looks like this:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femxlbtuqp1nu83eh6qaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femxlbtuqp1nu83eh6qaq.png" alt="Image description" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After logging in, you'll be redirected to the interface where you can connect or initiate an AWS instance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Initiating an Instance&lt;/strong&gt;&lt;br&gt;
Upon successful login, you'll see an interface like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6c1m8ngmr4at17hncuf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6c1m8ngmr4at17hncuf.png" alt="Image description" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can initiate your application instance. By clicking the 'Start' button, you initiate the instance specified by its Instance ID and AMI ID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Monitoring Instance Logs&lt;/strong&gt;&lt;br&gt;
While your application instance starts, you can monitor its logs in real time. This is facilitated by AWS Kinesis Data Streams, which sends logs from your application to the web UI, ensuring that the instance is initializing correctly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faz0gqkqudz4x0r8sqnku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faz0gqkqudz4x0r8sqnku.png" alt="Image description" width="800" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This process not only helps in verifying the initialization but also ensures that any issues can be promptly identified and addressed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Automatic Instance Management&lt;/strong&gt;&lt;br&gt;
During the instance initialization, several key details are saved in DynamoDB table, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UserId&lt;/li&gt;
&lt;li&gt;InstanceId&lt;/li&gt;
&lt;li&gt;CreationTime&lt;/li&gt;
&lt;li&gt;ExpireAt&lt;/li&gt;
&lt;li&gt;PublicIp&lt;/li&gt;
&lt;li&gt;SubnetId&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These details are crucial for managing the instance lifecycle. The application provides each user with a one-hour window to use the instance. If there is no activity from the user within this period, the instance is automatically stopped to save costs.&lt;/p&gt;

&lt;p&gt;While the logs from the application are visible in the UI, you can also monitor the status of the instances. This ensures that the instances are initializing correctly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnkqc84j8e70vfq4q8hqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnkqc84j8e70vfq4q8hqc.png" alt="Image description" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown in the screenshot, the application is running correctly so far. The instances are named according to the user authenticated via Cognito, and five warm pool instances are being initialized. This number can be configured in the configuration file. For testing purposes in this blog post, the instance type selected is t2.micro.&lt;/p&gt;

&lt;p&gt;Once the instance status checks are healthy, you will see a message indicating that the instance is ready.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8y23dj38ujel3eh38lkr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8y23dj38ujel3eh38lkr.png" alt="Image description" width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, to connect to your running on the instance, you can click the 'Connect' button. This will redirect you to a new domain specific to your username, where your application is running. With the this domain in our case we are able our launch the metaverse avatar. (If you're curious about how our metaverse-metahuman avatar looks and operates, please check out my other blog post )&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbcvbg0h2vs6ncupn3xo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbcvbg0h2vs6ncupn3xo.png" alt="Image description" width="800" height="58"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Disconnecting and Automatic Shutdown&lt;/strong&gt;&lt;br&gt;
When you are done using your application, you can log out. Upon logging out, the instance associated with your session will automatically shut down to save resources and costs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fptwtf5h2wkltehuvgpi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fptwtf5h2wkltehuvgpi0.png" alt="Image description" width="800" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This automatic shutdown ensures that no resources are wasted when the instance is not in use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Reusing Warm Pool Instances&lt;/strong&gt;&lt;br&gt;
Now that everything is in place and the algorithm works as expected, you might wonder what happens if you want to start the application again on an instance. Thanks to the warm pool of instances, the algorithm will not initialize a completely new instance for you. Instead, it will start one of the warm pool instances. This significantly reduces the starting time, allowing you to use your application quickly with your designated domain.&lt;/p&gt;

&lt;p&gt;When you initiate the application again, the process will be as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Starting Warm Pool Instance: The algorithm will select an available instance from the warm pool. Since these instances are pre-initialized, the startup time is minimal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Domain Assignment: The selected instance will be associated with your domain. This means you can access your application at the same domain as before, ensuring a seamless user experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Quick Availability: Since the instance is already part of the warm pool, the application will be ready to use in a short time. You won't have to wait for a new instance to be initialized, which can save several minutes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach optimizes both time and resources, ensuring that you can start your application promptly without unnecessary delays.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This Flask web application demonstrates an efficient approach to managing EC2 instances using AWS services. By leveraging AWS Cognito, DynamoDB, Kinesis, and EC2, the application ensures scalability, responsiveness, and cost-effectiveness. This project serves as a robust solution for handling dynamic workloads and managing cloud resources efficiently. With secure authentication, effective warm pool management, real-time event streaming, and seamless session management, the application offers a comprehensive and efficient tool for EC2 instance management.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Metahuman with AWS</title>
      <dc:creator>yusufgbagci</dc:creator>
      <pubDate>Mon, 19 Aug 2024 14:07:31 +0000</pubDate>
      <link>https://dev.to/yusufgbagci/metahuman-with-aws-3lbp</link>
      <guid>https://dev.to/yusufgbagci/metahuman-with-aws-3lbp</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Integrating AWS services with Unreal Engine can significantly enhance your project's capabilities, particularly if the actors in Unreal Engine utilize AWS AI services. While Amazon GameLift is a common service for deploying, operating, and scaling dedicated, low-cost servers in the cloud for session-based multiplayer games in a UE environment, other AWS services can also be integrated based on the use case. Services like EC2, API Gateway, and S3 can seamlessly integrate with Unreal Engine to provide various functionalities.&lt;/p&gt;

&lt;p&gt;In our work, we integrated Amazon Transcribe, Amazon Bedrock, and Amazon Polly services into Unreal Engine using the C++ SDK and Python SDK. This integration enables the creation of advanced interactive experiences within the Unreal Engine environment.&lt;/p&gt;

&lt;p&gt;MetaHuman is a comprehensive framework that empowers creators to develop and use fully rigged, photorealistic digital humans in various projects powered by Unreal Engine. The purpose of our work is to integrate a MetaHuman with AWS to create a real-time LLM (Language Learning Model) - RAG (Retrieval-Augmented Generation) powered avatar that can interact and communicate in real time. This post will guide you through the essential steps to set up and run AWS on Unreal Engine 4.27, covering the necessary configurations, modules, and scripts that make up this powerful combination.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxyg5jcafmls264w9fioa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxyg5jcafmls264w9fioa.png" alt="Image description" width="786" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By following this guide, you will learn how to leverage AWS AI services to enhance the interactivity and realism of your Unreal Engine projects, making it possible to create lifelike digital avatars capable of real-time communication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into the integration, ensure you have your AWS STS (Security Token Service) token ready. This token is crucial for secure interactions with AWS services. Follow the steps below to generate and configure your AWS STS token:&lt;/p&gt;

&lt;h4&gt;
  
  
  Generate AWS STS Token
&lt;/h4&gt;

&lt;p&gt;First, you need to configure your .config and .credentials files as explained here.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html" rel="noopener noreferrer"&gt;
      docs.aws.amazon.com
    &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Obtain the tokens by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sts get-session-token --profile &amp;lt;profilename&amp;gt; --serial-number &amp;lt;your mfa device in aws&amp;gt; --token-code &amp;lt;MFA_CODE&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set Environment Variables:&lt;br&gt;
After obtaining your tokens, set your environment variables using the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setx AWS_ACCESS_KEY_ID ************
setx AWS_SECRET_ACCESS_KEY ***********
setx AWS_SESSION_TOKEN ********** 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Unreal Engine version
&lt;/h4&gt;

&lt;p&gt;Although Unreal Engine 5.4 has been announced, our integration works only with versions 4.27 or 4.26. The reason for this is the compatibility of the C++ SDK integration with these specific versions of Unreal Engine. Ensure you have one of these versions installed before proceeding with the integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modules Overview
&lt;/h2&gt;

&lt;p&gt;The Metahuman project consists of several essential modules, each serving a specific purpose. Let's break down these modules:&lt;/p&gt;

&lt;h4&gt;
  
  
  Content
&lt;/h4&gt;

&lt;p&gt;Integrating Unreal Engine with AWS is a complex process that requires multiple steps. Here’s a streamlined approach to get you started:&lt;/p&gt;

&lt;p&gt;Cloning the AWS SDK Repository&lt;br&gt;
First, check if the SDK repository directory exists. If it does not, clone the AWS SDK from GitHub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/aws/aws-sdk-cpp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, run CMake to configure the build system for Visual Studio:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd aws-sdk-cpp
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After configuring the build system, build the SDK using MSBuild&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msbuild ALL_BUILD.vcxproj /p:Configuration=Release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, install the built SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msbuild INSTALL.vcxproj /p:Configuration=Release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By following these steps, you’ll have the AWS SDK ready for integration with Unreal Engine. This setup ensures you have the necessary tools to proceed with more advanced AWS functionalities within Unreal Engine.&lt;/p&gt;

&lt;h4&gt;
  
  
  Plugins
&lt;/h4&gt;

&lt;p&gt;Plugins extend the functionality of Unreal Engine, and our project will utilize the following plugin:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CallExePlugin:&lt;/strong&gt; This custom plugin, created by Jens Krenzin, allows you to run Python scripts within your Unreal Engine project.&lt;/p&gt;

&lt;p&gt;The plugin has two types of functionality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Blocking Mode: While the script is running in Unreal Engine, it blocks other applications. Once the script runtime is over, Unreal Engine resumes normal operation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-blocking Mode: This version does not interrupt other applications while running.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this project, we use the non-blocking version to ensure that MetaHuman can function without any interruptions.&lt;br&gt;
In this plugin, you need to specify the directory where Python is set up on your local PC as well as the directory of the Python script you want to run. This configuration ensures that the plugin can locate and execute the necessary Python scripts seamlessly within your Unreal Engine project.&lt;/p&gt;

&lt;p&gt;Here's a brief overview of how to set it up:&lt;/p&gt;

&lt;p&gt;Python Directory: Provide the path to your local Python installation.&lt;br&gt;
Script Directory: Specify the directory where your Python scripts are located.&lt;br&gt;
By configuring these directories, the CallExePlugin will be able to execute your Python scripts, extending the functionality of your Unreal Engine project without interruptions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F391xsm0qwqgh550775ku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F391xsm0qwqgh550775ku.png" alt="CallExePlugin Blueprint" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Scripts
&lt;/h4&gt;

&lt;p&gt;The Scripts directory houses various Python scripts essential for the project's core features. Here’s an overview of the key script:&lt;/p&gt;

&lt;p&gt;main.py: This Python file takes the user's voice input and converts it to text using Amazon Transcribe. The transcribed text is then sent to Amazon Bedrock for further processing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Voice to Text: Amazon Transcribe's real-time feature is used to convert the user's voice into text. This allows for immediate processing and response.&lt;/li&gt;
&lt;li&gt;Text to LLM: The transcribed text is forwarded to Amazon Bedrock. Bedrock is an AWS service that hosts multiple language models (LLMs). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our project, we use Claude 3 Sonnet, located in the Frankfurt region.&lt;br&gt;
This seamless integration between Amazon Transcribe and Amazon Bedrock enables real-time interaction, allowing the LLM to provide immediate and relevant responses. This setup ensures a smooth and efficient workflow, enhancing the overall user experience.&lt;/p&gt;
&lt;h4&gt;
  
  
  Blueprint Communication and Polly Integration
&lt;/h4&gt;

&lt;p&gt;Each avatar has its own Blueprint that must connect to the Scene-Blueprints (BP_UIWidget) for user interaction.&lt;/p&gt;

&lt;p&gt;The Metahuman Blueprint is the main place to set up all AWS services and plugins. Here, we configure AWS Polly using the C++ SDK.&lt;br&gt;
Amazon Polly provides two important capabilities that make this project work seamlessly. First, Polly can turn text into natural-sounding speech as an audio file. Second, Polly can generate a JSON-formatted list of mouth shapes corresponding to the sounds in that audio file. These mouth shapes are called "visemes." Here are what the visemes for the word "human" look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"time":2,"type":"viseme","value":"o"}
{"time":52,"type":"viseme","value":"k"}
{"time":196,"type":"viseme","value":"p"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because this viseme data includes timestamps for each mouth shape, we can use that information to achieve believable lip sync between the audio playback and MetaHuman facial animations.&lt;/p&gt;

&lt;p&gt;We created a Generate Speech function, which takes the text from our CallExePlugin and creates speech using Amazon Polly. This function is connected to another function that updates the AnimGraph. Specifically, it updates the "Viseme" variable to drive a Blend Pose node. This node determines which one of the possible viseme animation assets will be applied to the MetaHuman's face.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vrl285cbxs8e9chofz9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vrl285cbxs8e9chofz9.png" alt="Viceme Animation Blueprint" width="800" height="608"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By leveraging Amazon Polly's capabilities, we ensure that the MetaHuman's lip movements are synchronized with the generated speech, creating a realistic experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fworsf6oup0oyyrxsk3gz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fworsf6oup0oyyrxsk3gz.png" alt="Image description" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Integrating AWS with Unreal Engine 4.27 involves several crucial steps, including configuring AWS STS tokens, setting up essential modules, and utilizing plugins and scripts to enhance MetaHuman capabilities.&lt;/p&gt;

&lt;p&gt;In our use case, we configured our LLM (Language Learning Model) in a CEO role and created a RAG (Retrieval-Augmented Generation) system with the necessary data. This configuration allows our MetaHuman to act as a company's CEO. Users can interact with the avatar by asking questions about the company via voice, and the avatar responds with natural-sounding speech.&lt;/p&gt;

&lt;p&gt;Here's a video showing how we interact with our avatar: &lt;a href="https://www.youtube.com/watch?v=URaJv-YHVT8" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=URaJv-YHVT8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Although I am publishing this article, there is a great team behind this project. Thanks for the amazing work: Artur Schneider, Lydia Delyova, Jens Krenzin, and Willi Schwarzbach.&lt;/p&gt;

</description>
      <category>unrealengine</category>
      <category>aws</category>
      <category>llm</category>
      <category>metahuman</category>
    </item>
  </channel>
</rss>
