Sounds are to high pitched

Hello there,

after trying to get my external sound card working with Rhasspy and the RPi itself I finally managed to get it working. Now the only problem is, that the .wav file sounds normal using the command:

pi@himbipi2:~/.config/rhasspy/profiles/en/sounds $ suaplay end_of_input.wav
Playing WAVE ‘end_of_input.wav’ : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo

If I trigger the sound with my voice it sounds very high pitched.
Here is my config:
I had to enter pcm "hw:3,0" manually in the /etc/asound.conf aswell as into the profile.json as "device": "hw:3,0"

/etc/asound.conf:

pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}

pcm.mic {
   type softvol
   slave {
     pcm "array"
   }
   control {
     name "MicArray Master"
        card "MATRIXIOSOUND"
   }
}

pcm.speaker {
  type plug
  slave {
    pcm "hw:3,0"
  }
}

pcm.array {
  type plug
  slave {
    pcm "hw:MATRIXIOSOUND"
  }
}

pcm.channel_1 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }
    bindings.0  0
}

pcm.channel_2 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  1
} 

pcm.channel_3 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  2
} 

pcm.channel_4 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  3
} 

pcm.channel_5 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  4
} 

pcm.channel_6 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  5
} 

pcm.channel_7 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  6
} 

pcm.channel_8 {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings.0  7
} 

pcm.all_channels {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:2,0"
        channels 8
    }    
    bindings {
            0 0
            0 1
            0 2
            0 3
            0 4
            0 5
            0 6
            0 7
    }
} 

profile.json:

{
    "microphone": {
        "arecord": {
            "device": "hw:CARD=MATRIXIOSOUND,DEV=0"
        },
        "system": "arecord"
    },
    "mqtt": {
        "enabled": true,
        "host": "192.168.178.19"
    },
    "sounds": {
        "aplay": {
            "device": "hw:3,0"
        },
        "error": "${RHASSPY_PROFILE_DIR}/sounds/error.wav",
        "recorded": "${RHASSPY_PROFILE_DIR}/sounds/end_of_input.wav",
        "wake": "${RHASSPY_PROFILE_DIR}/sounds/start_of_input.wav"
    },
    "speech_to_text": {
        "system": "kaldi"
    },
    "text_to_speech": {
        "system": "picotts"
    },
    "wake": {
        "snowboy": {
            "apply_frontend": true,
            "model": "snowboy/jarvis.umdl",
            "sensitivity": "0.8,0.80"
        },
        "system": "snowboy"
    }
}

Anyone has an idea how to fix the high pitch?

Thank you :smiley:

I recently am getting a lot of trouble with alsa - and most Linux distros have moved on to using pulseaudio. It kind of works pretty ok (even headless) on a raspberry pi. In rhasspy you can then define local commands for recording (parec -d “device_from_pctl_list_sources” --rate 16000 --channel 1) and playing (paplay) - that made most of my problems go away.

Any interest in trying that route?

There is though a bug in newest rhasspy-voltron messing up the argument string of paplay - workaround is using square brackets and giving arguments in python notation (@synesthesiam).

I am not really sure why this ‘opinion’ turns up so much as most distro’s have not moved to using pulseaudio.
The basic Alsa system is there and pulseaudio sits ontop of the basic Alsa system.
They dont use asound.conf utils or plugins with preference for pulse audio but alsa is still definately still there and essential.

Pulseaudio starts to get difficult when running headless and with docker often needs an external server for audio to make easy install.

problem with Alsa is the conf file can be a bewildering array and the debugging is poor.

I can’t see anywhere there where you are doing any rate conversion.
If the above runs on a clean image no Rhasspy with no pitch shift its not Alsa or your hardware.
I know nothing about the MatrixIO and this is just curiosity but why do you seperate channels out to seperate PCMs and not just a single pcm with the bindings for channels you require?

But dunno really but like the current strange error I am getting with just a vanilla pulseaudio install for a AEC test.

May 22 22:08:24 raspberrypi pulseaudio[769]: E: [alsa-source-USB Audio] alsa-source.c: ALSA woke us up to read new data from the device, but there was actually nothing to read.
May 22 22:08:24 raspberrypi pulseaudio[769]: E: [alsa-source-USB Audio] alsa-source.c: Most likely this is a bug in the ALSA driver 'snd_usb_audio'. Please report this issue to the ALSA developers.
May 22 22:08:24 raspberrypi pulseaudio[769]: E: [alsa-source-USB Audio] alsa-source.c: We were woken up with POLLIN set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.

Without the use of Alsa its still very much there and pulseaudio sits ontop of it.

Just arecord each -Dplug:[pcm] and playback and see what you get also.

Well honestly I’m not experienced either in alsa and pulseaudio. I’m happy about the fact it’s working at the moment. I would really appreciate any advices on fixing the strange pitch of the sound in alsa.

Yes, on a clean image without rhasspy it runs as expected without any pitch. MatrixIO is the microphone array I use to record my speech. Basically the setting in /etc/asound.conf were defined by the system, maybe it has to do with the external soundcard, which may support surroundsound. Have you got any advice, how I could update my /etc/asound.conf? Like I said, I’m not very experienced :frowning:

Have you tried with arecord and aplay? With aplay -L you get a list of devices that you can use for the-d parameter.

Regarding pulseaudio @rolyan_trauts, I am not at all a friend of pulseaudio nor systemd, but I had some strange hardware that actually was behaving better in pulseaudio than with alsa (bluetooth audio devices, sound card extensions on the pi - mainly regarding the enumeration and mixer access), that’s why I suggested it.

1 Like

Unfortunately no but sounds like Alsa and your hardware is not causing the pitch change and guess it must be at the point of Rhaspy capture.

Guess you could try setting the default rate convertor to sample rate
defaults.pcm.rate_converter "samplerate"
In asound.conf

Surround sound are just channels in a pcm usually and dunno just a bit unusual to split like that as then as pcms they can become out of sync, but hey.

Looks like alsa is ok and you recorded and played back with arecord - D[pcm] -c1 -r 16000 -f S16_LE rec.wav then aplay rec.wav ok then its not likely to be alsa but setting or capture somewhere.

As far as I understood only aplay is available for Rhasspy.
aplay -L outputs:

pi@himbipi2:~/sounds $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
mic
speaker
array
channel_1
channel_2
channel_3
channel_4
channel_5
channel_6
channel_7
channel_8
all_channels
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dmix:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Hardware device with all software conversions
sysdefault:CARD=Dummy
    Dummy, Dummy PCM
    Default Audio Device
dmix:CARD=Dummy,DEV=0
    Dummy, Dummy PCM
    Direct sample mixing device
dsnoop:CARD=Dummy,DEV=0
    Dummy, Dummy PCM
    Direct sample snooping device
hw:CARD=Dummy,DEV=0
    Dummy, Dummy PCM
    Direct hardware device without any conversions
plughw:CARD=Dummy,DEV=0
    Dummy, Dummy PCM
    Hardware device with all software conversions
dmix:CARD=MATRIXIOSOUND,DEV=1
    MATRIXIO-SOUND,
    Direct sample mixing device
dsnoop:CARD=MATRIXIOSOUND,DEV=1
    MATRIXIO-SOUND,
    Direct sample snooping device
hw:CARD=MATRIXIOSOUND,DEV=1
    MATRIXIO-SOUND,
    Direct hardware device without any conversions
plughw:CARD=MATRIXIOSOUND,DEV=1
    MATRIXIO-SOUND,
    Hardware device with all software conversions
sysdefault:CARD=Device
    USB PnP Audio Device, USB Audio
    Default Audio Device
front:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Front speakers
surround21:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Direct sample mixing device
dsnoop:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Direct sample snooping device
hw:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Hardware device with all software conversions

I’ve therefore I’ve selected the corresponding plughw:

"sounds": {
    "aplay": {
        "device": "plughw:CARD=Device,DEV=0"
    },

And now it’s working properly.

Thank you very much :smiley:

3 Likes