Sonos¶
Scripts¶
tts.py.example¶
This script creates a rule that will trigger when a StringItem is updated and speak the string as TTS.
greeting.py.example¶
This script speaks a random greeting every minute on your Sonos speaker system.
To use this, you should set up astro.py as described in
Mode (Time of Day). It also
assumes that you’ve set up an openHAB ContactItems to represent the presence of
people to be greeted. Each of the Items should belong to the group
G_Presence_Family
. Finally, make sure that you add the contents of the
configuration.py.example
file into your own configuration.py
file.
Packages and Modules¶
playSound¶
This module provides functions for playing sounds.
-
community.sonos.playSound.
playsound
(fileName, ttsPrio=1, **keywords)¶ Play a sound mp3 file function. First argument is positional and mandatory. Remaining arguments are optionally keyword arguments.
Examples
playsound("Hello.mp3") playsound("Hello.mp3", PRIO['HIGH'], room='Kitchen', volume=42)
- Parameters
fileName (str) – Sound file name to play (files need to be put in the folder
/conf/sounds/
)ttsPrio (str) – (optional) priority as defined by PRIO (defaults to PRIO[‘MODERATE’])
**keywords –
room
(room to play in defaults toAll
) andttsVol
(volume)
- Returns
True
, if sound was sent, elseFalse
- Return type
bool
speak¶
This module provides functions for use with TTS.
-
community.sonos.speak.
tts
(ttsSay, ttsPrio=1, **keywords)¶ Text To Speak function. First argument is positional and mandatory. Remaining arguments are optionally keyword arguments.
Examples
tts("Hello") tts("Hello", PRIO['HIGH'], ttsRoom='Kitchen', ttsVol=42, ttsLang='en-GB', ttsVoice='Brian')
- Parameters
ttsSay (str) – text to speak
ttsPrio (str) – (optional) priority as defined by PRIO (defaults to PRIO[‘MODERATE’])
**keywords –
ttsRoom
(room to speak in),ttsVol
(volume),ttsLang
(language),ttsVoice
(voice),ttsEngine
(engine)
- Returns
True
, if sound was sent, elseFalse
- Return type
bool