Overview
Package tts is Home Assistant's tts domain: its types.
Entity controls one tts entity over HTTP.
No method for tts.clear_cache, tts.cloud_say and tts.demo_say, which target no entity: call api.Client.CallService.
Home Assistant documents the domain here:
Integration: https://www.home-assistant.io/integrations/tts/
Entity model (developers): https://contributors.home-assistant.io/core/entities/tts/
Control
// client is an *api.Client
target := tts.Get(client, "my_tts")
state, err := target.State(ctx)
err = target.Speak(ctx)
Commands
What each Entity method does on each transport. Home Assistant has no MQTT discovery for this domain.
| Method | Over HTTP, calls |
|---|---|
Speak |
tts.speak |
Services without a method
Call these with the REST or WebSocket client.
| Service | Why |
|---|---|
tts.clear_cache | it targets no entity |
tts.cloud_say | it targets no entity |
tts.demo_say | it targets no entity |
Control
type Entity struct
Entity controls one tts entity over HTTP (api.Client). State and Subscribe come from the embedded Handle.
Embeds entity.Handle[Attributes], whose methods it has too.
func Get(transport entity.Transport, id string) *Entity
Get returns the tts entity with the given id: an entity id over HTTP (the "tts." prefix may be omitted). It does no I/O.
func List(ctx context.Context, transport entity.Transport) ([]*Entity, error)
List returns every tts entity the transport can see.
func (e *Entity) Speak(ctx context.Context, options ...entity.ServiceOption) error
Speak calls tts.speak. It has no MQTT equivalent. Core describes the service: Speaks something using text-to-speech on a media player.
type State = entity.State[Attributes]
State is a snapshot of one tts entity.
func Cache(value bool) entity.ServiceOption
Cache sets the "cache" service data field.
func Language(value string) entity.ServiceOption
Language sets the "language" service data field.
func MediaPlayerEntityId(value string) entity.ServiceOption
MediaPlayerEntityId sets the "media_player_entity_id" service data field.
func Message(value string) entity.ServiceOption
Message sets the "message" service data field.
func Options(value map[string]any) entity.ServiceOption
Options sets the "options" service data field.
State and values
type Attributes struct
Attributes are the state attributes of a tts entity, under the names Home Assistant publishes them with.
type Voice struct
Voice is core's Voice.
See: https://www.home-assistant.io/integrations/tts/
| Field | Type | Wire key | Description |
|---|---|---|---|
Name | string | name | |
VoiceId | string | voice_id |