|
1 | | -#------------------------------------------- |
2 | | -# Speech Processing Script |
3 | | -# Description: Sends notifications to ChromeCast Audio devices |
4 | | -# |
5 | | -# Features: |
6 | | -# - Operates during specified hours |
7 | | -# - Activates when family is home or guest/vacation mode is on |
8 | | -# - Adjustable volume based on time of day |
9 | | -# |
10 | | -# Usage: |
11 | | -# action: |
12 | | -# service: script.speech_engine |
13 | | -# data: |
14 | | -# media_player: [target_media_player] |
15 | | -# speech_message: [message_to_speak] |
16 | | -# |
17 | | -# Original Repo: https://github.com/CCOSTAN/Home-AssistantConfig |
18 | | -# Follow me on https://www.vcloudinfo.com/click-here |
19 | | -#------------------------------------------- |
| 1 | +###################################################################### |
| 2 | +# @CCOSTAN - Follow Me on X |
| 3 | +# For more info visit https://www.vcloudinfo.com/click-here |
| 4 | +# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig |
| 5 | +# ------------------------------------------------------------------- |
| 6 | +# Speech Processing Script - shared spoken announcement delivery |
| 7 | +# Sends OpenAI-polished speech to Chromecast targets and routed Echo announcements. |
| 8 | +# ------------------------------------------------------------------- |
| 9 | +# Related Issue: 798 |
| 10 | +# Notes: Operates only when family/guest/vacation and speech notification |
| 11 | +# guards allow it, with time-aware volume. |
| 12 | +# Notes: Garage Echo is an always-on announcement target. Office Echo is |
| 13 | +# added when switch.office_lamp_switch is on, which tracks active PC work. |
| 14 | +###################################################################### |
20 | 15 |
|
21 | 16 | speech_processing: |
22 | 17 | mode: queued |
@@ -79,18 +74,50 @@ speech_processing: |
79 | 74 | {{ speech_message }} |
80 | 75 | response_variable: agent |
81 | 76 |
|
| 77 | + - variables: |
| 78 | + speech_response: "{{ agent.response.speech.plain.speech }}" |
| 79 | + routed_media_players: "{{ media_player | string | lower }}" |
| 80 | + |
82 | 81 | - service: tts.cloud_say |
83 | 82 | data: |
84 | | - entity_id: media_player.livingroomCC |
| 83 | + entity_id: > |
| 84 | + {{ media_player }} |
85 | 85 | options: |
86 | 86 | voice: JennyNeural |
87 | 87 | message: >- |
88 | | - {{ agent.response.speech.plain.speech }} |
| 88 | + {{ speech_response }} |
89 | 89 | cache: false |
90 | 90 |
|
| 91 | + - choose: |
| 92 | + - conditions: |
| 93 | + - condition: template |
| 94 | + value_template: "{{ 'media_player.garage' not in routed_media_players }}" |
| 95 | + sequence: |
| 96 | + - service: notify.alexa_media_garage |
| 97 | + continue_on_error: true |
| 98 | + data: |
| 99 | + message: "{{ speech_response }}" |
| 100 | + data: |
| 101 | + type: announce |
| 102 | + |
| 103 | + - choose: |
| 104 | + - conditions: |
| 105 | + - condition: state |
| 106 | + entity_id: switch.office_lamp_switch |
| 107 | + state: 'on' |
| 108 | + - condition: template |
| 109 | + value_template: "{{ 'media_player.office' not in routed_media_players }}" |
| 110 | + sequence: |
| 111 | + - service: notify.alexa_media_office |
| 112 | + continue_on_error: true |
| 113 | + data: |
| 114 | + message: "{{ speech_response }}" |
| 115 | + data: |
| 116 | + type: announce |
| 117 | + |
91 | 118 | - event: openai_response |
92 | 119 | event_data: |
93 | | - response: "{{ now().strftime('%B %d,%Y %-I:%M %p') }} {{ agent.response.speech.plain.speech }}" |
| 120 | + response: "{{ now().strftime('%B %d,%Y %-I:%M %p') }} {{ speech_response }}" |
94 | 121 |
|
95 | 122 | - service: input_boolean.turn_off |
96 | 123 | data: |
|
0 commit comments