How to create multiple phrases to send at random to TTS?

I’ve written some of my thoughts down at my Blog :

Schematically will be tough as the house speaks VOLUMES throughout the day for all sorts of various things. Take a look at my house’s twitter feed as well. The twitter feed is very similar to my speech throughout the house.

Https://twitter.com/BearStoneHA

-Carlo

@CCOSTAN Thanks for making your configs public. Being new to Hassio and yams, python, json and so on…I can certainly learn from this. Trying to understand how one can test your speech_engine by triggering it from the dev-service, i’m having trouble passing the correct parameters.

can anyone show how to pass the parameters for @CCOSTAN speech_engine from dev-service as well from an automation?

Really enjoying trying to learn as much as possible. I’ve went in circles for days but somehow can’t get this to work.

From the dev service, select the name of the script you use to create the message and in the data field add the bits you want to call, something like:

{
"call_greeting" :  1 , 
"call_introduction"  :  1 , 
"message"   :   "THIS IS A TEST"  , 
"call_bye"   : 1
}

@anon43302295, thank you very much, that looks so simple, i guess this is part of the learning curve. i ran it and i heard the engine running. this puts me in the right direction. Thanks again.

1 Like

Sorry to bring up an old thread again but anyone know about “random” still working?

I get an error from the CONFIG because of the character “|”

ie:

action:
- service: tts.google_say
  entity_id: media_player.living_room_home
  data_template:
    message: >
      '{{ ["OK", "Sure", "If you insist", "Done"] | random }}'

This is what I use.
automation.yaml

- id: family_greeting
  alias: Family Greeting
  trigger:
    platform: state
    entity_id:
      - binary_sensor.cameron_home
      - binary_sensor.corey_home
      - binary_sensor.courtney_home
      - binary_sensor.mom_home
      - binary_sensor.morgan_home
      - binary_sensor.wendy_home
      - binary_sensor.jasmine_home
      - binary_sensor.brandon_home
      - binary_sensor.andy_home
      - binary_sensor.nicole_home
    from: 'off'
    to: 'on'
    for: '00:01:45'
  condition:
    condition: time
  # At least one of the following is required.
    after: '10:00:00'
    before: '00:00:01'
  action:
    - wait_template: "{{ is_state('script.say_greeting', 'off') }}"
    - service: script.say_greeting
      data_template:
        entity_id: "media_player.livingroom"
        person: >
          {{ trigger.to_state.name }}
          {%- for s in states.binary_sensor
                |rejectattr('entity_id','eq',trigger.entity_id)
                |selectattr('state','eq','on')
                if '_home' in s.entity_id and
                   (now() - s.last_changed).total_seconds() < 105 -%}
            {{ (' and ' if loop.last else ', ') ~ s.name }}
          {%- endfor %}
        message: >
          {{ ["Hey there PERSON Welcome Home, during your stay, don't be a azzhole!",
              "Sometimes you feel like a nut, Sometimes you don't, Sometimes you feel like PERSON, l o l  Welcome Back",
              "Hello PERSON, damn, I wonder, how many peopl, we can fit in this, tiny house?",
              "Welcome back PERSON, Do you know what a gay cow eats? ,. ., . ,. ., ., ., ., .,  Heyaaaaaaaaaaaaaaa , ., ., ., .,   hahaha",
              "Welcome home PERSON, Did you hear about the crook who stole a calendar? He got twelve months.",
              "Welcome home PERSON,  I asked God for a bike, but I know God doesn’t work that way. So I stole a bike and asked for forgiveness.",
              "Welcome home PERSON,  I want to die peacefully in my sleep, like my grandfather.. Not screaming and yelling like the passengers in his car",
              "Welcome home PERSON, Sex is not the answer. Sex is the question. Yes, is the answer.",
              "Welcome home PERSON, The last thing I want to do is hurt you. But it’s still on the list",
              "Welcome home PERSON, We live in a society where pizza gets to your house before the police",
              "Welcome home PERSON, Light travels faster than sound. This is why some people appear bright until you hear them speak",
              "Welcome home PERSON, If I agreed with you we’d both be wrong",
              "Welcome home PERSON, We never really grow up, we only learn how to act in public",
              "Welcome home PERSON, Having sex is like playing bridge. If you don’t have a good partner, you’d better have a good hand",
              "Welcome home PERSON, War does not determine who is right , only who is left",
              "Welcome home PERSON, Knowledge is knowing a tomato is a fruit, Wisdom is not putting it in a fruit salad",
              "Welcome home PERSON, Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason",
              "Welcome home PERSON, Going to church doesn’t make you a Christian any more than standing in a garage makes you a car",
              "Welcome home PERSON, The early bird might get the worm, but the second mouse gets the cheese",
              "Welcome home PERSON, Children, You spend the first 2 years of their life teaching them to walk and talk. Then you spend the next 16 years telling them to sit down and shut-up",
              "Welcome home PERSON, My mother never saw the irony in calling me a son-of-a-bitch",
              "Welcome home PERSON, Evening news is where they begin with, Good evening, and then proceed to tell you why it isnt.",
              "Welcome home PERSON, If sex is a pain in the ass, then you’re doing it wrong",
              "Welcome home PERSON, If you think nobody cares if you’re alive, try missing a couple of payments",
              "Welcome home PERSON, Better to remain silent and be thought a fool, than to speak and remove all doubt",
              "Welcome home PERSON, If God is watching us, the least we can do is be entertaining",
              "Welcome home PERSON, If 4 out of 5 people SUFFER from diarrhea, does that mean that one enjoys it?",
              "Welcome home PERSON, To steal ideas from one person is plagiarism. To steal from many is research",
              "Welcome home PERSON, I thought I wanted a career, turns out I just wanted paychecks",
              "Welcome home PERSON, Some people are like Slinkies, not really good for anything, but you can’t help smiling when you see one tumble down the stairs",
              "Welcome home PERSON, Never, under any circumstances, take a sleeping pill and a laxative on the same night",
              "Welcome home PERSON, How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?",
              "Welcome home PERSON, Did you know that dolphins are so smart that within a few weeks of captivity, they can train people to stand on the very edge of the pool and throw them fish?",
              "Welcome home PERSON, I didn’t fight my way to the top of the food chain to be a vegetarian",
              "Welcome home PERSON, A bank is a place that will lend you money, if you can prove that you do not need it",
              "Welcome home PERSON, A computer once beat me at chess, but it was no match for me at kick boxing",
              "Welcome home PERSON, Why does someone believe you when you say there are four billion stars, but check when you say the paint is wet?",
              "Welcome home PERSON, Women will never be equal to men until they can walk down the street with a bald head and a beer gut, and still think they are sexy",
              "Welcome home PERSON, Whenever I fill out an application, in the part that says, If an emergency, notify, I put doctor,  Whats my mother going to do?",
              "Welcome home PERSON, A clear conscience is usually the sign of a bad memory",
              "Welcome home PERSON, The shinbone is a device for finding furniture in a dark room",
              "Welcome home PERSON, I didn’t say it was your fault, I said I was blaming you",
              "Welcome home PERSON, God must love stupid people. He made SO many, do you hear what i am laying down PERSON",
              "Welcome home PERSON, The voices in my head may not be real, but they have some good ideas",
              "Welcome home PERSON, Laugh at your problems, everybody else does",
              "Welcome home PERSON, Artificial intelligence is no match for natural stupidity",
              "Welcome home PERSON, Crowded elevators smell different to midgets",
              "Welcome home PERSON, The sole purpose of a childs middle name, is so he can tell when hes really in trouble",
              "Welcome home PERSON, Always borrow money from a pessimist. He won’t expect it back",
              "Welcome home PERSON, He who smiles in a crisis ...... has found someone to blame",
              "Welcome home PERSON, You do not need a parachute to skydive ...... You only need a parachute to skydive twice",
              "Welcome home PERSON, It’s not the fall that kills you ...... it’s the sudden stop at the end",
              "Welcome home PERSON, Some people say, If you can’t beat them, join them. I say, If you can’t beat them, beat them, because they will be expecting you to join them, so you will have the element of surprise",
              "Welcome home PERSON, Why do Americans choose from just two people to run for president .... and 50 for Miss America?",
              "Welcome home PERSON, My opinions may have changed .... but not the fact that .... I am always right says Wendy",
              "Welcome home PERSON, We have enough gun control .... What we need is idiot control .... cough .... cough .... trump",
              "Welcome home PERSON, Some cause happiness wherever they go ... ... Others whenever they go",
              "Welcome home PERSON, My psychiatrist told me I was crazy .... and I said I want a second opinion .... He said okay .... you’re ugly too",
              "Welcome home PERSON, Worrying works .... 90% of the things I worry about .... never happen .... says Wendy .... all day everyday",
              "Welcome home PERSON, I always take life with a grain of salt .... plus a slice of lemon .... and a shot of tequila",
              "Welcome home PERSON, Just remember .... if the world didn’t suck .... we’d all fall off",
              "Welcome home PERSON, I used to be indecisive .......... Now I’m not sure",
              "Welcome home PERSON, Jesus loves you .... but everyone else ..... thinks you’re an asshole",
              "Welcome home PERSON, Did you know that, Squirrels are nature’s speed bumps?",
              "Welcome home PERSON, Two antennas met on a roof ..... fell in love and got married ...... The ceremony wasn’t much ..... but the reception was excellent."
              "Welcome home PERSON, Being in a nudist colony .... probably takes all the fun out of Halloween",
              "Welcome home PERSON, Married men live longer than single men ...... but they’re a lot more willing to die",
              "Welcome home PERSON, If you go to sleep with a itching azz ...... you will wake up with a stinking finger",
              "Welcome home PERSON, We are all time travelers moving at the speed of exactly 60 minutes per hour",
              "Welcome home PERSON, I bet you, I could stop gambling",
              "Welcome home PERSON, Should crematoriums give discounts .... for burn victims",
              "Welcome home PERSON, Everyone has the right to be stupid, but you are abusing the privilege",
              "Welcome home PERSON, If the number two pencil is the most popular ..... why is it still number two",
              "Welcome home PERSON, I was thinking about how people seem to read the Bible a whole lot more as they get older. Then it dawned on me, they were cramming for their finals",
              "Welcome home PERSON, Constipated people .... don’t give a crap",
              "Welcome home PERSON, If a turtle doesn’t have a shell, is he homeless or naked",
              "Welcome home PERSON, I’m in shape...... Round is a shape isn’t it",
              "Welcome home PERSON, Just about the time when you think you can make ends meet, somebody moves the ends",
              "Welcome home PERSON, If Wal-Mart is lowering prices every day, why isn’t anything in the store is free yet",
              "Welcome home PERSON, What has four legs and an arm? A happy pit bull",
              "Welcome home PERSON, 1 in 5 people in the world are Chinese. There are 5 people in my family, so it must be one of them. It’s either my mom, or my, dad, Or my older brother Cameron, Or my younger brother Ho-Cha-Chu, But I think it’s Cameron",
              "Welcome, to the, Hotel, California, PERSON",
              "Welcome home PERSON, Call me Buffy ... because that's what I slay like",
              "Welcome home PERSON, Gucci Gang, Gucci Gang, Gucci Gang",
              "Welcome home PERSON, Employee of the month is a good example of how somebody can be both a winner and a loser at the same time",
              "Welcome home PERSON, I don’t have a girlfriend, but I know a girl that would get really mad if she heard me say that",
              "Welcome home PERSON, My drug test came back negative. My dealer sure has some explaining to do",
              "Welcome home PERSON, I have 3 kids and no money, why I can’t I have no kids and 3 money",
              "Welcome home PERSON, I think it’s wrong that only one company ... makes the game Monopoly",
              "Welcome home PERSON, My therapist says I have a preoccupation with vengeance ............ We’ll see about that ......... insert evil laugh ...... ha ha ha",
              "Welcome home PERSON, Words of wisdom ...... The worst time to have a heart attack ... is during a game of charades",
              "Welcome home PERSON, I have the world’s largest collection of seashells ...... you may have seen it ...... I keep it scattered on beaches all over",
              "Welcome home PERSON, The problem isn’t that obesity runs in your family ......... The problem is no one ..... runs in your family",
              "Welcome home PERSON, When you look like I do, it’s hard to get a table for one at chuckee cheese",
              "Welcome home PERSON, My ex girlfriend had this really weird fetish ....... She used to like to dress up like herself ..... and act like a fucking bitch all the time",
              "Welcome home PERSON, Circumcision is popular because ......... Jewish girls won’t touch anything ..... that’s not at least 15% off",
              "Welcome home PERSON, I have a friend ... He keeps trying to convince me he’s a compulsive liar ......  but I don’t believe him",
              "Welcome home PERSON, I have a lot of growing up to do ........... I realized that the other day inside my fort",
              "Welcome home PERSON, I taught Sunday School for two years ... And I got fired ..... I abused my authority ...... I used to teach class like this ..... OK, if one more person talks, everybody is   ... going to Hell",
              "Welcome home PERSON, It’s not that I’m afraid to die, I just don’t want to be there when it happens"
              "Welcome home PERSON, According to most studies ..... people’s number one fear is public speaking ....... Number two is death ..... Death is number two? ....... Does that sound right? ...... This means to the average person ... if you go to a funeral ... you’re better off in the casket than doing the eulogy"
             ] | random }}

script.yaml

say_greeting:
  sequence:
    service: media_player.alexa_tts
    data_template:
      entity_id: "{{ entity_id }}"
      message: "{{ message.replace('PERSON',person) }}"

I do use this with my Alexa TTS

4 Likes

I think you just need to get rid of the quotes. Like this:

action:
- service: tts.google_say
  entity_id: media_player.living_room_home
  data_template:
    message: >
      {{ ["OK", "Sure", "If you insist", "Done"] | random }}
2 Likes

Oh I’ll give that a go.
That was someone else’s example but didn’t work.

This works fine for me, same as above;

- alias: Say good night
  initial_state: true
  trigger:
    platform: state
    entity_id: switch.table_light
    to: 'off'
  action:
    service: tts.google_say
    entity_id: media_player.speaker_1
    data_template:
      message: '{{ [ "Good night. " , "Good evening. " , "Sweet dreams. " , "See you
        tomorrow. " , "Have a wonderful night. " , "See you in the morning. " ] |random }}'

Hi Corey

What are you using to have a person setup as a binary_sensor?

Thanks

Klint

I’m not using person.

I use my Home kit to trigger the binary_sensor when anybody comes home.

I created binary_sensors in HA then created switches that activated the binary_sensors and place the Switches in HomeKit. From HomeKit I made automations for each person so upon entering or leaving those switches turn on or off.

If you want to use person you should be able to change the ‘on’ part in the automation to ‘home’, that should do it. Let me know how it goes!!

Thanks will do, spent a few hours tonight, without much success, using Google mini instead of Alexa.
Hopefully have it working tomorrow.

Thanks for reply.

So the including behind the tts message: is not working anymore? I tried it but it reads just the text so !include messages.yaml

@Corey_Maxim
I am studying your script trying to follow the logic. You are giving each person about 4 minutes to arrive home before Alexa will start its message?

Yes, this gives us time to walk into the house.

Just wandering,
automation does not work for me when I’m using platform: zone and person entities,
however there is no problem when i use platform: state insteed.

Does zoes are working for you?

How would you setup notification when somone is leaving the office zone (not home)?

I’m sorry I missed this.

I use this setup along with HomeKit on my phone to track the devices.

I have dummy switches in HomeKit that turn on or off depending on the person. Homeassistant waits for the switch to turn then runs the script & automation

1 Like

Very nice! Very impressive actually.
I was wondering if we can have template (sensors) within template ???
Something like this for example

"data":
  "type": "tts"
"message": "{{ [
      'Hello! What shall we eat tonight?',
      'Hi! I was bored here all day alone',
      'Glad to have you back. Hope you had a busy day',
      'Hello again. Its getting dark and the temperature is pretty low',
      'Hello. You are late and I was about to make you dinner',
      'Ciao bella! The humidity is {{ states('sensor.humidity_outdoor') }} %',
      'Good evening. Nice to have you back. The outdoor temperature is {{ states('sensor.temperature_outdoor') }} Celsius',
      'Hello! The weather its {{ states('weather.spiti') }} and the temperature is {{ states('sensor.temperature_outdoor') }} Celsius'      
      ] | random }}"
1 Like

Hey did you even get anywhere with that?

Also looking for a solution to this.
I want to pass the outputs of some blueprinted automations to a notification so want to mixup the messages a bit.