Building a Public speaking Assistant using Lyzr SDK

akshay007

Akshay Keerthi

Posted on August 6, 2024

Building a Public speaking Assistant using Lyzr SDK

Public speaking can be daunting, but with the right preparation and practice, anyone can become a confident and engaging speaker. Our Public Speaking Assistant app, developed using Lyzr Automata SDK and OpenAI’s GPT-4 Turbo, provides personalized exercises tailored to your audience and speech type. This blog post will walk you through how we built this app to help you shine on stage.

Image description

Why use Lyzr SDK’s?
With Lyzr SDKs, crafting your own GenAI application is a breeze, requiring only a few lines of code to get up and running swiftly.

Lets get Started!

Setting Up the Environment

To begin, we import the necessary libraries and set up our environment, including configuring the OpenAI API key.

import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent, Task
from PIL import Image
from lyzr_automata.tasks.task_literals import InputType, OutputType
import os
Enter fullscreen mode Exit fullscreen mode

Set the OpenAI API key

os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]
Enter fullscreen mode Exit fullscreen mode

Creating the App Title and Introduction

We then set the app’s title and provide a brief introduction to guide users on the information they need to input.

App title and introduction

st.title("Public Speaking Assistant")
st.markdown("Welcome to Tailored Public Speaking Exercises! Just tell us about your audience and the type of speech you're preparing for, and we'll give you custom drills to help you shine.")
st.markdown("1) Mention your audience type.")
st.markdown("2) Mention the type of speech you're preparing for.")
input = st.text_input("Please enter the above details:", placeholder="Type here")
Enter fullscreen mode Exit fullscreen mode

Initializing the OpenAI Model

We initialize the OpenAI model with specific parameters for text completion. This model will generate personalized public speaking exercises.

open_ai_text_completion_model = OpenAIModel(
    api_key=st.secrets["apikey"],
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)
Enter fullscreen mode Exit fullscreen mode

Defining the Generation Function

The generation function uses the OpenAI model to generate personalized public speaking exercises based on user input. It defines the agent's role and prompt for the task.

def generation(input):
    generator_agent = Agent(
        role="Expert PUBLIC SPEAKING ASSISTANT",
        prompt_persona="Your task is to ANALYZE the user's AUDIENCE and the TYPE of speech they are preparing for, and provide them with PERSONALIZED public speaking drills.")
    prompt = """
[Prompts here]
"""
    generator_agent_task = Task(
        name="Generation",
        model=open_ai_text_completion_model,
        agent=generator_agent,
        instructions=prompt,
        default_input=input,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
    ).execute()
    return generator_agent_task
Enter fullscreen mode Exit fullscreen mode

Adding the Assist Button

We add a button that triggers the generation of personalized exercises when clicked.

if st.button("Assist!"):
    solution = generation(input)
    st.markdown(solution)
Enter fullscreen mode Exit fullscreen mode

The Public Speaking Assistant app helps users enhance their public speaking skills by providing personalized exercises based on their audience and speech type. Leveraging the power of Lyzr Automata SDK and OpenAI’s GPT-4 Turbo, this app offers a practical solution for anyone looking to improve their public speaking abilities.

App link: https://speakingassistant-lyzr.streamlit.app/

Source Code: https://github.com/isakshay007/speaking_assistant

Try building your own version of the Public Speaking Assistant app and experience the benefits of AI-driven personalized exercises! If you have any questions or need further assistance, feel free to contact Lyzr.

Website: Lyzr.ai
Book a Demo: Book a Demo
Discord: Join our Discord community
Slack: Join our Slack channel

💖 💪 🙅 🚩
akshay007
Akshay Keerthi

Posted on August 6, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related