shivasiddharth / GassistPi

Google Assistant for Single Board Computers
Other
1.02k stars 303 forks source link

Dsnoop plugin for bluetooth audio setups #466

Open WarmWinters opened 6 years ago

WarmWinters commented 6 years ago

Describe the bug:

On a PI3 B+ I cloned https://github.com/shivasiddharth/GassistPi and installed two days a ago. I am using a USB Microphone and Bluetooth speakers via embedded Bluetooth in the Pi. I have made several attempts to get this working. Thanks for any assistance.

Google Assistant fully works with these commands.

cd /home/pi
source env/bin/activate
python3 /home/pi/env/bin/google-assistant-demo

But will not work if setup to run as a service or if started manually with main.py I think I am missing something in the audio configuration.

This works.
aplay -D bluealsa:DEV=00:1F:81:94:70:C7 /usr/share/sounds/alsa/Front_Center.wav
As does this. Clip is recorded and played back.
arecord  -d 3 test.wav && aplay test.wav
No audio is heard with this however but I cannot see why :-(
speaker-test -t wav
speaker-test 1.1.3
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 9600 to 4565228
Period size range from 480 to 4459
Using max buffer size 4565228
Periods = 4
........

Here are my files

cat /home/pi/.asoundrc
pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}
pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}
pcm.speaker {
   type plug
        slave.pcm {
                type bluealsa
                device "00:1F:81:94:70:C7"
                profile "a2dp"
        }
}

cat /etc/asound.conf
pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}

pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}

pcm.speaker {
   type plug
        slave.pcm {
                type bluealsa
                device "00:1F:81:94:70:C7"
                profile "a2dp"
        }
}

in /usr/share/alsa/alsa.conf
-- I changed changed both lines from 0 to 1
defaults.ctl.card 1
defaults.pcm.card 1`

Did you go through or search the issues section to check if your issue was already discussed (either currently open issues or closed issues).

Yes

2. Is the issue related to assistant installation ?

Yes

If answer to question 2 is Yes, then paste the contents of the terminal below.


Aug 01 19:12:39 computer systemd[1]: gassistpi-ok-google.service: Service hold-off time over, scheduling restart.
Aug 01 19:12:39 computer systemd[1]: Stopped Google Assistant-Voice.
Aug 01 19:12:39 computer systemd[1]: Started Google Assistant-Voice.
Aug 01 19:12:39 computer dhcpcd[346]: eth0: Router Advertisement from fe80::4826:42ff:fea9:fba9
Aug 01 19:12:39 computer dhcpcd[346]: eth0: requesting DHCPv6 information
Aug 01 19:12:46 computer python[16799]: [0189d9c0] pulse audio output error: PulseAudio server connection failure: Connection refused
Aug 01 19:12:46 computer python[16799]: [01894b40] pulse audio output error: PulseAudio server connection failure: Connection refused
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Aug 01 19:12:46 computer python[16799]: ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
Aug 01 19:12:46 computer python[16799]: ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
Aug 01 19:12:46 computer python[16799]: ALSA lib bluealsa-pcm.c:679:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Aug 01 19:12:46 computer python[16799]: Cannot connect to server socket err = No such file or directory
Aug 01 19:12:46 computer python[16799]: Cannot connect to server request channel
Aug 01 19:12:46 computer python[16799]: jack server is not running or cannot be started
Aug 01 19:12:46 computer python[16799]: JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Aug 01 19:12:46 computer python[16799]: [FATAL:audio_input_stream.cc(47)] Input device could not be opened: default
Aug 01 19:12:46 computer systemd[1]: gassistpi-ok-google.service: Main process exited, code=killed, status=6/ABRT
Aug 01 19:12:46 computer systemd[1]: gassistpi-ok-google.service: Unit entered failed state.
Aug 01 19:12:46 computer systemd[1]: gassistpi-ok-google.service: Failed with result 'signal'.

If answer to question 2 is No, then proceed further.

3. Does the assistant service start normally?

No

4. Is the assistant service restarting automatically?

Yes

If answer to question 4 is Yes, then paste the contents of the terminal below.

Aug 01 19:12:39 computer systemd[1]: gassistpi-ok-google.service: Service hold-off time over, scheduling restart.
Aug 01 19:12:39 computer systemd[1]: Stopped Google Assistant-Voice.
Aug 01 19:12:39 computer systemd[1]: Started Google Assistant-Voice.
Aug 01 19:12:39 computer dhcpcd[346]: eth0: Router Advertisement from fe80::4826:42ff:fea9:fba9
Aug 01 19:12:39 computer dhcpcd[346]: eth0: requesting DHCPv6 information
Aug 01 19:12:46 computer python[16799]: [0189d9c0] pulse audio output error: PulseAudio server connection failure: Connection refused
Aug 01 19:12:46 computer python[16799]: [01894b40] pulse audio output error: PulseAudio server connection failure: Connection refused
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Aug 01 19:12:46 computer python[16799]: ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
Aug 01 19:12:46 computer python[16799]: ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
Aug 01 19:12:46 computer python[16799]: ALSA lib bluealsa-pcm.c:679:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
Aug 01 19:12:46 computer python[16799]: ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Aug 01 19:12:46 computer python[16799]: Cannot connect to server socket err = No such file or directory
Aug 01 19:12:46 computer python[16799]: Cannot connect to server request channel
Aug 01 19:12:46 computer python[16799]: jack server is not running or cannot be started
Aug 01 19:12:46 computer python[16799]: JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Aug 01 19:12:46 computer python[16799]: [FATAL:audio_input_stream.cc(47)] Input device could not be opened: default
Aug 01 19:12:46 computer systemd[1]: gassistpi-ok-google.service: Main process exited, code=killed, status=6/ABRT
Aug 01 19:12:46 computer systemd[1]: gassistpi-ok-google.service: Unit entered failed state.
Aug 01 19:12:46 computer systemd[1]: gassistpi-ok-google.service: Failed with result 'signal'.

If answer to question 4 is No, then proceed further.

Manually start the assistant. For guidelines to start the assistant manually refer this

Paste the command below, that crashed the assistant

pi@computer:~ $ /home/pi/env/bin/python -u /home/pi/GassistPi/src/main.py --device_model_id xxxxxx-xxxxxx-xxxxxx-xxxxxx

Paste the contents of the terminal below

[00fb7350] pulse audio output error: PulseAudio server connection failure: Connection refused
[00fdc4f8] pulse audio output error: PulseAudio server connection failure: Connection refused
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib bluealsa-pcm.c:679:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
[FATAL:audio_input_stream.cc(47)] Input device could not be opened: default   <-------
Aborted`

Attach the log file. Log file can be found in /tmp directory. Remeber to copy your log file before shutting down or restarting the Pi.

There is no log file.

shivasiddharth commented 6 years ago

The issue here is the audio setup. I have enabled the custom wakeword option by default. So to simultaneously run the snowboy and google assistant, you need a dsnoop plugin. Which you dont have in your audio conf. So disable the custom wakeword in the config.yaml. After that you have the google assistant working normally. Go through the README for details/guidance to disable the custom wakeword.

WarmWinters commented 6 years ago

Thank you. I have disabled custom wakeword and rebooted the pi but error remains. I will look into dsnoop as I would like to get custom wakeword working at some stage.

pi@computer:~ $ grep -i -a1 custom_wakeword   /home/pi/GassistPi/src/config.yaml
#To enable custom wakeword, change status to Enabled and restart the assistant.
Custom_wakeword:
  status: 'Disabled'

pi@computer:~ $ /home/pi/env/bin/python -u /home/pi/GassistPi/src/main.py --device_model_id 'femputer-e3f60-femputer-hwz8p2'
[01790da0] pulse audio output error: PulseAudio server connection failure: Connection refused
[0179bf20] pulse audio output error: PulseAudio server connection failure: Connection refused
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib bluealsa-pcm.c:679:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
[FATAL:audio_input_stream.cc(47)] Input device could not be opened: default 
Aborted
shivasiddharth commented 6 years ago

In the extras folder you will find a file called no_custom_wakeword_main.py rename it to main.py and use that to replace the existing file in the src folder. I am positive that it should fix your issue.

WarmWinters commented 6 years ago

You are correct Sir. Its working now. I will research dsnoop. Many thanks for creating this project and your help!

shivasiddharth commented 6 years ago

Hello, I would like to give users as many options as possible and freedom to use a number of different setups. I would like to add the bluetooth audio setup to the project. Can you kindly mention the bluetooth device that you are using and the steps that you went through to set it up? I shall try to investigate and add dsnoop to bluetooth setups.

WarmWinters commented 6 years ago

Hello. No problem. I will do that as soon as I have some time.

WarmWinters commented 6 years ago

I am using an HMDX Bluetooth speaker. These commands were ran on a fresh install of Stretch. No need to install additional packages.

pi@raspberrypi:~ $ bluetoothctl
[NEW] Controller B8:27:EB:41:F3:97 raspberrypi [default]
[NEW] Device 00:1F:81:94:70:C7 HMDX RAVE
[CHG] Device 00:1F:81:94:70:C7 Connected: no

[bluetooth]# agent on
Agent registered

[bluetooth]# trust 00:1F:81:94:70:C7
[CHG] Device 00:1F:81:94:70:C7 Trusted: yes
Changing 00:1F:81:94:70:C7 trust succeeded

[bluetooth]# pair 00:1F:81:94:70:C7
Attempting to pair with 00:1F:81:94:70:C7
[CHG] Device 00:1F:81:94:70:C7 Connected: yes
Request PIN code
[agent] Enter PIN code: 0000
[CHG] Device 00:1F:81:94:70:C7 Paired: yes
Pairing successful
[CHG] Device 00:1F:81:94:70:C7 Connected: no

[bluetooth]# connect 00:1F:81:94:70:C7
Attempting to connect to 00:1F:81:94:70:C7

[HMDX RAVE]# info 00:1F:81:94:70:C7
Device 00:1F:81:94:70:C7
        Name: HMDX RAVE
        Alias: HMDX RAVE
        Class: 0x240414
        Icon: audio-card
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: yes
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)

[HMDX RAVE]# exit

aplay -D bluealsa:DEV=00:1F:81:94:70:C7 /usr/share/sounds/alsa/Front_Center.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
contactwajeeh commented 6 years ago

I was able to setup GassistPi with nowakeword main.py file, but only assistant works with that, no youtube playback, Gmusic etc doesnt work with this setup.

Vino-git commented 6 years ago

Hi, I am using pulseaudio with Bluetooth speaker setup. I am able to stream music from my mopidy but neither aplay nor google voice heard from the speaker.

I have tried the above steps also but no luck.

Any suggestion pls.

here is asound.rc & /etc/asound.conf

pcm.dsnooper { type dsnoop ipc_key 816357492 ipc_key_add_uid 0 ipc_perm 0666 slave { pcm "hw:1,0" channels 1 } }

pcm.!default { type asym playback.pcm { type plug slave.pcm "hw:0,0" } capture.pcm { type plug slave.pcm "dsnooper" } }

pcm.bluetooth_speaker_1 { type bluetooth device "00:22:37:0D:2B:89" profile "auto" } pcm.bluetooth_bar{ type bluetooth device "88:D0:39:03:FC:2D" profile "auto" }

oceank82 commented 6 years ago

Hello!

I have the Assistantspi running well with both assistants. How can I make them using my bluetooth speaker? I cannot get it to work, anyone?

amitsrivastava79 commented 6 years ago

Hi @shivasiddharth,

I am using GassistPi for a long time and it's working fine now with your help. I am running it with a USB Mic and Output from Audio Jack.

Now I want to add my Bose Soundtouch 20 with this via Bluetooth, I connected it as per the Bluetooth connection steps for PI and with same steps Audio working fine on my another PI (not using as Google Assistant), but the PI with GassistPi not routing the audio to the Bluetooth speaker(even if I ran a youtube video directly on the Pi browser ) although showing as connected.

Hope you can guide me here...thanks in advance for this wonderful project.

Regards, Amit

Hoeby commented 5 years ago

Sorry for adding to this old thread, but i noticed a few people have problems getting the bluetooth working. I got it working and would to share it with all. This works whit dsnoop active, so also custom wake-word should work. I am using a PS3 eye USB microphone and a havit M16 bluetooth speaker

Step 1: Install GassistPi like you wanted to use the jack plug as audio output. This was for me the start of the install.

Step 2: Follow the steps to enable and pair the bluetooth speaker on the raspberry pi. I am using a 3b+, don't know if these steps works on other pi's. This has nothing to do with GassistPi. Follow the instruction on the next link: https://sigmdel.ca/michel/ha/rpi/bluetooth_01_en.html I had the problem that the PI didn't autoconnect (pair bluetooth) after reboot. I made a script for it and put it in autodesk, to start it with power-on.

Step 3: Change your .asoundrc file to (make sure to make a copy or printscreen, just in case) There where i written "place your bluetooth mac ID here", only change the text to mac ID, but keep the " and " in the script

pcm.dsnooper {
    type dsnoop
    ipc_key 816357492
    ipc_key_add_uid 0
    ipc_perm 0666
    slave { 
        pcm "hw:1,0"
        channels 1
    }
}

pcm.bluetooth {
    type plug 
    slave.pcm {
        type bluealsa
        device "place your bluetooth mac ID here"
        profile "a2dp"
    }
}

pcm.!default {
    type asym
    playback.pcm {
        type plug
        slave.pcm "bluetooth"
    }
    capture.pcm {
        type plug
        slave.pcm "dsnooper"
    }
}
bachoo786 commented 5 years ago

@Hoeby I followed your method however when I test my sound it doesnt work.

what I noticed was that the .asoundrc file changes back to default with the default bluetooth settings when I restart my rpi3b+

this is what the .asoundrc file becomes after I restart:

pcm.!default {
        type plug
        slave.pcm {
                type bluealsa
                device "20:18:08:30:A9:66"
                profile "a2dp"
        }
}

ctl.!default {
        type bluealsa
}
Hoeby commented 5 years ago

your .asoundrc file doesn't have the right permissions. that is why it changes back. Do a chmod on your .asoundrc file and try again after you did that.

bachoo786 commented 5 years ago

Which file do I need to edit ? Is this the one in the home folder ?

bachoo786 commented 5 years ago

@hoeby do I need to follow the link that you sent because the latest raspbian version works with Bluetooth already and it connects to my Bluetooth speaker whenever I restart my pi .

I get errors with my mic saying that it is not connected but I'm using the USB mic and it doesn't work . The mic is working and I can see that the USB connection is working .

bachoo786 commented 5 years ago

this is my log when I manually start it:

INFO:gmusicapi.Mobileclient1:!-- begin debug log --!
INFO:gmusicapi.Mobileclient1:version: 12.0.0
INFO:gmusicapi.Mobileclient1:logging to: /home/pi/.cache/gmusicapi/log/gmusicapi.log
INFO:gmusicapi.Mobileclient1:initialized
INFO:gmusicapi.Mobileclient1:logged out
/home/pi/env/lib/python3.5/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /home/pi/.local/share/gmusicapi/mobileclient.cred: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
2019-03-02 11:45:22,700 - gmusicapi.Mobileclient1 (shared:183) [WARNING]: could not retrieve oauth credentials from ''/home/pi/.local/share/gmusicapi/mobileclient.cred''
WARNING:gmusicapi.Mobileclient1:could not retrieve oauth credentials from ''/home/pi/.local/share/gmusicapi/mobileclient.cred''
INFO:gmusicapi.Mobileclient1:failed to authenticate
[03131580] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[03138f28] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
USB-MIC-JACK
Initializing GPIOs 5 and 6 for assistant activity indication
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.front.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib bluealsa-pcm.c:680:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
ALSA lib bluealsa-pcm.c:680:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
  File "/home/pi/GassistPi/src/main.py", line 1024, in <module>
    Myassistant().main()
  File "/home/pi/GassistPi/src/main.py", line 192, in __init__
    self.detector = snowboydecoder.HotwordDetector(models, sensitivity=self.sensitivity)
  File "/home/pi/GassistPi/src/snowboydecoder.py", line 115, in __init__
    stream_callback=audio_callback)
  File "/home/pi/env/lib/python3.5/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/home/pi/env/lib/python3.5/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9997] Invalid sample rate

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/GassistPi/src/main.py", line 1026, in <module>
    logger.exception(error)
NameError: name 'logger' is not defined

@shivasiddharth can you please help me?

Hoeby commented 5 years ago

@Hoeby do I need to follow the link that you sent because the latest raspbian version works with Bluetooth already and it connects to my Bluetooth speaker whenever I restart my pi . I get errors with my mic saying that it is not connected but I'm using the USB mic and it doesn't work . The mic is working and I can see that the USB connection is working .

The link has nothing to do with the problem you have about changing .asoundrc after reboot.

Log in on your Pi and give the next command sudo chmod 0444 ./.asoundrc There should be no error, when there is an error, please post the error here in this thread. After done the command, change the .asoundrc to what you need and reboot the Pi. After reboot, check to .asoundrc file if it's OK by now.

You first need to get the problems solved with your .asoundrc file, before going further.

First test this, but be sure that the .asoundrc file doesn't change after reboot. This needs to be stable. When it is stable, go futher with your gassistpi install When having errors, but a stable .asoundrc file, post what your error is. The error you posted has no sence to look over, when your soundcard is not right configured