Skip to content

Commit 8e64d2b

Browse files
author
Daniel Dunn
committed
✨ Speak command that useds the new globally configured TTS model.
1 parent 8d46595 commit 8e64d2b

File tree

9 files changed

+456
-1
lines changed

9 files changed

+456
-1
lines changed

kaithem/api/settings.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,16 @@ def add_val(
1616
):
1717
"""Add a config option. If value is empty string, remove it instead."""
1818
return settings_overrides.add_val(key, value, source, priority)
19+
20+
21+
def add_suggestion(key: str, value: str, description: str = ""):
22+
"""Add a suggestion for the given key"""
23+
return settings_overrides.add_suggestion(key, value, description)
24+
25+
26+
def clear_suggestions(key: str):
27+
return settings_overrides.clear_suggestions(key)
28+
29+
30+
def set_description(key: str, description: str):
31+
return settings_overrides.set_description(key, description)

kaithem/api/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ def lorem() -> str:
2121
def get_logdir() -> str:
2222
"""Get the user and machine specific log directory"""
2323
return directories.logdir
24+
25+
26+
def get_vardir() -> str:
27+
"""Get the main kaithem storage dir"""
28+
return directories.vardir

kaithem/data/default_configuration.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ core/apprise_target: ""
154154
core_plugin_map_tile_server/max_age_days: 100
155155
core_plugin_map_tile_server/cache_size_mb: 32000
156156

157+
core_plugin_tts/default_model: ""
158+
core_plugin_tts/default_speaker: 0
157159

158160
#####################MISC#######################################################
159161

kaithem/src/chandler/group_context_commands.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,18 @@ def uiNotificationCommand(text: str):
5656
"Send a notification to the operator, on the web editor and console pages"
5757

5858

59+
def speak(text: str = "Hello World!", speaker="0", speed="1"):
60+
"BETA. Use the default text to speech model. Speaker is the number for multi-voice models."
61+
62+
5963
rootContext.commands["shortcut"] = codeCommand
6064
rootContext.commands["goto"] = gotoCommand
6165
rootContext.commands["set_alpha"] = setAlphaCommand
6266
rootContext.commands["if_cue"] = ifCueCommand
6367
rootContext.commands["send_event"] = eventCommand
6468
rootContext.commands["set_slideshow_variable"] = setWebVarCommand
6569
rootContext.commands["console_notification"] = uiNotificationCommand
70+
rootContext.commands["speak"] = speak
6671

6772

6873
def sendMqttMessage(topic: str, message: str):
@@ -217,13 +222,27 @@ def uiNotificationCommand(text: str):
217222
lambda s: s.linkSend(["ui_alert", text])
218223
)
219224

225+
def speak(text: str = "Hello World!", speaker="0", speed="1"):
226+
"BETA. Use the default text to speech model. Speaker is the number for multi-voice models."
227+
from kaithem.src.plugins.CorePluginTTS import get_model
228+
229+
m = get_model()
230+
if m:
231+
m.speak(
232+
str(text)[:1024],
233+
speed=float(speed),
234+
sid=int(speaker),
235+
device=context_group.sound_output,
236+
)
237+
220238
cc["shortcut"] = codeCommand
221239
cc["goto"] = gotoCommand
222240
cc["set_alpha"] = setAlphaCommand
223241
cc["if_cue"] = ifCueCommand
224242
cc["send_event"] = eventCommand
225243
cc["set_slideshow_variable"] = setWebVarCommand
226244
cc["console_notification"] = uiNotificationCommand
245+
cc["speak"] = speak
227246

228247
# cc["set_tag"].completionTags = {"tagName": "tagPointsCompleter"}
229248

kaithem/src/docs/changes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ Change Log
44

55
### 0.89.0
66

7+
This release has one of the first AI features! We use sherpa-onnx and and automatically download models.
8+
79
- :sparkles: New system tag points and default alarms for hdmi port connection(/system/display_ports/hdmi_1.connected)
810
- :sparkles: Stateful blocks like on_change in the visual logic editor.
11+
- :sparkles: Speak command that useds the new globally configured TTS model.
912
- :bug: Fix web media not rendering without login
1013
- :bug: Fix mixer sort issue and use fixed width num param fields
1114

0 commit comments

Comments
 (0)