Transition over to OPENAi speech. #1368

This commit is contained in:
CCOSTAN 2024-05-24 14:07:49 +00:00
parent 311f6f5039
commit 1ce3d22013
5 changed files with 30 additions and 10 deletions

0
config/automations.yaml Executable file → Normal file
View File

View File

@ -2,3 +2,4 @@ MQTT:
entities: entities:
- sensor.medicine_time - sensor.medicine_time
- sensor.last_message - sensor.last_message
- sensor.last_ai_message

View File

@ -19,6 +19,9 @@ mqtt:
sensor: sensor:
- state_topic: "polly/lastmsg" - state_topic: "polly/lastmsg"
name: "Last Message" name: "Last Message"
- state_topic: "polly/lastmsg_openai"
name: "Last AI Message"
############################################################################## ##############################################################################
### Automations - ### Automations -
@ -34,18 +37,19 @@ automation:
to: 'on' to: 'on'
action: action:
- service: tts.amazon_polly_say - service: tts.cloud_say
entity_id: entity_id:
- media_player.livingroomCC - media_player.livingroomCC
- media_player.entry_alarm_panel - media_player.entry_alarm_panel
- media_player.bedroom_alarm_panel - media_player.bedroom_alarm_panel
data: data:
message: > options:
<speak> voice: JennyNeural
{{states.sensor.last_message.state}} message: >-
</speak> {{states.sensor.last_ai_message.state}}
cache: true cache: false
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: entity_id:
- input_boolean.lastmsg - input_boolean.lastmsg

View File

@ -41,6 +41,7 @@ exclude:
- sensor.ha_uptime - sensor.ha_uptime
- sensor.large_garage_door_since - sensor.large_garage_door_since
- sensor.last_message - sensor.last_message
- sensor.last_ai_message
- sensor.low_battery - sensor.low_battery
- sensor.medicine_time - sensor.medicine_time
- sensor.network - sensor.network

View File

@ -14,7 +14,7 @@ speech_processing:
- service: mqtt.publish - service: mqtt.publish
data: data:
topic: 'polly/lastmsg' topic: 'polly/lastmsg'
payload: "This message is from {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ speech_message | striptags | truncate(220)}}" payload: "Message: {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ speech_message | striptags | truncate(220)}}"
retain: true retain: true
- condition: and - condition: and
@ -53,11 +53,11 @@ speech_processing:
{{ media_player }} {{ media_player }}
volume_level: >- volume_level: >-
{% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %} {% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %}
0.3 0.2
{% elif now().strftime('%H')|int > 12 and now().strftime('%H')|int < 20 %} {% elif now().strftime('%H')|int > 12 and now().strftime('%H')|int < 20 %}
0.3 0.3
{% else %} {% else %}
0.3 0.2
{% endif %} {% endif %}
# - service: tts.amazon_polly_say # - service: tts.amazon_polly_say
@ -71,15 +71,29 @@ speech_processing:
# </speak> # </speak>
# cache: true # cache: true
- service: conversation.process
data:
agent_id: conversation.openai_conversation
text: >-
Please take the following system generated information and review and relay the information as yourself. There should be no followups in your response since this is a broadcast only. Here is the information:
{{ speech_message }}
response_variable: agent
- service: tts.cloud_say - service: tts.cloud_say
data: data:
entity_id: media_player.livingroomCC entity_id: media_player.livingroomCC
options: options:
voice: JennyNeural voice: JennyNeural
message: >- message: >-
{{ speech_message }} {{ agent.response.speech.plain.speech }}
cache: true cache: true
- service: mqtt.publish
data:
topic: 'polly/lastmsg_openai'
payload: "Message: {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ agent.response.speech.plain.speech | striptags | truncate(220)}}"
retain: true
- service: input_boolean.turn_off - service: input_boolean.turn_off
data: data:
entity_id: entity_id: