Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. Tutorials
  4. An assistant that can see and talk (Difficulty: 3)

An assistant that can see and talk (Difficulty: 3)

Scheduled Pinned Locked Moved Tutorials
1 Posts 1 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by info-creaticode
    #1

    Introduction

     

    Large language models today are usually multi-modal. This means they can not only chat using words but also understand images.
    This is incredibly useful — sometimes, it’s much easier to show a picture than to try to describe something with words!

    In this tutorial, you will create an AI assistant that can see and talk.
    The user just needs to take a picture with the camera and then ask the AI any question about that picture!

    448b6d33-2ead-4e45-8773-cc0881336bd5-image.png

     
     

    Step 1 - Create a new project

     

    On CreatiCode.com, log in and create a new project. Remove the dog sprite, and rename the project to “AI Assistant”.

     
     

    Step 2 - Search for or generate a backdrop

     

    When the project starts, we want a cool backdrop to show that this is an AI assistant.

    • Switch to the Stage and add a new backdrop.
    • Search for something like “a helpful AI assistant” to find interesting designs:
       
      b2b538a9-48e3-480c-b4f4-e8e4db00b7d7-image.png

     
    You can also generate a new backdrop based on your own idea. For example, suppose we want this assistant to be used as a tour guide, then we can generate the backdrop with a detailed description like this:

    a robot tour guide facing the viewer with both arms open, standing in front of a historical site, cartoon style
    

    And you might get a result like this:

    alt text

     
     

    Step 3 - Show 2 buttons when the green flag is clicked

     

    Now switch to the empty sprite.

    We’ll add two buttons so the user can pick a camera:

    • Front camera (for laptops/touchpads/Chromebooks)
    • Back camera (for iPads/phones)
       

    6b93ef86-699b-4461-93d8-9dc7dbfb28b9-image.png

     
    You can use the following code:

    92fe6a32-0f07-4d2c-9ced-bdab9f8d1879-image.png

     
     

    Step 4 - Show camera preview

     

    When a button is clicked, the camera view will show up so the user can aim at the object or scene.

    • The only difference between the two buttons is whether you use the front or back camera.
    • We’ll use the same camera widget name (“camera1”) for both options.
       

    0ede859c-0d0f-49c5-8093-825d2e2a97d4-image.png

     
     

    Step 5 - Prepare to take a picture

     

    Besides showing the camera, we also need to get ready for the user to take a picture.

    To avoid repeating code, let’s make a custom block called “prepare to take picture”:

    8deb6639-60a8-497a-b4f7-fe4897bd642b-image.png

     
    Inside this custom block:

    • Delete the two old buttons.
    • Add a new button to take a picture.
       

    ce8bd9ac-6500-4a4c-88ec-2d9649616ecf-image.png

     
    Now the stage will look like this when getting ready to snap a photo:

    6cbf3772-ae0f-41b7-a5ed-47722983390d-image.png

     
     

    Step 6 - Take a picture and show it

     

    When the user clicks the “Take a picture” button, we will save the current camera view as a costume image named “c”. We will also remove all the widgets (the camera view and the button) so that the newly captured costume image is shown to the user:

    31dd923b-69e8-4462-a8d1-dc8fbe0f545d-image.png

     
     

    Step 7 - Prepare for the user question

     

    After taking the picture, add more blocks to:

    • Create a new button for the user to ask a question using speech.
    • Add a textbox to show the recognized question.

    👉 Make the textbox background 30% transparent so the captured costume image stays visible behind it.

    3e36e3a2-82c6-4334-8ce3-4deb6a98d7e4-image.png
     
    Result:
     

    6d2508ce-6e56-479b-ad1d-ea953ee611cb-image.png

     
     

    Step 8 - Recognize the user’s question

     

    When the user clicks “Ask a Question”:

    • Start speech recognition for 8 seconds, which should be long enough for most questions.
    • Show the recognized text inside the textbox.

    3249a6ef-db5c-49fe-b819-dd234954bd6b-image.png

     
    You can also use “continuous speech recognition”, and stop recognition when the user has completed a full sentence. To keep it simple, we will just use the time-based cutoff time.

    To test it, click the “Ask a question” button, and ask a question like “what is this?”, and then it will be recognized and displayed in the textbox:

    9e6a4111-0c02-42e2-bcd6-ba9155e7e12c-image.png

     
     

    Step 9 - Ask AI a question about this image

     

    Finally, we can send the picture and the question to the AI!

    You’ll need two blocks (the LLM block is wide, so it’s shown in two rows):

    d5707c1d-36a5-43a8-be00-8fc26effb4f5-image.png

    175254db-e5db-493c-9b7d-750af1d91d9b-image.png

     

    Here is how it works:

    1. Attach the costume image “c” to the chat: this step will not send the image to the AI (LLM) yet. It only stores the image as part of the chat. You can attach more than one image to a chat session, but for this project, we only need to attach one image.

    2. Send a chat message to AI (LLM): this block will send out the prompt together with the image attached above. We will use a simple prompt: “Answer verbally in 50 words:\n”. The keyword “verbally” ensures the AI’s answer is conversational and not too formal. We are also limiting it to within 50 words to avoid lengthy answers.

    After these 2 blocks run, the AI’s answer will be stored in the variable “result”.

     
     

    Step 10 - Display and say the answer

     

    Once the AI responds:

    • Show the answer in the textbox.
    • Speak the answer out loud!

    Also, make sure to stop any earlier speech when the user asks a new question.

    ee98c2fd-79ce-400e-8ba4-7fb3366f42c2-image.png

     
    The answer will look like this:

    b3ee2f44-e4e1-4720-a50a-622a83a559dd-image.png

     
     

    Additional Challenges

     

    This project demonstrates how to combine many useful AI tools into one simple app, but it is kept simple intentionally. Here are some ideas you can explore to enhance this tool further:

    • Handle follow-up questions:
      Let users keep asking more questions about the same picture.
      Be careful not to re-attach the image again and again. Set the AI to “continue” mode for a smoother conversation.

    • Smarter Speech Recognition:
      Instead of waiting exactly 8 seconds, detect when the user finishes talking, or use start/stop buttons.

    • Translate the Assistant:
      Make it work in your native language!

    • Customize the AI’s Behavior:
      Adjust the prompt to give hints instead of direct answers (for example, for a homework helper version).

    1 Reply Last reply
    1
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode