node-red-contrib-sonos-plus icon indicating copy to clipboard operation
node-red-contrib-sonos-plus copied to clipboard

TTS-Ultimate->Sonos-plus interaction for queue handling.

Open Supergiovane opened this issue 3 years ago • 14 comments

Description

Hi @hklages, i'm the dev of tts-ultimate node (the successor of sonospollytts). Many users are asking me to gracefully resume queue on master and grouped players, after each speech.

I keep suggesting to use your wonderful node, focused way better on music handling than tts-ultimate. As my node is mainly focused on TTS (now with Google voice free and paid API layers, as well as AWS Polly, all with cache and multi voice capable), it was great if we can find a sort of JSON message format to interact. TTS-Ultimate already sends a msg whenever it starts and ends playing the TTS queue and already tries to resume the queue, but in certain cases (for example Sonos playlist or local mp3 dir) it fails resuming from the last position.

It whould be great if an user, by simply interconnect our two nodes, was able to do a great queue resume after TTS. In this case, i can put a checkbox in TTS-Ultimate config window, to allow the user to "Use Sonos-Plus to handle the queue".

What do you think about a very very very light, stress-less and simple implementation?

Supergiovane avatar Jul 02 '21 15:07 Supergiovane

Hi "Supergiovane" - in my Wiki I have already been recommending your program for a long time: TTS. Seems that I have to change the name to "tts-ultimate node".

Sure - I am very much interested to make both nodes work together (my current work around is far to complex).

There are already some "commands" we can use such as group.create.snap, group.restore.snap, household.create.group, household.separate.group, .... documentation and I can add additional functionality. In my example section there are two flows saving and restoring the state - examples 08 and 09 examples

Do you already have some ideas?

Lets continue via email and maybe via discord. My email is "[email protected]". Stephan (who maintaines node-sonos and created the newer node-sonos-ts) has a discord chat server - we can also use that.

hklages avatar Jul 02 '21 19:07 hklages

Hi thank you for your effort. Unfortunately (or fortunately), i'm on holiday now and i haven't access to my house's Sonos system to test. As soon as i come back to home, i'll join back this discussion. In the meantime, i'll learn your docs and samples :-) Thank you!

Supergiovane avatar Jul 05 '21 07:07 Supergiovane

Enjoy you vacation!

On Mon, Jul 5, 2021, 09:28 Max Supergiovane @.***> wrote:

Hi thank you for your effort. Unfortunately (or fortunately), i'm on holiday now and i haven't access to my house's Sonos system to test. As soon as i comes back to home, i'll join back this discussion. In the meantime, i'll learn your docs and samples :-) Thank you!

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/hklages/node-red-contrib-sonos-plus/issues/158#issuecomment-873874218, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDZCHY3H5YP7FPJX63EJELTWFNLBANCNFSM47W7DHBQ .

hklages avatar Jul 05 '21 10:07 hklages

This library node-sonos-contrib-plus is already using @svrooij/sonos.

My guess that your TTS library just generates an url with an mp3 hosted somewhere?

If you would call player.PlayNotification({ trackUri: 'url', delayMs: 700 }) (see docs, you would have a great start. I'm not sure if @hklages implemented this command though.

svrooij avatar Jul 22 '21 12:07 svrooij

Hi TTS-Ultimate it's more articulated. I cannot use player.PlayNotification. I must handle persistent files, queues, multiple voices syncronized simultaneusly.

Supergiovane avatar Jul 22 '21 12:07 Supergiovane

TTS-Ultimate it's more articulated. I cannot use player.PlayNotification. I must handle persistent files, queues, multiple voices synchronized simultaneously.

What does handle persistent files mean?

At the end there is an url with the correct voice file right?

The used sonos library has support for capturing the current state, playing one or more notifications and restoring the state afterwards. You wouldn't have to manage anything. Although I think @hklages implemented something similar.

See this code

svrooij avatar Jul 22 '21 12:07 svrooij

Stephan, as i told to hklages, i'll take a look as soon as i come back home. In the meantime, i'm committed to KNX Secure and i need to do my job as usual. So i've not so much time... If you wish, you can check the TTS-Ultimate code by yourself, do the changes and make a PR. Every contribution is wellcome.

Supergiovane avatar Jul 22 '21 13:07 Supergiovane

@svrooij Stephan, give us some time to figure out how we can "connect" tts-ultimate and sonos-plus node. Although they are based on different packages (JavaScript versus TypeScript version of node-sonos) there is a good chance that we can create a nice solution.

After that the plan is to remove all my "extensions" and use what is provided in node-sonos-ts or tts-ultimate .

hklages avatar Jul 22 '21 14:07 hklages

Hi hklages, Despite still in holidays, i've read your docs and tested some samples you mentioned. I think we can start with simple things. Many users wish to correctly resume queues, non only on coordinator player, but also on each player belonging to a group. TTS-Ultimate is capable of grouping additional players (there is a listbox, where you can add players to the group).

So, theroretically, as soon as TTS-Ultimate receives a message to be spoken, it should be able to:

  1. Save the current household's coordinator's player group.
  2. Snapshotting the coordinator's queue and his state (playing/stopped)
  3. Snapshotting the queue of each additional player belonging to the group created by TTS-Ultimate and save his state (playing/sopped)
  4. Play the spoken message to the custom group created by TTS-Ultimate
  5. Resuming the coordinator's queue and his state (play/don't play)
  6. Resuming the grouped player's queue and their state (play/don't play)
  7. Restore the household group saved at point 0

That's tricky and i'm thinking if is simpler to create a sample flow to do so, or if it's simpler integrating a way to control sonos-plus into TTS-Ultimate.

Supergiovane avatar Jul 27 '21 15:07 Supergiovane

Players in a group don't have a queue, at least not an active one.

Playing and restoring is already integrated in both the used Sonos library and the great node red library by @hklages

If you need anything about the Sonos library, just mention me.

svrooij avatar Jul 27 '21 15:07 svrooij

Svrooij, TTS-Ultimate creates the group "on the fly" and then dismounts it as soon as it ended playing the TTS message, so if you're enjoing some music queue from a player alone in the Kitchen, i need to snapshot this player's queue as well and restore it after TTS-Ultimate ended speaking and after it dismounted the group .

Supergiovane avatar Jul 27 '21 16:07 Supergiovane

There is a confusion about the wording.

You do create a group of players and the notification is played on these players. Lets name that group NOTIFICATION_GROUP. To simplify I treat any stand alone player as group with only 1 player. (your discussion with Stepan above)

0: Capture household: Get a list of all groups (includes stand alone player), lets name it "MY_HOUSEHOLD_GROUPS" 1: We use NOTIFICATION_GROUP to create a "IMPACTED_GROUPS": Every player in NOTIFICATION_GROUP is in exactly one group of "IMPACTED_GROUPS" and every group of IMPACTED_GROUPS has one player being in NOTIFICATION_GROUP. 2. Capture al "STATES" of all groups in "IMPACTED_GROUPS" 3. Create NOTIFICATION_GROUP 4. Play notification on NOTIFICATION_GROUP 5. Restore all groups from "IMPACTED_GROUPS" 6. Restore STATE for all "IMPACTED_GROUPS"

For STATE we have:

  • source such as a radio stream, the SONOS_QUEUE, line in, ... --- apps (SPOTIFY) we can not restore
  • SONOS_QUEUE parameter in case source is SONOS_QUEUE. Parameter are position, queue play mode, ...
  • group volume
  • group mute state
  • group play state such as playing, paused, stopped
  • volume of each player
  • mute state of each player

Two issues:

  • To capture efficiently we need the IMPACTED_GROUP, that is being derived from the NOTIFICATION_GROUP, what is created in your node. So we can not capture the data in a node before your node, it must be inside your node. I can provide you subroutines but we use different libraries.

  • Restore can be complex in an installation with 10 or more players. Imagine the door bell should be played on 18 players and before they were grouped in 6 groups as 3 players. Without parallel execution is might take to long. I have a smart algorithm to restore a single group - but it takes time. In any case I need as output of your node the IMPACTED_GROUP, MY_HOUSEHOLD_GROUPS and all "STATES" in JSON format.

Your opinion?

Do you use the SONOS_QUEUE to play your notification or is it a stream not impacting/modifying the SONOS_QUEUE?

hklages avatar Jul 27 '21 19:07 hklages

Thanks for spending time in clarify that. I don’t use queuing, as you intend. The queue is internal and is not related to sonos. I use stream.

My through is.. to leave all as is! Yet an user can already do what they wish, using a mix from my and your node linked toghether. I think that the involved work is a lot and if spotify and app cannot be resumed, we’ll still have users complaining about that and blaming both of us. 🤨

Supergiovane avatar Jul 27 '21 19:07 Supergiovane

I leave this topic open until December. Maybe we have some good ideas in the cold time October/November. Enjoy your vacation - I am going to start mine now.

hklages avatar Jul 28 '21 06:07 hklages