[SOLVED] Say() issues using SONOS audiosink and PollyTTS

Running WIN10, OH 2.2.0

Cannot get following working and NO READ IN LOG

say("Kinder",  "pollytts:Marlene", "sonos:CONNECTAMP:Esszimmer")

What works:

say("Kinder")

using from PaperUI: same Sonos player as default audiosink, Polly TTS Engine, Marlene.

Read for this one in log:

21:24:41.300 [DEBUG] [ice.pollytts.internal.PollyTTSService] - voice UID: 'pollytts:Marlene'   voice Label: 'Marlene'  voice Locale: de_DE
21:24:41.363 [DEBUG] [api.CachedPollyTTSCloudImplementation] - PollyTTS cache cleaner lastdelete 32930895
21:24:41.394 [DEBUG] [ice.pollytts.internal.PollyTTSService] - Audio Stream for 'Kinder' in format AudioFormat [codec=MP3, container=NONE, bitDepth=16, bitRate=64000, frequency=22050]

Q: How to get the syntax right/define which sonos audiosink should be used in the say () command?

Much inspiration from many sources but did not find a solution:
OH Documentation Multimedia SAY()
that would state:

say("Hello world!", "voicerss:enUS", "sonos:PLAY5:kitchen")

Sonos Notification

items:

Group EZ_Sonos (Sonos)

Player EZ_Sonos_Control                 "Control"                   <sonos_control>      (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:control"}
String EZ_Sonos_CurrentAlbum            "Album [%s]"                <sonos_album>        (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:currentalbum"}
String EZ_Sonos_CurrentArtist           "Artist [%s]"               <sonos_artist>       (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:currentartist"}
String EZ_Sonos_CurrentTitle            "Title [%s]"                <sonos_title>        (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:currenttitle"}
String EZ_Sonos_CurrentTrack            "Track [%s]"                <sonos_track>        (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:currenttrack"}
Switch EZ_Sonos_Led                     "Led"                       <sonos_led>          (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:led"}
Switch EZ_Sonos_Mute                    "Mute"                      <sonos_mute>         (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:mute"}
String EZ_Sonos_NotificationSound       "Notification Sound [%s]"   <sonos_notification> (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:notificationsound"}
Dimmer EZ_Sonos_Notificationsoundvolume "Notification Sound Volume" <soundvolume>        (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:notificationvolume"}
String EZ_Sonos_State                   "State [%s]"                <sonos_state>        (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:state"}
Switch EZ_Sonos_Stop                    "Stop"                      <sonos_stop>         (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:stop", autoupdate="false"}
Dimmer EZ_Sonos_Volume                  "Volume"                    <soundvolume>        (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:volume"}
String EZ_Sonos_ZoneName                "Zone Name [%s]"            <sonos_zone>         (EZ_Sonos)            {channel="sonos:CONNECTAMP:Esszimmer:zonename"}

Sitemap works as well and updates.

Bundle:List

START LEVEL 100 , List Threshold: 50
 ID | State    | Lvl | Version                | Name
----+----------+-----+------------------------+------------------------------------------------------------------------------------------------------------
 15 | Active   |  80 | 5.3.1.201602281253     | OSGi JAX-RS Connector
 16 | Active   |  80 | 2.4.5                  | Jackson-annotations
 17 | Active   |  80 | 2.4.5                  | Jackson-core
 18 | Active   |  80 | 2.4.5                  | jackson-databind
 19 | Active   |  80 | 2.4.5                  | Jackson-dataformat-XML
 20 | Active   |  80 | 2.4.5                  | Jackson-dataformat-YAML
 21 | Active   |  80 | 2.4.5                  | Jackson-module-JAXB-annotations
 22 | Active   |  80 | 2.7.0                  | Gson
 23 | Active   |  80 | 18.0.0                 | Guava: Google Core Libraries for Java
 24 | Active   |  80 | 3.0.0.v201312141243    | Google Guice (No AOP)
 25 | Active   |  80 | 3.12.0.OH              | nrjavaserial
 26 | Active   |  80 | 1.5.8                  | swagger-annotations
 27 | Active   |  80 | 3.19.0.GA              | Javassist
 29 | Active   |  80 | 3.5.2                  | JmDNS
 32 | Active   |  80 | 1.1.0.Final            | Bean Validation API
 34 | Active   |  80 | 2.0.1                  | javax.ws.rs-api
 35 | Active   |  80 | 3.2.0.v201101311130    | ANTLR Runtime
 38 | Active   |  80 | 3.2.1                  | Commons Collections
 39 | Active   |  80 | 1.1                    | Commons Exec
 40 | Active   |  80 | 2.2.0                  | Commons IO
 41 | Active   |  80 | 2.6                    | Commons Lang
 51 | Active   |  80 | 4.1.3                  | Apache Karaf :: OSGi Services :: Event
 70 | Active   |  80 | 2.11.0.v20150805-0538  | EMF Common
 71 | Active   |  80 | 2.11.1.v20150805-0538  | EMF Ecore
 72 | Active   |  80 | 2.11.1.v20150805-0538  | EMF XML/XMI Persistence
 73 | Active   |  80 | 3.8.0.v20160509-1230   | Common Eclipse Runtime
 74 | Active   |  80 | 3.6.100.v20160223-2218 | Extension Registry Support
101 | Active   |  80 | 0.2.1.v20170706-0855   | org.eclipse.lsp4j
102 | Active   |  80 | 0.2.1.v20170706-0855   | org.eclipse.lsp4j.jsonrpc
103 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Config Core
104 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Configuration Discovery
105 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Configuration mDNS Discovery
106 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Config Dispatcher
107 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Config Serial
108 | Active   |  75 | 0.10.0.b1              | Eclipse SmartHome Config XML
109 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core
110 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core Audio
111 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome AutoUpdate Binding
112 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core Binding XML
113 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core ID
114 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core Persistence
115 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Scheduler Service
116 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core Thing
117 | Active   |  75 | 0.10.0.b1              | Eclipse SmartHome Core Thing XML
118 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Transformation Service
119 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core Voice
120 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Console
121 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Console for OSGi runtime Karaf
122 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome JavaSound I/O, Fragments: 188
123 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Monitor
124 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Net I/O Bundle
125 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome REST Interface Bundle
126 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Core REST API
127 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome REST mDNS Announcer
128 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome REST Interface JAX-RS optimization Bundle
129 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Sitemap REST API
130 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome SSE REST API
131 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Voice REST API
132 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Bonjour/MDS Service Discovery Bundle
133 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Web Audio Support
134 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Model Core
135 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Item Model
136 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Item Model IDE
137 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Item Model Runtime
138 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Language Server
139 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Persistence Model
140 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Persistence Model IDE
141 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Persistence Runtime
142 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Rule Model
143 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Rule Model IDE
144 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Rule Runtime
145 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Script
146 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Script Model IDE
147 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Script Runtime
148 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Sitemap Model
149 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Sitemap Model IDE
150 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Sitemap Runtime
151 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Thing Model
152 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Thing Model IDE
153 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Thing Model Runtime
154 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Json Storage Service
155 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome UI
156 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome UI Icons
157 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Classic IconSet
158 | Active   |  80 | 2.12.0.v20170518-0757  | Xtend Runtime Library
159 | Active   |  80 | 2.12.0.v20170518-0757  | Xtend Macro Interfaces
160 | Active   |  80 | 2.12.0.v20170518-0959  | Xtext
161 | Active   |  80 | 2.12.0.v20170519-0752  | Xtext Common Types
162 | Active   |  80 | 2.12.0.v20171017-1700  | Xtext IDE Core
163 | Active   |  80 | 2.12.0.v20170518-0959  | Xtext Utility
164 | Active   |  80 | 2.12.0.v20170519-0752  | Xbase Model
165 | Active   |  80 | 2.12.0.v20170519-0752  | Xbase Generic IDE Services
166 | Active   |  80 | 2.12.0.v20170518-0757  | Xbase Runtime Library
181 | Active   |  80 | 2.3.0                  | JUPnP Library
182 | Active   |  80 | 1.9.6                  | MIME streaming extension
183 | Active   |  80 | 5.0.2                  | Require-Bundle Fix :: org.objectweb.asm
185 | Active   |  90 | 2.2.0                  | openHAB Core
186 | Active   |  80 | 2.2.0                  | openHAB Karaf Integration
188 | Resolved |  80 | 2.2.0                  | openHAB Sound Support, Hosts: 122
189 | Active   |  80 | 2.2.0                  | openHAB Dashboard UI
194 | Active   |  80 | 3.1.4                  | Stax2 API
195 | Active   |  80 | 3.2.0                  | Commons Net
196 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Basic UI, Fragments: 198
197 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Paper UI, Fragments: 201
198 | Resolved |  75 | 2.2.0                  | openHAB Basic UI Fragment, Hosts: 196
199 | Active   |  80 | 2.2.0                  | HABPanel User Interface
200 | Active   |  80 | 2.2.0                  | HomeBuilder User Interface
201 | Resolved |  75 | 2.2.0                  | openHAB Paper UI Theme Fragment, Hosts: 197
202 | Active   |  80 | 1.6.0                  | Commons Codec
203 | Active   |  80 | 4.2.3                  | Apache HttpClient OSGi bundle
204 | Active   |  80 | 4.2.3                  | Apache HttpCore OSGi bundle
205 | Active   |  80 | 3.1.0.7                | Apache ServiceMix :: Bundles :: commons-httpclient
207 | Active   |  80 | 2.2.0                  | openHAB 1.x Compatibility Layer
208 | Active   |  80 | 2.2.0                  | openHAB Cloud Connector Bundle
216 | Active   |  80 | 2.3.0.201804102115     | Robonect Binding
217 | Active   |  80 | 1.11.0                 | openHAB HTTP Binding
218 | Active   |  80 | 1.11.0                 | openHAB Expire Binding
219 | Active   |  80 | 1.11.0                 | openHAB KNX Binding
220 | Active   |  80 | 2.2.0                  | Network Binding
224 | Active   |  80 | 0.10.0.b1              | WeatherUnderground Binding
234 | Active   |  80 | 2.2.0                  | Exec Binding
235 | Active   |  75 | 0.10.0.b1              | Eclipse SmartHome RegEx Transformation Service
236 | Active   |  75 | 0.10.0.b1              | Eclipse SmartHome Exec Transformation Service
237 | Active   |  75 | 0.10.0.b1              | Eclipse SmartHome Map Transformation Service
238 | Active   |  80 | 0.10.0.b1              | Astro Binding
240 | Active   |  80 | 2.2.0.201712061958     | PollyTSS Voice Service
244 | Active   |  80 | 0.10.0.b1              | Sonos Binding
245 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome Configuration UPnP Discovery
246 | Active   |  80 | 0.10.0.b1              | Eclipse SmartHome UPnP Transport Bundle

High

I’m presently on a bicycle-trip, so the connectivity to my OH instance is limited (only my smartphone…)
For the syntax to define an Audio sink I’m using the Thing definition as used on PaperUI.
Will post my “SaySomething” rule when back home(latest Monday). This rule can use different SonosPlayers as selected on HABPanel and will say the String which is stated in the Textbox.

Since I use VoiceRSS I can’t say anything about your used TTS service, however that seems to work.

(Edit)
I had posted that rule already, look:

Note that I changed the correct syntax of the Thing definitions in order to hide the correct numbers.

Hi, many thanks and have fun cycling :grinning:
I did see the rule before and played around with it but couldn’t get it to work. Let me try again and get back with more precise feedback.

I did have a closer look again at your “SaySomething” rule. Here is your version I had a look at (think this is the version you are referring to, no?) and my Qs:

val Number NotificationVolume = 20
rule "Say Something"

when 
  Item SayCommand received update
then
  var string AudioSink
  switch AudioSink {
    case Lautsprecher.state.toString=="Küche" : AudioSink="sonos:PLAY1:RINCON_xxx1400"
    case Lautsprecher.state.toString=="Wohnzimmer" : AudioSink="sonos:PLAY1:RINCON_yyy1400"
    case Lautsprecher.state.toString=="Gästezimmer" : AudioSink= "sonos:PLAY1:RINCON_zzz1400"
    default:AudioSink="sonos:PLAY1:RINCON_xxxx1400"
    }
  //gPlayer_NotificationVolume.allMembers.filter(s | s.state!=NotificationVolume ).forEach [item | item.sendCommand(NotificationVolume)]
  say(SayCommand.state.toString,"voicerss:deDE",AudioSink)
  logInfo("SayCommand","Es ist alles gesagt!")
end

You still seem to use as the core of the rule the say() command with 3 strings that for some reason I cant get to run, no (see above)? The 3rd String “AudioSink” is then calling the value from the switch defined above. I quite like the switch logic and the general setting of the notification volume, which would be nice add-one for my rule once either

  • the initial say() command would run with accepting the 2nd and 3rd string or
  • I could use a line before the say() command that would allow me to “switch the default sink to Sonos:xxx”

I’m not using the setting of the NotificationVolume in the say command just because I’m still on OH2.2. In this release the NotificationVolume couldn’t be set.
However it should work as posted in the docs. Did you try it from the console? You stated in the initial post that a test from PaperUI did work, I do not know how you did such a test. Did you use the Karaf-console?
How did you state the Audiosink to be used when testing?

I am on OH 2.2 and did set the Sonos thing in the PaperUI. There I did define the default audioSink as my Sonos player. The notification volume came from the item definition (that I did via notepad and linked in the PaperUI). That worked fine as a test. In this setting the say command has just one string e.g., say (“Kinder streitet Euch nicht”) (TTS Engine, and voice are defined in the Paper UI as well).

Why would

say("Hello world!", "voicerss:enUS", "sonos:PLAY5:kitchen")

not work in my installation? Do I need OH 2.3 to do so`?

It seems I misunderstood your:
" What works:
say(“Kinder”)
using from PaperUI: same Sonos player…"
as if you were initiating this command on PaperUI, which isn’t possible. Thesetup needs to be done there.

If such a test works,the say command in a rule should also work! You do not need OH2.3
In your initial statement you are using a different TTS service (PolyTTS), in the last examples it is VoiceRSS, Did you change that on PaperUI as well?
Do you switch the language between the PaperUI andthesaycommand,I never did.

Sorry, I might not have been too clear.
I did never change the TTS nor the voice between the default I did set via PaperUI and the attributes in the say() command. Exactly the same.
say(“Hello world!”, “voicerss:enUS”, “sonos:PLAY5:kitchen”) was just the example from the documentation, I am using as stated above PollyTTS.

When adding the voice and audio Sink to the say command I dont get any error message or log at all. OH seems to ignore it completely.

Would this for any reaon only work with voicerss or NOT with PollyTTS or do you see any other mistake I did in the syntax above (checked it 1000 times, but at times …)

I can’t see anymistakes if you post the examples from thedocs!

Please post the settings for Default Voice and Default Sink from PaperUI and an (not working) say command with three strings.
I am not familiar with PolyTTS, using VoiceRSS the created audio file is saved on the system and can be played manually. Can you do that with PolyTTS?
Another possible failure could be the notificationsoundvolume, Did you set it for all players? If not it could be zero for the player used, however if you are handing over the default sink it should work, since it worked with the say command when stating only one string.

Here are the defaults set in the Paper UI:

As well as the Sonos Thing/ the first channels from the PaperUI:


(Item definitions see first post pls)

My say rule (as per my first post) that is NOT working

rule "talk"
	when
		Item EG_Arbeiten_Wand received update
	then
	{
		sendCommand(EZ_Sonos_Notificationsoundvolume, 45)
		say("Kinder",  "pollytts:Marlene", "sonos:CONNECTAMP:Esszimmer")
	}
end

So replacing the say() command in the rule above with just one string - as shown below - works very well.

rule "talk"
	when
		Item EG_Arbeiten_Wand received update
	then
	{
		sendCommand(EZ_Sonos_Notificationsoundvolume, 45)
		say("Kinder")
	}
end

I have an item for the notificationvolume and setting this as a separate line before the say() command. I can set it to 10, 50, 100 and it works well (I did read your previous posts and some others about some challanges re notificationvolume and wanted to circumvent it by setting it explicitly).

PollyTTS does not permanently seem to store the mp3 files. no (?):

In case we have no other idea, let me try to install your TTS engine and find out whether this is the problem
(I hope OH would be agnostic to which of the engines that can be linked into OH and that generally work, no?).

What do you think?

Just did a test at my system, when using the name given by you for the Sonos thing (like sonos:CONNECTAMP:Esszimmer) in the rule it did NOT work. When using the thing name as given by the system (like: sonos:CONNECTAMP:RINCON_xxxxx1400) it did work!

1 Like

Cool ! I thought I had tried that before … let me redo it !

… it works, great !

rule "talk"
	when
		Item EG_Arbeiten_Wand received update
	then
	{
		sendCommand(WZ_Sonos_Notificationsoundvolume, 75)
		sendCommand(EZ_Sonos_Notificationsoundvolume, 55)
		say("Alexa, gemütlicher Abend im Wohnzimmer", "pollytts:Marlene", "sonos:CONNECTAMP:RINCON_xxx100")
		Thread::sleep(2000)
		say("Test Esszimmer", "pollytts:Marlene", "sonos:CONNECTAMP:RINCON_xxx200")
		sendCommand(EZ_Sonos_Stop, ON)
		sendCommand(WZ_Sonos_Stop, ON)
	}
end

Wonderful, many thanks !
:grinning::rofl:

Regarding the NotificationVolume, you probably read the docs for the latest version (that is actually 2.3).

You can switch the documentation to version 2.2 by opening the grey selection box at the right top of the page.
In 2.2 you can’t set the volume in the say command, but you will be able in 2.3.

Additionally I don’t think the Stop command is necessary, a played music should stop for the say command and resume afterwards automatically.

Yes, many thanks, I did read it … wanted to get that one working first before playing with too many variables at once.

well, regarding the stop command: most of the times it is not required (opposite, it actually stops the music in case music was running before).
But at times after the notification, Sonos launches the current playlist at 80% of the volume … as the latter is worse than restarting the music …
I am trying to see in the log whether this is triggered by OH or Sonos.

1 Like

That would be a valid point. We are using the boxes to play radio most of the time and I haven’t had this problem (so far ). Keeping fingers crossed.

My Sonos system occasionally starts playing the last “playlist” used after a “Say” Command is issued as well. At a very loud volume. Does anyone have any insight into this issue? I am still digging into the forums for more details.

OH 2.5.2
Sonos binding:
246 │ Active │ 80 │ 2.5.10 │ org.openhab.binding.sonos