synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
944 stars 101 forks source link

faster speed tts for Jabra 510 USB speaker #119

Closed comperta closed 4 years ago

comperta commented 4 years ago

Hy, In order to make Jabra 510 USB speaker to work with Rhasspy, we need to change the setting in /etc/asound.conf by adding some lines regarding to sampling rate. Otherwise, its tts always play 16000Hz wav file at faster speed which is too weird to be understood.

actually the /etc/asound.conf look like :

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 "hw:1,0"
  }
}

and for jabra we need :

pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}
pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
    rate 48000
  }
}
pcm.speaker {
  type plug
  slave {
    pcm "hw:1,0"
  }
}

Can we have a option in Hass.io: add-on details menu audio to force the rate at 48000 ?

frkos commented 4 years ago

I have the same problem... My mic volume is too low, so I need to amend asound.conf inside hassio addon. Still trying to find a solution =(

frkos commented 4 years ago

I've found a way... please check my post here https://community.rhasspy.org/t/hass-io-addon-make-rhasspy-use-custom-asound-conf/106

comperta commented 4 years ago

Thanks @frkos for the idea. But I can't do it with my system. I use this image : https://github.com/home-assistant/hassos/releases/download/3.7/hassos_rpi3-3.7.img.gz and I can't Run on host system this command : sudo docker container ls | grep rhasspy

I try this way : https://developers.home-assistant.io/docs/en/hassio_debugging.html but I can't do anything ... everytime I try to copy, I have this error : /.asoundrc: read-only file system

frkos commented 4 years ago

Ohhh.... it is hassOS limitation((( I have hassio installed over raspbian

Can you edit any files in this folder? /usr/share/hassio/addons/git/75f2ff60/rhasspy

keith721 commented 4 years ago

I have a Jabra 410 USB speaker and noticed this same thing, today. Pre-recorded WAV files play fine, but anything recorded from the microphone (at 16KHz) is speeded up greatly, and sounds like chipmunk speech. (This is probably why my wake word processing is failing.)

Found this other asoundrc file which works for properly recognizing and playing back speech at the correct pitch. For both arecord and aplay output devices, I use the value 'sysdefault'.

comperta commented 4 years ago

Thanks @keith721 for the asoundrc file. Did you use a hassOS like me ? I can't write the file inside my system.

keith721 commented 4 years ago

I use a Debian Server system, with Docker containers. To copy the asoundrc file into the container, I used the 'docker cp' command.

with hassOS, I'm not certain what is possible. :(

comperta commented 4 years ago

Hi @synesthesiam ,

any idea how I can do that on HassOS ?

frkos commented 4 years ago

@comperta could you check this?

Can you edit any files in this folder? /usr/share/hassio/addons/git/75f2ff60/rhasspy

If you can edit, so just add COPY command to Dockerfile. I use this method

Or you can fork hassio addon on github

comperta commented 4 years ago

thanks @frkos but I can't find :

/usr/share/hassio/addons/git/75f2ff60/rhasspy

maybe I am doing something wrong :)

the only way I find with hassOS to connect to docker is :

SSH access through port 22222

but with this I am initially be logged in to Hass.io CLI. to acces to the host system I use the 'login' command.

I will try fork hassio addon on github, but this is not "optimal"

comperta commented 4 years ago

I've found a way , thanks to you @frkos (and @keith721 for the .asoundrc file)

this is what I have made : https://developers.home-assistant.io/docs/en/hassio_debugging.html => use debugging mode on port 22222 with an authorized_keys on a USB drive

then access to the host system with : login Run sudo docker container ls | grep rhasspy on host system (Rhasspy addon should be started) and find Rhasspy container ID Run on host system to accessing the Rhasspy's container bash : docker exec -it 11c8a7e34ea6 /bin/bash here and below replace 11c8a7e34ea6 with your container id Run , to use wget command : apt-get install wget Run to create .asoundrc wget https://gist.github.com/ScottJWalter/3ec644d2eb180d145db2b42c6ad13b53/raw/8c1f03e9f34ea6674f715297f9de08b4db9f4ebe/.asoundrc -P /root/

With the command above we create .asoundrc which overrides default asound.conf That’s all. You should see effect immediately

Important note: every time you restart Hassio addon you need to copy the file again

comperta commented 4 years ago

@synesthesiam if you read this, and if you have time to implant this in the addon, this will be great :)

synesthesiam commented 4 years ago

OK, I think I see what you mean. A way to have Rhasspy copy a .asoundrc over to the home directory (/root in this case) when it starts?

frkos commented 4 years ago

@synesthesiam It would be really helpful for Hassio addon users🤓

comperta commented 4 years ago

@synesthesiam thanks for the reply, it will be great if you can also detect in the options panel (see my capture screen) the mention of a Jabra in the audio output and use the .asoundrc file for jabra

image

synesthesiam commented 4 years ago

Hass.io is supposed to set whatever you select as the default device in ALSA for the add-on. Does it not work to always describe settings for the default device in asoundrc?

comperta commented 4 years ago

Hi @synesthesiam ,

I think this should work

comperta commented 4 years ago

Hi @synesthesiam ,

thanks for the add option in CONFIG : image

but should I put the "link" for the asoundrc file ? something like : image or should I add the configuration directly here ? image

both of them not working . the first option put " /share/rhasspy/profiles/fr/.asoundrc" inside the /root/.asoundrc and the seconde one I can't save the CONFIG.

did I make something wrong ?

frkos commented 4 years ago

Hi @comperta Yes, you can't copy and paste it Please check my config here

https://community.rhasspy.org/t/hass-io-addon-make-rhasspy-use-custom-asound-conf/106/16?u=frkos

comperta commented 4 years ago

Hi @frkos

"\n to have single line" 👍

that works now.

comperta commented 4 years ago

Thank to everyone :-)