Attempting to generate a prompt using Google Generative AI Conversation integration, and make TTS say the response out loud

Hi everyone!

Just after I saw the AI integration, this idea came into my mind. Sadly, I don’t really understand how to code, I just the visual way to create automations.

I am not sure if it is possible, but it would be amazing if my speakers could say the responses created by Google AI.

This is where I am at:

alias: Google AI tells history
description: ""
trigger:
  - platform: time_pattern
    hours: "2"
    minutes: "5"
    seconds: "30"
condition: []
action:
  - service: google_generative_ai_conversation.generate_content
    metadata: {}
    data:
      prompt: >-
        Pick a random date, and tell about a significant event in the history
        happened that day.
    response_variable: ai_response
  - service: tts.cloud_say
    entity_id: media_player.living_room
    data_template:
      message: null
mode: single

Thank you guys!

1 Like

Yes it’s possible. See Gemini Pro API - #17 by tronikos

I have a lot of similar automation. Just use service: conversation.process for the prompt and then use
message: " {{ ai_response.response.speech.plain.speech }} "
for tts. That’s it.

Thanks everyone! I figured it out!

action:
  - service: google_generative_ai_conversation.generate_content
    data:
      prompt: Can you give me a random history fact?
    response_variable: generated_contenthistory
  - service: tts.cloud_say
    entity_id: media_player.living_room
    data_template:
      message: "{{ generated_contenthistory['text'] }}"
mode: single

This way I can edit it the way I want, and make it pull any answer by editing the prompt!

2 Likes