Sonos ... Audio Sink ... Say?

I reinstalled the bundle but it pulled the old. is it already merged for the nighty build?

Not yet merged.

Right, I didn’t address the masterVolume commands yet, they are still the old code. They probably do not make much sense anymore, probably rather a setVolume(String sinkID) should be there.

No, I would leave that separate. Usually volume control is independent of the content that is played. And if you have use cases where you need to say something loud, use setVolume and say within a rule.

With snapshot 595 running Windows 10, I observed the following bugs and German language.

say command is not working
When defining “marytts” as default language:

say(“Test”)
11:06:31.674 [ERROR] [se.smarthome.core.voice.VoiceManager] - Error saying ‘Test’: Unable to find a voice for language de

say(“dies ist ein Test das ist ein Test ist ein Test”,“marytts:bits1hsmm”,“enhancedjavasound”)
working

say(“dies ist ein Test das ist ein Test ist ein Test”,“marytts:bits3hsmm”,“sonos:PLAY1:Schlafzimmer”)
or also
say(“dies ist ein Test das ist ein Test ist ein Test”,“marytts:bits3hsmm”,“webaudio”)
working but not understandable.
Sounds like Donald Duck but cannot understand words.
Seems to be played much too fast.

Shall I create a issue or too early?

This is already tracked: https://github.com/eclipse/smarthome/issues/2352

It seems that the Mary server provides the wrong sampling rate for bits3hsmm. Feel free to enter an issue at https://github.com/openhab/openhab2-addons/issues - but don’t expect me to find time to look into that myself, I would hope that some other MaryTTS user might jump in here.

Hi @Lolodomo,

I’ve updated to build # 598 and tested voicerss using the karaf command
smarthome:voice say ("BlaBla")
This works!
No I’m trying it from within a rule with that:

rule "TestVoice"

when
  Item TestSomething changed

then 
  say("Hallo Echo!","voicerss:deDE","sonos:PLAY1:RINCON_xxxxx1400")
end

When trying to use the say command in a rule only the last string that was entered in karaf is being played (the “BlaBla” is plaed, not “Hallo Echo!”)
Am I missing something?

Parentheses in case of console commands are mot required. Just try: smarthome:voice say blabla
But no idea if it can be the source of your problem.

My problem is the other way around, using the console command works as expected. Using it from within a rule doesn’t.

Hi,
I’ve tested the SetMasterVolume from within a rule and I can’t seem to set anything else then 0 or 1.0(i.e. 100%).
I tried:
setMasterVolume(0,5) Sets 0!
setMasterVolume(0.5) Returns " Cannot convert number literal to typeorg.eclipse.smarthome.core.library.types.PercentType"
setMasterVolume(“0.5”) Returns “Could not invoke method: org.eclipse.smarthome.model.script.actions.Audio.setMasterVolume(org.eclipse.smarthome.core.library.types.PercentType) on instance: null”

Which syntax is needed?

I’m on #build 627

for setting you have to use a “,” but as I understood Kai this code is non functional and will be replace by different APIs.

Did you try with values from 0 to 100?

@martin_klimke
Did try it with “,”. It seems that the value gets truncated to zero.

@Kai
Sorry forgot to mention that one. Values above 1 are neglected because out of bounce (0-1).

Can you figure the test with the doorbell, with volume 0 and 1!

There was another possible way, which I missed:

setMasterVolume(0.2F)

So it does use the “.”, however the “F” for float was missing.
If you like to set percentage values instead of float numbers, you can use

setMasterVolume(new PercentType(20))

No more yelling, because of this really loud “doorbell”:wink:

[Edit:]
My next problem is the correct syntax for the say command.
If I use only one string input, this text will be said by the default voice through the default audio-sink.
What is the correct syntax for the voice, I used “voicerss:deDE” as specified through Karaf as an available voice or if I ommit the second string like say(MyString, ,“MySonosPlayer”), both cases return an error:

Could not invoke method: org.eclipse.smarthome.model.script.actions.Voice.say(java.lang.String,java.lang.String) on instance: null

I have the “say” command working in the version with one string (i.e. using both default voice and audio sink).
However I can’t get the overloaded versions with more then one string working.
The second string is supposed to be voice (The description say: “the name of the voice to use or null, if the default voice should be used. If the voiceId is fully qualified (i.e. with a tts prefix), the according TTS service will be used, otherwise the voiceId is assumed to be available on the default TTS service.”)
What is the correct syntax to name the voice? I’m using VoiceRSS:deDE, @Lolodomo reported it working with “voicerss:frFR”, so in my case it should be “voicerss:deDE”. However I get an error as posted above.

Should it work that way or am I pushing it to hard for the moment?

You have to use one of the entries (first part of the line) returned by the command “smarthome:voice voices”. So your voice id is “voicerss:deDE” and not “VoiceRSS:deDE”. Case is probably important (not verified).
On my side, I am using in rules the “say” action with 3 parameters: text, voice and audio sink. It is working, the voice is set to “voicerss:frFR”.

For the available audio sinks, run the command “smarthome:audio sinks” and then use one of the returned values as third parameter for the say action. I only tested with Sonos as audio sink.

I did use the “lowercase” version for the voice!
I tried:

say(SayCommand.state,“voicerss:deDE”)

resulted in

17:34:04.875 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘SagEtwas’: An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.Voice.say(java.lang.String,java.lang.String) on instance: null

or

say(SayCommand.state,“voicerss:deDE”,“sonos:PLAY1:RINCON_???1400”)

resulted in

Rule ‘SagEtwas’: An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.Voice.say(java.lang.String,java.lang.String,java.lang.String) on instance: null

however

say(SayCommand.state)

is working like a charm!

I’m on build #627

1 Like

Try this: say(SayCommand.state.toString,“voicerss:deDE”)
This should work.
I know, there is something strange, say with 1 parameter takes one Object while say with 2 or 3 parameters takes one String as first parameter.
Probably something to change that I have already commented.

1 Like

Bingo!

Thanks for that hint, yes I was feeling really strange already for all that false trys!

Next thing is to incooperate a selection of the audio sink to be used by the command, I was hoping that the Name intead of the UDN could be used. So I need to populate a list with the names and then select the correspondig UDN for the say command.

Not very fancy, however working!

On a template widget in HABpanel
Lautsprecher and SayCommand are string items!

<div class="form-inline">
  <div class="form-group">
    <input type="text" class="form-control" no-snap-drag="true"
           ng-model="myvalue" ng-value="itemValue('SayCommand')"></input>
    <button type="button" class="btn btn-primary"
           ng-click="sendCmd('SayCommand', myvalue)">Sag es!</button>
  </div>
  <div class="btn-group" uib-dropdown>
  <button id="single-button" type="button" class="btn btn-primary" uib-dropdown-toggle>
    {{itemValue('Lautsprecher')}} <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
    <li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Küche')">Küche</a></li>
    <li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Wohnzimmer')">Wohnzimmer</a></li>
    <li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Gästezimmer')">Gästezimmer</a></li>

</div>

and the rule that actualy calls the “say”

rule “SaySomething”

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==“Gästezimmer” : AudioSink="sonos:PLAY1:RINCON_yyy1400"
default:AudioSink=“sonos:zzz1400”
}
say(SayCommand.state.toString,“voicerss:deDE”,AudioSink)
end