rhasspy / wyoming-satellite

Remote voice satellite using Wyoming protocol
MIT License
739 stars 107 forks source link

Allow using Satellite as manual tts/audio/media output #40

Open Bluscream opened 11 months ago

Bluscream commented 11 months ago

Please register the satellites to these lists:

kizovinh commented 11 months ago

It is very useful, also volumn control for the satellite as well

sfkmk commented 11 months ago

would be insanely useful!

HannesK-ME commented 10 months ago

In the meantime you can just install MPD on the same device as the satellite to add a media_player entity to home assistant for this kind of stuff.

llluis commented 10 months ago

In the meantime you can just install MPD on the same device as the satellite to add a media_player entity to home assistant for this kind of stuff.

Just finished installing and configuring MPD, everything works as expected. There's some configuration to be made on alsa config to allow simultaneous access to card, but I figured it out.

I even installed raspotify (to cast Spotify from spotcast or phone) and now I can definitely get rid of my Google Home(s).

HannesK-ME commented 10 months ago

Yep, that's exactly what I did, too! It's a great setup like this! Combined with some custom sentences for assist this can do all the important stuff a Google home or alexa can do 😎😎😎

On January 11, 2024 12:30:28 PM MST, Luis Andrade @.***> wrote:

In the meantime you can just install MPD on the same device as the satellite to add a media_player entity to home assistant for this kind of stuff.

Just finished installing and configuring MPD, everything works as expected. There's some configuration to be made on alsa config to allow simultaneous access to card, but I figured it out.

I even installed raspotify (to cast Spotify from spotcast or phone) and now I can definitely get rid of my Google Home(s).

-- Reply to this email directly or view it on GitHub: https://github.com/rhasspy/wyoming-satellite/issues/40#issuecomment-1887826156 You are receiving this because you commented.

Message ID: @.***>

vhsdream commented 10 months ago

Perhaps a bit out of scope to ask here, but do either of you have any tips for the alsa config so both the satellite and wyoming can access the card? Are you using pulseaudio for ducking as well?

vhsdream commented 10 months ago

Adding more info here. I have followed what others appear to have done regarding using pulseaudio. It is running under my user context - I used pulseaudio --start -D to run it. My service file for the satellite is below:

[Unit]
Description=Wyoming Satellite
Wants=network-online.target
After=network-online.target
Requires=openwakeword.service

[Service]
Environment=PULSE_SERVER=127.0.0.1
Type=simple
ExecStart=/home/user/wyoming-satellite/script/run \
    --uri 'tcp://0.0.0.0:10700' \
    --name 'Living room satellite' \
    --awake-wav sounds/awake.wav \
    --done-wav sounds/done.wav \
    --mic-command 'parecord --property=media.role=phone --rate=16000 --channels=1 --format=s16le --raw' \
    --snd-command 'paplay --property=media.role=announce --rate=22050 --channels=1 --format=s16le --raw' \
    --snd-volume-multiplier 0.35 \
    --snd-command-rate 22050 \
    --wake-uri 'tcp://127.0.0.1:10400' \
    --wake-word-name 'ok_nabu' \
    --debug
WorkingDirectory=/home/user/wyoming-satellite
User=user
Restart=always
RestartSec=1

[Install]
WantedBy=default.target

When I start the service file I get the following error watching the debug:

DEBUG:root:Connecting to mic service: ['parecord', '--property=media.role=phone', '--rate=16000', '--channels=1', '--format=s16le', '--raw']
DEBUG:root:Connecting to snd service: ['paplay', '--property=media.role=announce', '--rate=22050', '--channels=1', '--format=s16le', '--raw']
DEBUG:root:Connecting to wake service: tcp://127.0.0.1:10400
INFO:root:Connected to services
DEBUG:root:Connected to mic service
DEBUG:root:Connected to wake service
Connection failure: Connection refused
DEBUG:root:Server set: 55650073127210
INFO:root:Waiting for wake word
WARNING:root:Mic service disconnected
DEBUG:root:Connected to mic service
Connection failure: Connection refused
WARNING:root:Mic service disconnected

However, when I use the exact same command via the commandline, it all works just fine.

DEBUG:root:Connecting to mic service: ['parecord', '--property=media.role=phone', '--rate=16000', '--channels=1', '--format=s16le', '--raw']
DEBUG:root:Connecting to snd service: ['paplay', '--property=media.role=announce', '--rate=22050', '--channels=1', '--format=s16le', '--raw']
DEBUG:root:Connecting to wake service: tcp://127.0.0.1:10400
INFO:root:Connected to services
DEBUG:root:Connected to mic service
DEBUG:root:Connected to wake service
DEBUG:root:Server set: 55958378074104
INFO:root:Waiting for wake word
DEBUG:root:Streaming audio
DEBUG:root:Connected to snd service
DEBUG:root:Event(type='transcript', data={'text': ' Turn off the kitchen lights.'}, payload=None)
INFO:root:Waiting for wake word
DEBUG:root:Event(type='synthesize', data={'text': 'Turned off the light', 'voice': {'name': 'en_US-hfc_male-medium'}}, payload=None)
DEBUG:root:Connected to snd service

I have not made any changes to any pulseaudio configurations, so have not got around to attempting ducking yet since I want this to work as a systemd service. Can anyone shed any light on what I might be missing here?

pkkrusty commented 10 months ago

Just finished installing and configuring MPD, everything works as expected. There's some configuration to be made on alsa config to allow simultaneous access to card, but I figured it out.

I even installed raspotify (to cast Spotify from spotcast or phone) and now I can definitely get rid of my Google Home(s).

Can you provide details of your alsa config et al, for noobs like us to look at and copy?

llluis commented 10 months ago

Here's my asound.conf for reference. It's working perfectly in my case, but it's my first time playing with this stuff, so, it may not be optimal. I adapted from other examples found online and some trial and error.

If you are using the 2mic hat you will have to replace the contents of /etc/asound.conf and also /etc/voicecard/asound_2mic.conf, as the first file is replaced at boot by the second.

Make sure the card id is correct for your system. I disabled the other audio interfaces in mine, so that's why it's 0. It will probably be 1 in vanilla systems.

# Default control card.
defaults.ctl.card 0

# Default playback card.
# It should usually be the same as defaults.ctl.card.
defaults.pcm.card 0

# Default device on the default card.
# 0 or 1 is usually the correct device number.
defaults.pcm.device 0

# Default subdevice on the default device.
# Should rarely need to be changed.
defaults.pcm.subdevice 0

#defaults.pcm.rate_converter speexrate_medium

# Default input and output.
pcm.!default {
    type asym
    playback.pcm {
        type plug
        slave.pcm dmixer
    }
    capture.pcm {
        type plug
        slave.pcm dsnooper
    }
}

ctl.!default {
    type hw
    card {
        @func refer
        name defaults.ctl.card
    }
}

pcm.dmixer {
    type plug
    slave {
        pcm {
            type softvol
            control {
                name PCM
                card {
                    @func refer
                    name defaults.ctl.card
                }
            }
            slave.pcm {
                type dmix
                ipc_key 47589
                ipc_perm 0666
                ipc_gid 29
                slave {
                    pcm {
                        type hw
                        card {
                            @func refer
                            name defaults.pcm.card
                        }
                        device {
                            @func refer
                            name defaults.pcm.device
                        }
                        subdevice {
                            @func refer
                            name defaults.pcm.subdevice
                        }
                    }
                }
                bindings {
                    0 0
                    1 1
                }
            }
        }
    }
}

pcm.dsnooper {
    type plug
    slave {
        pcm {
            type softvol
            control {
                name Capture
                card {
                    @func refer
                    name defaults.ctl.card
                }
            }
            slave.pcm {
                type dsnoop
                ipc_key 47533
                ipc_perm 0666
                ipc_gid 29
                slave {
                    pcm {
                        type hw
                        card 0
                        device 0
                    }
                }
            }
        }
    }
}

# Playback (RA)Spotify (mono), Output only.
pcm.spotify {
    type route #plug
    ttable {
      # Merge both channels for mono output.
      0.0 0.5
      1.0 0.5
      0.1 0.5
      1.1 0.5
    }
    slave {
        pcm {
            type softvol
            slave.pcm dmixer
            control {
                name spotify
                card {
                    @func refer
                    name defaults.ctl.card
                }
            }
        }
    }
}

# Playback MPD / media player / TTS speaker. Output only.
pcm.mplayer {
    type plug
    slave {
        pcm {
            type softvol
            slave.pcm dmixer
            control {
                name mplayer
                card {
                    @func refer
                    name defaults.ctl.card
                }
            }
        }
    }
}

# Jarvis / Wyoming-Satellite. Output and input.
pcm.jarvis {
    type asym
    capture.pcm {
        type plug
        slave.pcm dsnooper
    }
    playback.pcm {
        type plug
        slave {
            pcm {
                type softvol
                slave.pcm dmixer
                control {
                    name jarvis
                    card {
                        @func refer
                        name defaults.ctl.card
                    }
                }
            }
        }
    }
}

This will create 3 "devices" to be used: jarvis, spotify and mplayer. So, for satellite, you use -D jarvis.

pcwii commented 10 months ago

Is a link or steps available to install mpd that someone could provide. No warranty assumed. 😏

eleaner commented 4 months ago

Is a link or steps available to install mpd that someone could provide. No warranty assumed. 😏

also interested, what actually is MPD though?

Bluscream commented 4 months ago

also interested, what actually is MPD though?

https://www.musicpd.org/

andzejsp commented 3 months ago

also interested, what actually is MPD though?

https://www.musicpd.org/

is there a way to set up to get TTS back to the same satellite when some onther audio souce is playing like browser youtube? By default it throws errors when something else is playing and you start the wake word and ask for command and when the TTS supposed to run with the output then it shows error that the sound device is busy or something..

How do i have satellite running and be able to listen to music and TTS at the same time?