rhasspy / rhasspy3

An open source voice assistant toolkit for many human languages
MIT License
295 stars 23 forks source link

write() failed: Broken pipe #29

Open Shulyaka opened 1 year ago

Shulyaka commented 1 year ago

Hi! I've been trying it out on my Raspberry Pi. Unfortunately I can't make it work. The individual parts seems to be working fine, but the pipeline is not working properly. It recognizes the words I am saying to it,

[denis@speaker rhasspy3]$ LANG=en_US.UTF8 script/run bin/pipeline_run.py --debug
DEBUG:rhasspy3.core:Loading config from /home/denis/rhasspy3/rhasspy3/configuration.yaml
DEBUG:rhasspy3.core:Loading config from /home/denis/rhasspy3/config/configuration.yaml
DEBUG:rhasspy3.program:mic_adapter_raw.py ['--rate', '16000', '--width', '2', '--channels', '1', 'parecord --client-name=porcupine --rate=16000 --channels=1 --format=s16le --raw --property=media.software=Rhasspy']
DEBUG:rhasspy3.program:client_unix_socket.py ['var/run/faster-whisper.socket']
DEBUG:rhasspy3.program:.venv/bin/python3 ['bin/porcupine_stream.py', '--model', '/home/denis/rhasspy3/config/data/wake/porcupine1/resources/keyword_files_de/raspberry-pi/ananas_raspberry-pi.ppn', '--lang_model', '/home/denis/rhasspy3/config/data/wake/porcupine1/lib/common/porcupine_params_de.pv']
DEBUG:rhasspy3.wake:detect: processing audio
DEBUG:rhasspy3.wake:detect: Detection(name='ananas_raspberry-pi', timestamp=49831396948773)
DEBUG:rhasspy3.program:vad_adapter_raw.py ['--rate', '16000', '--width', '2', '--channels', '1', '--samples-per-chunk', '512', '--timeout-seconds', '45', 'script/speech_prob "share/silero_vad.onnx"']
DEBUG:rhasspy3.vad:segment: processing audio
DEBUG:rhasspy3.vad:segment: speaking started
DEBUG:rhasspy3.vad:segment: speaking ended
write() failed: Broken pipe

Same happens on asr_transcribe, regardless of whether it is a subprocess or a server/client:

[denis@speaker rhasspy3]$ LANG=en_US.UTF8 script/run bin/asr_transcribe.py
INFO:asr_transcribe:Ready
{"type": "transcript", "data": {"text": " Hello, this is a test."}}
write() failed: Broken pipe

I am on master branch, this is my configuration.yaml:

programs:
  mic:
    parecord:
      command: |
        parecord --client-name=porcupine --rate=16000 --channels=1 --format=s16le --raw --property=media.software=Rhasspy
      adapter: |
        mic_adapter_raw.py --rate 16000 --width 2 --channels 1
  vad:
    silero:
      command: |
        script/speech_prob "share/silero_vad.onnx"
      adapter: |
        vad_adapter_raw.py --rate 16000 --width 2 --channels 1 --samples-per-chunk 512 --timeout-seconds 45
  asr:
    faster-whisper:
      command: |
        script/wav2text "${data_dir}/base" "{wav_file}"
      adapter: |
        asr_adapter_wav2text.py
    faster-whisper.client:
      command: |
        client_unix_socket.py var/run/faster-whisper.socket
  wake:
    porcupine1:
      command: |
        .venv/bin/python3 bin/porcupine_stream.py --model "${model}" --lang_model "${lang_model}"
      template_args:
        model: "${data_dir}/resources/keyword_files_de/linux/ananas_linux.ppn"
        lang_model: "${data_dir}/lib/common/porcupine_params_de.pv"
  handle:
    date_time:
      command: |
        bin/date_time.py
      adapter: |
        handle_adapter_text.py
  tts:
    piper:
      command: |
        bin/piper --model "${model}" --output_file -
      adapter: |
        tts_adapter_text2wav.py
      template_args:
        model: "${data_dir}/en-us-lessac-low.onnx"
    piper.client:
      command: |
        client_unix_socket.py var/run/piper.socket
  snd:
    paplay:
      command: |
        paplay --rate=22050 --format=s16le --channels=1 --raw --property=media.software=Rhasspy
      adapter: |
        snd_adapter_raw.py --rate 22050 --width 2 --channels 1

servers:
  asr:
    faster-whisper:
      command: |
        script/server --language "en" "${data_dir}/tiny-int8"
  tts:
    piper:
      command: |
        script/server "${model}"
      template_args:
        model: "${data_dir}/en-us-lessac-low.onnx"

pipelines:
  default:
    mic:
      name: parecord
    vad:
      name: silero
    asr:
      name: faster-whisper.client
    wake:
      name: porcupine1
      template_args:
        model: "${data_dir}/resources/keyword_files_de/raspberry-pi/ananas_raspberry-pi.ppn"
    handle:
      name: repeat
    tts:
      name: piper.client
    snd:
      name: paplay

Unfortunately, the debug logs are not extensive enough for me to understand at which point it fails.

Shulyaka commented 1 year ago

Update: Looks like the error is from my mic command ('parecord'). Might be not related to rhasspy. I will close the issue until I find more evidence.

Shulyaka commented 1 year ago

After some investigation I have to reopen the issue. While the error indeed comes from parecord, the error also repeats with arecord, even though with higher success rate (probably due to different buffer size in arecord and parecord). The process is terminated on purpose (end of ASR), however rhasspy gets block after that because it did not read all the output from the process. I'll make a PR to fix that shortly.