feat: implement /speaker endpoint for TTS and URL playback

- Add PlayInfo model for TTS and URL content playback requests
- Add SpeakerResponse model for endpoint responses
- Implement client methods: PlayTTS, PlayURL, PlayCustom, PlayNotificationBeep
- Add comprehensive CLI commands for speaker functionality:
  - speaker tts: Text-to-Speech with Google TTS and language support
  - speaker url: Audio content playback from HTTP/HTTPS URLs
  - speaker beep: Simple notification beep sound
  - speaker help: Detailed functionality documentation
- Support for volume control (0-100 or current volume)
- Multi-language TTS support (EN, DE, ES, FR, IT, NL, PT, RU, ZH, JA, etc.)
- Custom metadata support for NowPlaying display
- Comprehensive validation and error handling
- Full test suite with XML marshaling/unmarshaling tests
- Complete documentation with API reference and usage examples
- Compatible with ST-10 (Series III) and other supported SoundTouch devices

The /speaker endpoint enables notification and audio content playback,
automatically managing volume restoration and content interruption.
Perfect for home automation, alerts, and custom audio notifications.
This commit is contained in:
Tobias Gesellchen
2026-02-01 23:21:15 +01:00
parent a008093775
commit 3a33cadbd7
6 changed files with 1109 additions and 0 deletions
+41
View File
@@ -1643,3 +1643,44 @@ func (c *Client) hasCapability(capabilities *models.Capabilities, capability str
capStr := fmt.Sprintf("%+v", capabilities)
return strings.Contains(capStr, capability)
}
// PlayTTS plays a Text-To-Speech message using Google TTS on the speaker
func (c *Client) PlayTTS(text, appKey string, volume ...int) error {
playInfo := models.NewTTSPlayInfo(text, appKey, volume...)
if err := playInfo.Validate(); err != nil {
return fmt.Errorf("invalid TTS request: %w", err)
}
return c.postPlayInfo(playInfo)
}
// PlayURL plays audio content from a URL on the speaker
func (c *Client) PlayURL(url, appKey, service, message, reason string, volume ...int) error {
playInfo := models.NewURLPlayInfo(url, appKey, service, message, reason, volume...)
if err := playInfo.Validate(); err != nil {
return fmt.Errorf("invalid URL play request: %w", err)
}
return c.postPlayInfo(playInfo)
}
// PlayCustom plays custom content using a PlayInfo configuration
func (c *Client) PlayCustom(playInfo *models.PlayInfo) error {
if err := playInfo.Validate(); err != nil {
return fmt.Errorf("invalid play request: %w", err)
}
return c.postPlayInfo(playInfo)
}
// PlayNotificationBeep plays a notification beep on the device
func (c *Client) PlayNotificationBeep() error {
return c.post("/playNotification", nil)
}
// postPlayInfo sends a PlayInfo request to the /speaker endpoint
func (c *Client) postPlayInfo(playInfo *models.PlayInfo) error {
return c.post("/speaker", playInfo)
}