How to set speech language of intent_script

There is an example I found somewhere online:

conversation:
  intents:
    YearOfVoice:
      - "how is the year of voice going"

intent_script:
  YearOfVoice:
    speech:
      text: "Great! We're at over 40 languages and counting."

Which adds a custom sentence and response. But it doesn’t tell HA which language these sentences and responses are written in, so I guess it will use the language of HA.

Is it possible to specify the language of both sentences and responses in the above settings? (Since I use multiple languages myself)

It seems I can’t set language in the above settings, so I tried the following:

#/config/custom_sentences/en/example.yaml
language: "en"
intents:
  ExampleIntent:
    data:
      - sentences:
          - "do you love me"
        response: "default"

#/config/custom_sentences/en/example_responses.yaml
language: "en"
responses:
  intents:
    ExampleIntent:
      default: "of course baby"

But I got the following error:

There are a few issues in your yaml files:
In example.yaml remove the “response:” line. The remaining lines should be fine.

Put the following lines into your configuration.yaml file and delete the example_responses.yaml file.

intent_script:
  ExampleIntent:
    speech:
      text: of course baby

This should work.

1 Like

I use multiple languages. This will only work for English.

You need to create a second custom_sentences file. Example for German where you put it into the “custom_sentences/de” folder:

#/config/custom_sentences/de/example.yaml
language: "de"
intents:
  ExampleIntentDE:
    data:
      - sentences:
          - "Liebst du mich"

And add it to your configuration.yaml

intent_script:
  ExampleIntent:
    speech:
      text: of course baby
  ExampleIntentDE:
    speech:
      text: na klar mein schatz

That’s how I would do it with the knowledge I currently have regarding assist.

Thank you! Your solution works!

But it doesn’t seem natural. Please take a look at this doc:

# Example config/custom_sentences/en/responses.yaml
language: "en"
responses:
  intents:
    HassTurnOn:
      default: "I have turned on the {{ slots.name }}"

If people can custom responses for built-in intents, then I think this should also work for custom ones.

You’re right, and here’s how you should go about it:

#/config/custom_sentences/en/example.yaml
language: "en"
intents:
  ExampleIntent:
    data:
      - sentences:
          - "do you love me"
        response: "default"
#/config/custom_sentences/de/example.yaml
language: "de"
intents:
  ExampleIntent:
    data:
      - sentences:
          - "liebst du mich"
        response: "default"
#/config/custom_sentences/en/responses.yaml
language: en
responses:
  intents:
    ExampleIntent:
      default: "of course"
#/config/custom_sentences/de/responses.yaml
language: de
responses:
  intents:
    ExampleIntent:
      default: "jawohl"

But there has to be something in the intent_script for ExampleIntent

intent_script:
  ExampleIntent:
    action:
      - service: script.do_the_twist

Does the filename have to be responses?

No. In fact, you can actually place the entire responses: tree in the same file as the sentences. Something like:

#/config/custom_sentences/de/example_intent.yaml
language: de
responses:
  ...
intents:
  ...
1 Like