Step by step: Raspberry Pi offline voice recognition with SOPARE

After a round of optimization, refactoring, bug fixing and testing it is time for a new blog post. Since fundamentals have changed and due to public requests, we do a step-by-step tutorial. First of all, the good news: SOPARE 1.5 is out and was successful developed, installed and tested on Raspbian Wheezy, Jessie and Stretch. In addition, people mentioned that SOPARE works on Orange Pi and on some Ubuntu versions. Just in case you have no idea what SOPARE is let’s do a quick introduction:

SOPARE stands for SOund PAttern REcognition and is a Python project developed on and for the Raspberry Pi. The goal is to provide offline and real time audio processing for some words that must be trained upfront.

Offline and real time voice speech recognition for Raspberry Pi

As SOPARE is able to learn sounds from training sessions SOPARE is able to identify the same sound later on even under different circumstances. This means that you can train words in any languages. Or just sounds like doorbells, knocks and whatever you want. Of course, there are limitations. However, SOPARE provides a simple plug-in architecture for further processing. Here are some real life operational areas: SOPARE runs 24/7 and controls smart home things like lights (on/off), a magic mirror (wake up, change views, …) and another installation controls a robotic arm via voice commands. The source code and even more information is available on GitHub.

You want to see SOPARE in action? Here is a 32 second video that shows the potential:

Now let us start with the hardware requirements. You need a computer. Yep, seriously. As SOPARE was developed for and on a Raspberry Pi we go with this one – even if SOPARE runs on other hardware as well. Make sure that the hardware comes with a multi core processor. This means Raspberry Pi 2 or 3. Please note: The Pi zero was not tested and could be too weak even if the “0” comes with 2 cores. SOPARE does not run on older hardware like Raspberry Pi B or B+ due to the lack of multi-core processors. Of course, you need a power supply and a micro SD card if you go with the Raspberry Pi.

Raspberry Pi with Mic

Then you need a microphone. Maybe some USB-mic. The microphone is extremely important and should fit your own requirements. For example: If you want speech recognition across a large distance (more that 1 meter) you may find out that the cheap USB-mic for 5 Euros does not do the trick. But if you plan to speak directly into the microphone the same mic could do the job just perfect. I’m using different microphones for different environments and requirements.

That’s it for the hardware. Now let’s talk about software. SOPARE should run on every Raspbian version that is out there. The latest version is Stretch. All of my Raspberry Pis are running the “lite” version without a desktop UI. But this is up to you and you can choose whatever you prefer. There is some good information available how to download, install and configure Raspbian. I don’t cover this topic as it would get out of hand.

Now you should have a computer, a mic and the operating system installed and configured. In terms of Raspbian you already got most of the software for the further installation. Only some required libraries must be installed manually with the following commands:

sudo apt-get update
sudo apt-get install build-essential python-pyaudio python-numpy python-scipy python-matplotlib

I recommend to create a development directory in your home directory but this is really optional. In case you follow my recommendation execute the following commands:

cd 
mkdir dev
cd dev

You are now ready to install SOPARE from GitHub:

git clone https://github.com/bishoph/sopare.git

Voilá. To really be ready and to follow the complete instructions we need two more directories:

cd sopare
mkdir tokens
mkdir samples

You successful installed SOPARE. Congratulations. We can fire up some tests to find out if all requirements are met and if the microphone is configured and used correctly. Start SOPARE and the audio test with the following commands:

python sopare.py -u
python test/test_audio.py

Let us assume that everything went well and you got no errors. In that case you see something like this:

sopare 1.5.1
starting unit tests...
...
unit_tests run successful!
done.

test_audio init...
... ALSA related information ...
testing different SAMPLE_RATEs ... this may take a while!

Your sopare/config.py recommendations:

SAMPLE_RATE = 48000
CHUNK = 512
THRESHOLD = 100

Great! You can now edit the configuration and change the file accordingly to the recommendations:

nano config/default.ini

As soon as you saved the config you are ready to do a first training round. Let’s train the word “test”. This is easy as eating cake:

./sopare.py -v -t test

Start saying the word “test” shortly after the line

INFO:sopare.recorder:start endless recording

appears on the screen. You should see lots of lines rush over your monitor. This is good as SOPARE logs some debug information. If the lines are rushing before you said something SOPARE started the training because something triggered the THRESHOLD. In that case I recommend to delete the trained file(s) and start the training again, maybe with a higher THRESHOLD.
Here is the command to delete the files and the dictionary and start again:

rm dict/*.raw
./sopare.py -d "*"

You can repeat the training round a few times. Normally 3 times is enough to get first results.
After the training SOPARE must create an internal dictionary from the training:

./sopare.py -c

Finally we reached the end of the step-by-step tutorial. You may want to check if your trained words are recognized, right? Here we go. Start SOPARE in endless loop mode and say “test”:

./sopare.py -l

Depending on your mic, your environment, the count of test rounds and lots of other things you should see that SOPARE is able to recognize the word test as it appears on the screen in square brackets.

['test']

Amazing. You can now fine tune, train more or different words or write your custom plugin. See the other available content for more information. Leave me a comment and tell me about your experience and your achievement. The video video tutorial for this post:

Happy voice control and have fun!

274 thoughts on “Step by step: Raspberry Pi offline voice recognition with SOPARE

  1. Thank you for the great information! Unfortunately, I am not sure how to put it all together.

    I was able to install Sopare, train it, etc. I even saw the comment on how to apply it to gpio, but I am trying to control multiple functions with commands. What I don’t understand is, how do you use the readable output to trigger a section of code? I don’t understand what rawbuf or the 3 arguments are.

    When I look at the robot arm code, for example, I don’t see how i could apply this to gpio / motor controllers so that the computer takes the voice command it hears through a microphone (ie., ‘test’ or whatever the word is and uses) in the code? How / what line does the code “take in” the voice input information and use it to trigger something? I was expecting something like #this is where the voice command comes from and #this is where the voice command goes.

      • Thank you for the response!

        Yes, I was happy to see that post, but the problem is not knowing how to control via GPIO, the problem is, I don’t know how to link the voice command to that code. I see to add the ‘readable_results” piece, but nothing is being piped into that variable as far as I can tell. In other words, when I say “test” or “forward” or whatever, this doesn’t seem to link to any line of code to make it activate the GPIO as needed.

        Here is my code: (first I define the GPIO functions, then I added the sopare.py code with modifications to use those functions. I commented out all the things that didn’t apply, at least as I saw it.)

        #!/usr/bin/env python
        # -*- coding: utf-8 -*-

        import os
        import sys
        import time
        import RPi.GPIO as gpio
        #import usb.core, usb.util

        #RoboArm = usb.core.find(idVendor=0x1267, idProduct=0x000)
        #light = 0

        def init():
        gpio.setmode(gpio.BOARD)
        gpio.setup(7,gpio.OUT)
        gpio.setup(11,gpio.OUT)
        gpio.setup(13,gpio.OUT)
        gpio.setup(15,gpio.OUT)

        def forward(tf):
        init()
        gpio.output(7,True)
        gpio.output(11,True)
        gpio.output(13,True)
        gpio.output(15,False)
        time.sleep(tf)
        gpio.cleanup()

        def reverse(tf):
        init()
        gpio.output(7,True)
        gpio.output(11,False)
        gpio.output(13,True)
        gpio.output(15,True)
        time.sleep(tf)
        gpio.cleanup()

        def turn_left(tf):
        init()
        gpio.output(7,True)
        gpio.output(11,True)
        gpio.output(13,False)
        gpio.output(15,True)
        time.sleep(tf)
        gpio.cleanup()

        def turn_right(tf):
        init()
        gpio.output(7,False)
        gpio.output(11,True)
        gpio.output(13,True)
        gpio.output(15,False)
        time.sleep(tf)
        gpio.cleanup()

        def pivot_left(tf):
        init()
        gpio.output(7,True)
        gpio.output(11,True)
        gpio.output(13,True)
        gpio.output(15,True)
        time.sleep(tf)
        gpio.cleanup()

        def pivot_right(tf):
        init()
        gpio.output(7,True)
        gpio.output(11,False)
        gpio.output(13,True)
        gpio.output(15,False)
        time.sleep(tf)
        gpio.cleanup()

        #!/usr/bin/env python
        # -*- coding: utf-8 -*-

        “””
        Copyright (C) 2015 – 2018 Martin Kauss (yo@bishoph.org)

        Licensed under the Apache License, Version 2.0 (the “License”); you may
        not use this file except in compliance with the License. You may obtain
        a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
        WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
        License for the specific language governing permissions and limitations
        under the License.
        “””

        import sys
        import getopt
        import sopare.config as config
        import sopare.util as util
        import sopare.recorder as recorder
        import sopare.log as log
        import test.unit_tests as tests
        from sopare.version import __version__

        def main(argv):
        endless_loop = False
        debug = False
        outfile = None
        infile = None
        dict = None
        plot = False
        wave = False
        error = False
        cfg_ini = None

        recreate = False
        unit = False

        print (“sopare “+__version__)

        if (len(argv) > 0):
        try:
        opts, args = getopt.getopt(argv, “ahelpv~cous:w:r:t:d:i:”,
        [“analysis”, “help”, “error”, “loop”, “plot”, “verbose”, “wave”, “create”, “overview”, “unit”,
        “show=”, “write=”, “read=”, “train=”, “delete=”, “ini=”
        ])
        except getopt.GetoptError:
        usage()
        sys.exit(2)
        for opt, arg in opts:
        if (opt in (“-h”, “–help”)):
        usage()
        sys.exit(0)
        if (opt in (“-e”, “–error”)):
        error = True
        if (opt in (“-l”, “–loop”)):
        endless_loop = True
        if (opt in (“-p”, “–plot”)):
        if (endless_loop == False):
        plot = True
        else:
        print (“Plotting only works without loop option!”)
        sys.exit(0)
        if (opt in (“-v”, “–verbose”)):
        debug = True
        if (opt in (“-~”, “–wave”)):
        wave = True
        if opt in (“-c”, “–create”):
        recreate = True
        if opt in (“-o”, “–overview”):
        show_dict_ids(debug)
        sys.exit(0)
        if opt in (“-a”, “–analysis”):
        show_dict_analysis(debug)
        sys.exit(0)
        if opt in (“-s”, “–show”):
        show_word_entries(arg, debug)
        sys.exit(0)
        if opt in (“-w”, “–write”):
        outfile = arg
        if opt in (“-r”, “–read”):
        infile = arg
        if opt in (“-t”, “–train”):
        dict = arg
        if opt in (“-d”, “–delete”):
        delete_word(arg, debug)
        sys.exit(0)
        if opt in (“-i”, “–ini”):
        cfg_ini = arg
        if opt in (“-u”, “–unit”):
        unit = True

        cfg = create_config(cfg_ini, endless_loop, debug, plot, wave, outfile, infile, dict, error)

        if (recreate == True):
        recreate_dict(debug, cfg)
        sys.exit(0)

        if (unit == True):
        unit_tests(debug, cfg)
        sys.exit(0)

        recorder.recorder(cfg)

        def create_config(cfg_ini, endless_loop, debug, plot, wave, outfile, infile, dict, error):
        if (cfg_ini == None):
        cfg = config.config()
        else:
        cfg = config.config(cfg_ini)
        logger = log.log(debug, error, cfg)
        cfg.addsection(‘cmdlopt’)
        cfg.setoption(‘cmdlopt’, ‘endless_loop’, str(endless_loop))
        cfg.setoption(‘cmdlopt’, ‘debug’, str(debug))
        cfg.setoption(‘cmdlopt’, ‘plot’, str(plot))
        cfg.setoption(‘cmdlopt’, ‘wave’, str(wave))
        cfg.setoption(‘cmdlopt’, ‘outfile’, outfile)
        cfg.setoption(‘cmdlopt’, ‘infile’, infile)
        cfg.setoption(‘cmdlopt’, ‘dict’, dict)
        cfg.addlogger(logger)
        return cfg

        def recreate_dict(debug, cfg):
        print (“recreating dictionary from raw input files…”)
        utilities = util.util(debug, cfg.getfloatoption(‘characteristic’, ‘PEAK_FACTOR’))
        utilities.recreate_dict_from_raw_files()

        def delete_word(dict, debug):
        if (dict != “*”):
        print (“deleting “+dict+” from dictionary”)
        else:
        print (“deleting all enttries from dictionary”)
        utilities = util.util(debug, None)
        utilities.deletefromdict(dict)

        def show_word_entries(dict, debug):
        print (dict+” entries in dictionary:”)
        print
        utilities = util.util(debug, None)
        utilities.showdictentry(dict)

        def show_dict_ids(debug):
        print (“current entries in dictionary:”)
        utilities = util.util(debug, None)
        utilities.showdictentriesbyid()

        def show_dict_analysis(debug):
        print (“dictionary analysis:”)
        utilities = util.util(debug, None)
        analysis = utilities.compile_analysis(utilities.getDICT())
        for id in analysis:
        print (id)
        for k, v in analysis[id].iteritems():
        print (‘ ‘ + str(k) + ‘ ‘ + str(v))

        def unit_tests(debug, cfg):
        print (“starting unit tests…”)
        tests.unit_tests(debug, cfg)
        print (“done.”)

        def usage():
        print (“usage:\n”)
        print (” -h –help : this help\n”)
        print (” -l –loop : loop forever\n”)
        print (” -e –error : redirect sdterr to error.log\n”)
        print (” -p –plot : plot results (only without loop option)\n”)
        print (” -v –verbose : enable verbose mode\n”)
        print (” -~ –wave : create *.wav files (token/tokenN.wav) for”)
        print (” each detected word\n”)
        print (” -c –create : create dict from raw input files\n”)
        print (” -o –overview : list all dict entries\n”)
        print (” -s –show [word] : show detailed [word] entry information”)
        print (” ‘*’ shows all entries!\n”)
        print (” -w –write [file] : write raw to [dir/filename]\n”)
        print (” -r –read [file] : read raw from [dir/filename]\n”)
        print (” -t –train [word] : add raw data to raw dictionary file\n”)
        print (” -d –delete [word] : delete [word] from dictionary and exits.”)
        print (” ‘*’ deletes everything!\n”)
        print (” -i –ini [file] : use alternative configuration file\n”)
        print (” -a –analysis : show dictionary analysis and exits.\n”)
        print (” -u –unit : run unit tests\n”)

        main(sys.argv[1:])

        ”’
        if (RoboArm != None):
        print (‘Robotic arm connected!’)
        else:
        print (‘Robotic arm not connected or offline!’)

        def Light():
        global light
        light = 1 – light
        RoboArm.ctrl_transfer(0x40,6,0×100,0,[0,0,light],3)

        def AllOff():
        RoboArmOff = usb.core.find(idVendor=0x1267, idProduct=0x000)
        attemtps = 0
        while True:
        try:
        RoboArmOff.ctrl_transfer(0x40,6,0×100,0,[0,0,light],3)
        break
        except:
        if (attemtps == 0):
        print (‘USB con error … consider an emergency shutdown!’)
        try:
        RoboArmOff = usb.core.find(idVendor=0x1267, idProduct=0x000)
        except:
        print (‘Shit. Manual emergency shutdown required!’)
        attemtps += 1
        if (attemtps == 20):
        break

        def MoveArm(Duration, ArmCmd):
        RoboArm.ctrl_transfer(0x40,6,0×100,0,ArmCmd,3)
        time.sleep(Duration)
        ”’

        def run(readable_results, data, rawbuf):
        # if (len(readable_results) > 2 or len(readable_results) == 0):
        # return
        # if RoboArm is None:
        # print (‘Robotic arm not connected or offline!’)
        # return
        try:
        if (‘forward’ in readable_results): # forward
        forward(1)
        elif (‘back’ in readable_results): # reverse
        reverse(1)
        elif (‘right’ in readable_results): # turn right
        turn_right(1)
        elif (‘pivot’ in readable_results): # turn left
        turn_left(1)
        # elif (‘stop’ in readable_results): # pivot right
        # pivot_right(2)
        # elif (‘test’ in readable_results): # pivot left
        # pivot_left(2)
        # elif (‘stop’ in readable_results and ‘now’ in readable_results): # stop
        # break
        elif (‘test’ in readable_results): # test
        forward(2)
        except Exception as err:
        print err
        # finally:
        # AllOff()

        run(readable_results,1,1)

        • PS. everything is properly indented, pasting here seemed to take out formatting. also the “readable_results” code is at the end for the GPIO control, but again, it doesn’t seem to do anything. the voice commands all work though, they just don’t do anything.

        • SOPARE calls your plugin in the plugin directory and another sub directory with the name “__init__.py”

          1) cd sopare/plugins
          2) Create a custom directory in the plugin directory (e.g.: mkdir my_gpio_custom_plugin)
          3) Create a python file with the name “__init__.py” (e.g. you copy the print plugin)
          4) Create your custom code and the conditions in the run function for your trained identifiers
          5) Start SOPARE
          6) SOPARE now calls automatically the function “def run(readable_results, data, rawbuf):” whenever an identifier is recognized and the recognized values are in the array “readable_results”
          7) Your custom code and your conditions are executed which means you control your robot

          Hope that helps. Seems my next tutorial will be about plugins 😉

          • THANK YOU! I was nervously going through your instructions. I have been trying to do voice control for 2 weeks (I’m new to robotics and coding) and every method I tried has been failing. I knew when I came across your tutorial it was well written and well thought out.

            After your notes above, the robot did it! You probably can’t image how happy I am about this. I literally just threw my arms up and cheered when the robot moved! 🙂

          • Great! You are welcome and I’m glad that you like the project, the tutorials and it works for you.

            Have fun and happy robot control. Spread the word 😉

  2. try to get it started.
    have all software installed:
    python sopare.py -u runs fine
    can run mic (on usb) : arecord /home/pi/Desktop/a.wav -D sysdefault:CARD=1 works fine
    have changed
    nano ~.asoundrc

    pcm.!default {
    type hw
    card 1
    }

    ctl.!default {
    type hw
    card 1
    }

    and
    sudo nano /usr/share/alsa/alsa.conf

    defaults.ctl.card 0
    defaults.pcm.card 0

    and change them to

    defaults.ctl.card 1
    defaults.pcm.card 1

    get error with python test/test_audio.py
    test_audio init…
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    same as with : python
    import pyaudio
    p = pyaudio.PyAudio()

    any advice, change of arameters to get it work?

    Thanks

    • As I don’t see any errors and just warnings from ALSA my only recommendation is that you can clean your alsa.conf file and then have some serious fun 🙂

      Cleaning means that you comment out the stuff that appears as warning, here is an example that should help you:

      #
      #  PCM interface
      #
      ...
      #pcm.rear cards.pcm.rear
      ...
      
  3. tried again with a clean updated / upgraded stretch on rpi3 no joy ..
    did :
    sudo python sopare.py
    sopare 1.5.0
    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 pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
    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

    then nothing happens
    sudo python sopare -u
    gives:
    sudo python sopare.py -u
    sopare 1.5.0
    starting unit tests…
    starting analyze tests…
    analyze test preparation…
    testing analyze get_match…
    testing normal conditions (1)[u’test1′] == [u’test1′]
    testing normal conditions (2)[u’test1′, u’test3′] == [u’test1′, u’test3′]
    testing normal conditions (3)[u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′]
    testing leading space [u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′]
    testing ending space [u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′]
    testing correct order [u’test1′, u’test3′, u’test2′, u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′, u’test1′, u’test3′, u’test2′]
    testing strict length [u’test1′, u’test3′, ”, u’test2′] == [u’test1′, u’test3′, ”, u’test2′]
    testing false leading results [”, u’test1′, ”, u’test2′] == [”, u’test1′, ”, u’test2′]
    analyze tests run successful.
    filter test preparation…
    testing filter n_shift…
    testing n_shift [5, 6, 7, 8, 9, 10, 11, 12, 13, 14] == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
    testing n_shift [15, 16, 17, 18, 19, 20, 21, 22, 23, 24] == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
    testing n_shift [25, 26, 27, 28, 29, 30, 31, 32, 33, 34] == [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
    filter tests run successful.
    unit_tests run successful!
    done.

    you stated: “clean your alsa.conf file ” == delete and re-install python-pyaudio?

    Karl

    • No need to delete or uninstall pyaudio. Clean the file

      sudo nano /usr/share/alsa/alsa.conf
      

      as shown and comment out the lines that appear in the warnings.

      For example, if you see a line like this

      “ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear”

      then search for the term “cards.pcm.rear” and comment out the line like shown above.

  4. ok seems to do something..

    python test/test_audio.py
    test_audio init…
    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 pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
    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
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 48000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.0213333333333
    DEBUG:sopare.audio_factory:maxInputChannels: 128
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 5
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0213333333333
    testing different CHUNK sizes … this may take a while!

    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open

    Your sopare/config.py recommendations:

    SAMPLE_RATE = 44100
    CHUNK = 512
    THRESHOLD = 400

    ./sopare.py -v -t test
    sopare 1.5.0
    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 pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
    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
    INFO:sopare.analyze:checking for plugins…
    DEBUG:sopare.analyze:loading and initialzing plugins/print
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 48000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.0213333333333
    DEBUG:sopare.audio_factory:maxInputChannels: 128
    DEBUG:sopare.audio_factory:structVersion: 2
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 5
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0213333333333
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 48000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    WARNING:sopare.recorder:stream read error [Errno -9981] Input overflowed
    WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
    WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
    WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
    WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed

    on forever

    Karl

    • The recommendation for your environment is a sample rate of “44100” but you are using a sample rate of “48000”. Please change the sample rate in the config file according to the recommendation and the warning should vanish.

  5. ok got it to work with catching the errors and sending sigkill , then restarting itself :

    recorder.recorder(cfg)
    os.system(“python sopare.py “+ argList[-1]+” &”)
    os.kill(os.getpid(), signal.SIGTERM)

    in main:
    killOldPgm(os.getpid(),”sopare.py”)

    in recording:
    self.stop()
    return
    remove sys.exit .. that hangs

    def killOldPgm(myPID,pgmToKill):
    try:
    cmd= “ps -ef | grep ‘”+pgmToKill+”‘ | grep -v grep”
    ret = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0]
    lines=ret.split(“\n”)

    for line in lines:
    print (“killing ? “+ line)
    if len(line) < 10: continue
    items=line.split()
    pid=int(items[1])
    if pid == int(myPID): continue

    print "killing "+pgmToKill
    os.system("sudo kill -9 "+str(pid))
    except Exception, e:
    print ( u"killOldPgm in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))

    it seems the quality of the mic has a really strong impact ..

    thanks for this great piece of software

    Karl

    • Yes, indeed. I have tested a lot of microphones and the ones that work flawlessly are the more expensive ones. But I also using a 5€ mic that works as well but the distance is limited to around 0,5m.

      Now to your problem: First of all, you only get warnings and not an error. This is important. You should be able to run SOPARE and still get some results. Not saying best results but maybe decent results. What you can do is test different sample_rates. Test the following sample_rates one by one and see if the warnings disappear:

      SAMPLE_RATES to test : 8000, 11025, 12000, 16000, 22050, 32000, 44100, 48000

      EDIT: Your test_audio recommendation shows a recommended SAMPLE_RATES of “44100” so start using this one 😉

  6. the
    WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed

    repeats endlessly once started. thats why I added the self restart.

    dumb question, where are the results printed eg. [u’light’]. I would like to replace that with a method that performs some actions.

    Thanks

    Karl
    und viele Gruesse aus Dallas

  7. found the place where I can add the commands.. .. I am really impressed by this package. outstanding work ..

    waiting for a better mic .. arriving on Tuesday

  8. getting an error:
    in filter.py line 61:

    def get_chunked_norm(self, nfft):
    ….
    progessive += progessive * pf

    pf not defined, which is correct pf is not defined ..

  9. Hi Martin;
    I did every step you showed in the video.However when i try to test ./sopare.py -t “example” i got this error.

    sopare 1.5.0
    ALSA lib confmisc.c:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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 sysdefault
    ALSA lib confmisc.c:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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 sysdefault
    ALSA lib confmisc.c:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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 confmisc.c:767:(parse_card) cannot find card ‘0’
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
    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 dmix
    connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
    attempt to connect to server failed
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 268, in _feed
    send(obj)
    IOError: [Errno 32] Broken pipe

    • The issue is that there seems to be no sound device/mic: “ALSA lib confmisc.c:767:(parse_card) cannot find card ‚0‘”
      I can only guess but the steps are something like:

      * connect a mic
      * if connected and the same error occurs edit alsa.conf to make use of the mic
      * could be another issue related to your environment. Search internet for “alsa cannot find card 0” and see if you find a solution
      * …
      * clean your alsa.conf file to avoid wild messages

      Hope that help 🙂

      • Thanks for your answers Martin i did all of your steps.After i write ./sopare.py -t “go” i got this error ;
        sopare 1.5.0
        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 pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
        connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
        attempt to connect to server failed

        • Hi. There is no SOPARE error. The output comes from the ALSA system respective from pyaudio. As I don’t know anything about your environment so I can only recommend to clean your alsa.conf file to get rid of those warnings. I found a thread with the same message and the recommendation is also to clean your alsa config:

          https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=203547

          Check if you your system is capable of record audio by running the audio test SOPARE provides:

          python test/test_audio.py

  10. Hi,

    after disabling the internal sound card and adding following code to /etc/asound.conf and ~/.asoundrc
    [code]
    pcm.!default {
    type hw
    card 0
    }

    ctl.!default {
    type hw
    card 0
    }
    [/code]

    i start “python test/test_audi.py” and got this “Segmentation fault”…
    before doing the changes to the configs, i had errors on mass, jack-server and so on… like shown in posts above

    I have a Raspi3 and an Ugreen USB sound card 2.0 and an adafruit amplified mic.

    • A segmentation fault comes normally from code with low memory access: https://en.wikipedia.org/wiki/Segmentation_fault

      As SOPARE is written in Python and uses pyaudio as bride to the hardware I can only guess that you compiled something manually or you have installed some incompatible (lib-)versions. The error can be nearly anywhere in the system which means this goes beyond anything we could solve here with normal efforts 😉

      My recommendation is to set up a fresh and lean Raspbian system without X and install only the most necessary dependencies and try again.

      • This is a fresh installation, standard raspian without X, age of max. 10 minutes, sopare from git, and only the changes as mentioned.

        • There are apparently only two states. Either miles of error messages but the test is running, Threshold 33200 and no detection of the test word or the segmentation fault.

          • Sorry, but a segfault is something where I can’t help as it is too deep in the system ;(

            Anyway. The threshold seems to be very high so likely SOPARE never gets something useful to analyse. The threshold defines a peak volume when the mic input is passed to the analysis. In all of my working environments this value is below 1000 … just to give you an indication.

  11. Ok, then there is something wrong with the mic, or the pi usb power is to noisy. the treshold was mentioned from the soprare init test. will try a i2s mic array next. Thx

  12. Hallo,

    kann man Sopare auch beim pi 3 im Autostart hinzufügen?
    Wenn ja was müsste ich dann machen?

    Vielen Dank

    Mit freundlichen Grüßen

  13. Sollte gehen, besser ist aber SOPARE direkt als service zu starten. Ich kann beizeiten mal schreiben wie man das macht…

  14. Hey bishop,

    Iam getting threshold as 12600 which is too much. Do i have to configure alsa ??

    pi@raspberrypi:~/sopa/sopare $ python test/test_audio.py
    test_audio init…
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    ALSA lib pcm_dmix.c:1022:(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
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 48000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00797916666667
    DEBUG:sopare.audio_factory:maxInputChannels: 1
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 2
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    DEBUG:sopare.audio_factory:name: USB Device 0x46d:0x825: Audio (hw:1,0)
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.032
    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
    ERROR:sopare.audio_factory:Error: [Errno Invalid sample rate] -9997
    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
    ERROR:sopare.audio_factory:Error: [Errno Invalid sample rate] -9997
    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
    ERROR:sopare.audio_factory:Error: [Errno Invalid sample rate] -9997
    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
    ERROR:sopare.audio_factory:Error: [Errno Invalid sample rate] -9997
    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
    ERROR:sopare.audio_factory:Error: [Errno Invalid sample rate] -9997
    testing different CHUNK sizes … this may take a while!

    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.

    Your sopare/config.py recommendations:

    SAMPLE_RATE = 48000
    CHUNK = 512
    THRESHOLD = 12600

    Please reply.

  15. Hey,

    when i run ./sopare.py -v -t test

    DEBUG:sopare.worker:meta = [{‘token’: ‘stop’}]
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording

    how to debug this ?

    pi@raspberrypi:~/sopa/sopare $ ./sopare.py -v -t test
    sopare 1.5.0
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    ALSA lib pcm_dmix.c:1022:(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
    INFO:sopare.analyze:checking for plugins…
    DEBUG:sopare.analyze:loading and initialzing plugins/print
    DEBUG:sopare.audio_factory:#### Default input device info #####
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:defaultSampleRate: 48000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00797916666667
    DEBUG:sopare.audio_factory:maxInputChannels: 1
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 2
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    DEBUG:sopare.audio_factory:name: USB Device 0x46d:0x825: Audio (hw:1,0)
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.032
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 48000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    INFO:sopare.processing:starting append mode
    DEBUG:sopare.filter:New window!
    DEBUG:sopare.worker:characteristic = 0 {‘dfm’: 8392550, ‘peaks’: [8, 15], ‘df’: 63, ‘volume’: 9612, ‘fc’: 255.9, ‘norm’: [0.10594115523225008, 0.10158322877562957, 0.11681804231105489, 0.1068257056148099, 0.12176796351005956, 0.11209939201357319, 0.11759502901369843, 0.12503041757929728, 0.14295509295512973, 0.1070191763533646, 0.11333741569275226, 0.10356867771497102, 0.10517339535918468, 0.10650379064074418, 0.11714289851848253, 0.131390592120332, 0.09705024201595135, 0.09655979182149141, 0.11637940402477487, 0.1006688351272602, 0.09423555310449071, 0.12549780259002877, 0.09516164280750142, 0.11825248043989187, 0.10227699566410674, 0.09949168264985163, 0.08828491072525728, 0.11273756863678466, 0.09170913880801336, 0.10735042608047875, 0.09688408426832594, 0.08547141747078266, 0.09609075003796842, 0.0964611191282749, 0.11163953426146789, 0.08616867620694622, 0.08769690713626388, 0.08706560276741793, 0.08993791132326426, 0.0951527940811163, 0.12830248982376538, 0.09952743652502033, 0.08884856749517457, 0.09239102974294733, 0.09092245938869348, 0.08448179666122957, 0.10403397291110868, 0.09088023475480482, 0.08570597421010066, 0.08948350537745008, 0.07877256061356505, 0.08257108177758929, 0.0987806117268587, 0.08496997847138044, 0.08193184047908449, 0.08864385050594285, 0.08722686605697104, 0.08913779248114005, 0.08035649432361833, 0.0901549042144198, 0.07669151671168899, 0.08583583761035314, 0.08482462283809358, 0.08500600200346071, 0.09243170448728302, 0.0945426825120565, 0.08357031972273939, 0.084045815362883, 0.08320151327230363, 0.0903627583300921, 0.0798217437948932, 0.09269861204418268, 0.08453347895873428, 0.08503204282709025, 0.08791641270680751, 0.08378257655395593, 0.08282180116769983, 0.0811500322408955, 0.08231425668231578, 0.08547998546658354, 0.0900528102089543, 0.08483703966188035, 0.0896208185383541, 0.09079794642405874, 0.09198839739529613, 0.08884273409864274, 0.08575794916245694, 0.07478585767554269, 0.08196022964387799, 0.0920031300703268, 0.0870321485753616, 0.08420359558452448, 0.08641863836919976, 0.09494250941832272, 0.09177906586338158, 0.09318078639298588, 0.08920778364930738, 0.09759967892173155, 0.08155563760434316, 0.07860070876220698, 0.08507211331860365, 0.08100867092670498, 0.08168634896715157, 0.1012084548038084, 0.0877466158127226, 0.0810468934879292, 0.058217545366710866, 0.05650011352227838, 0.06197183816331754, 0.0825206316801464, 0.060560695024661756, 0.05679567169102145, 0.05189418886700866, 0.05947670577671059, 0.046404246417839044, 0.062401216853387786], ‘token_peaks’: [3616417, 3477013, 3741406, 4055078, 4173553, 3966424]}
    DEBUG:sopare.worker:meta = [{‘adapting’: 3966424, ‘token_peaks’: [3616417, 3477013, 3741406, 4055078, 4173553, 3966424], ‘pos’: 6, ‘volume’: 9612, ‘token’: ‘token’, ‘silence’: 1}]
    DEBUG:sopare.worker:characteristic = 1 {‘dfm’: 15758218, ‘peaks’: [8], ‘df’: 63, ‘volume’: 7632, ‘fc’: 233.1, ‘norm’: [0.11068015788057073, 0.10892327765714963, 0.10950146099201594, 0.10925153921323472, 0.12098632893293138, 0.11343284527743924, 0.10947997850911097, 0.12886674608597318, 0.133687773567616, 0.11611381070851311, 0.11608437016474935, 0.10013509754574351, 0.11117590834000986, 0.11162666355341658, 0.13018971403977217, 0.1302635679862645, 0.10925689315880026, 0.0995778723806147, 0.1026015890341256, 0.09202280740428172, 0.10115738153832864, 0.12324746950058255, 0.08654858904790462, 0.09735178394566106, 0.10178716052893438, 0.098503733874218, 0.1072688294023852, 0.12297510423628465, 0.1040194003283266, 0.09447341814929792, 0.10162939508038966, 0.08721999238611453, 0.0916522514419516, 0.10276547150245925, 0.10878723861004246, 0.09679073498519697, 0.09703292898298091, 0.09325450796711483, 0.1046750071868504, 0.11331594282794624, 0.12618647905901306, 0.10331600937534441, 0.09540656216626028, 0.09685536650892972, 0.08821441706792908, 0.08124323868468077, 0.09038522566667574, 0.08850035513957531, 0.08436435371731368, 0.08159372539295795, 0.08260771131845221, 0.08779927398085455, 0.0942104227051756, 0.09526309099419712, 0.08849547115284771, 0.08359781275174556, 0.08076220745016971, 0.08516363865549413, 0.08483879056234866, 0.09137040595048612, 0.07968627004756744, 0.07820159399363144, 0.07275768591521893, 0.07875933196677881, 0.0869581534193286, 0.09763125834334756, 0.08030221082547434, 0.08277792267460587, 0.0793090948163051, 0.07568855040890213, 0.08272938145738673, 0.08694044712151928, 0.08083467513304822, 0.08059023620852677, 0.08040059036989283, 0.073690547709575, 0.07681978903106366, 0.07879496368974068, 0.07994845396234244, 0.08033775123589551, 0.08863134178364507, 0.0820835433739588, 0.08316367907282605, 0.0805585059905549, 0.08797931692095796, 0.08581859855457068, 0.08279642610196618, 0.08331158460462718, 0.07763614630871592, 0.08811461316674872, 0.08993435603674965, 0.08528077045104286, 0.08125860242094271, 0.08576660630745814, 0.08930374150366625, 0.08979937030927897, 0.09616704846241522, 0.09186035430786045, 0.08243907823096931, 0.07588657178993195, 0.08315395022596402, 0.08002696512779799, 0.09061913174083243, 0.10050361589836874, 0.07704733125715547, 0.07392927081283802, 0.07887475480347615, 0.07102557264500815, 0.07054729100249378, 0.08035262535647872, 0.0614732278550356, 0.05731852513887314, 0.06545629676371222, 0.061591070473517424, 0.06292917473859498, 0.07021680053188344], ‘token_peaks’: [4172321, 4176452, 3750138, 3355692, 3428014, 3324366]}
    DEBUG:sopare.worker:meta = [{‘adapting’: 3324366, ‘token_peaks’: [4172321, 4176452, 3750138, 3355692, 3428014, 3324366], ‘pos’: 12, ‘volume’: 7632, ‘token’: ‘token’, ‘silence’: 7}]
    DEBUG:sopare.worker:characteristic = 2 {‘dfm’: 10822998, ‘peaks’: [8], ‘df’: 63, ‘volume’: 6422, ‘fc’: 280.8, ‘norm’: [0.10581791842163109, 0.10605482058542506, 0.11336416838586244, 0.1082301489384921, 0.11529507336051051, 0.11835125545888266, 0.10548498487091319, 0.11763119013613214, 0.1389229571700896, 0.12635480827032822, 0.11504361655816592, 0.10852292055271702, 0.1062011285565714, 0.11232780736671044, 0.11785586339698804, 0.11600115012229746, 0.1076731514664409, 0.1028056270567882, 0.11338731928176739, 0.10492660305576688, 0.10296603669335348, 0.11866853474122073, 0.09476520516555677, 0.0978819677514007, 0.10849857672389103, 0.0987947565992829, 0.09682620264785975, 0.10931609008181835, 0.09757848613296663, 0.1022928372203376, 0.113880657340897, 0.08419296941788891, 0.0948120632572979, 0.10803468599091018, 0.1036838910659119, 0.09470839177771934, 0.09307316444570997, 0.09535127879435283, 0.10155564080785906, 0.1065559848340397, 0.11716355087550123, 0.10098687499353115, 0.09142297665737181, 0.0875012726589464, 0.08971666458722653, 0.09906225545814656, 0.11574767312370496, 0.09547515966014006, 0.09030746892801653, 0.09038010314389687, 0.07301208716954645, 0.08791547831833514, 0.09955899383132472, 0.10414379437108194, 0.07958644266980203, 0.08030985043033224, 0.07368295977199055, 0.08798896613254013, 0.09263761024520419, 0.09969149629901411, 0.09112799565650126, 0.08246432596789308, 0.06889158903460423, 0.07406805783740222, 0.07710478130561359, 0.08016952119447719, 0.08092531519401204, 0.0740105063997355, 0.07693216244928147, 0.0783154304469863, 0.07560513951050767, 0.08295556054330248, 0.09370585465282834, 0.08473244375800686, 0.07458819447995442, 0.08020070134905757, 0.08004390236445444, 0.08174062695680326, 0.08881490812123694, 0.07132774535023173, 0.07965668391016846, 0.08098323283312012, 0.08067214629521095, 0.0860524466381488, 0.08385493737513072, 0.0715613535946179, 0.06992006565701778, 0.07266199973402815, 0.071352132562571, 0.08445594543957893, 0.08120997923203284, 0.08668128057859228, 0.08592829607099754, 0.09054553267616251, 0.08248040413978959, 0.09628135676093542, 0.09450406173677667, 0.09911789323995118, 0.08996589519846919, 0.07680365722610055, 0.07462735303446914, 0.07947764867115721, 0.0864735239900374, 0.094354337644113, 0.0960283751298775, 0.08405404033684563, 0.07927660001828633, 0.06970702071947649, 0.06776840229701961, 0.07337067755446128, 0.0736303253339122, 0.0703148091725682, 0.07007594283805099, 0.06585695016431346, 0.06950676611855888, 0.062443776663468814], ‘token_peaks’: [3052382, 3120958, 3103405, 3201110, 3299518, 2769444]}
    DEBUG:sopare.worker:meta = [{‘adapting’: 2769444, ‘token_peaks’: [3052382, 3120958, 3103405, 3201110, 3299518, 2769444], ‘pos’: 18, ‘volume’: 6422, ‘token’: ‘token’, ‘silence’: 13}]
    DEBUG:sopare.worker:characteristic = 3 {‘dfm’: 6322293, ‘peaks’: [8], ‘df’: 63, ‘volume’: 4647, ‘fc’: 240.0, ‘norm’: [0.10855326787986203, 0.11988165660857696, 0.11235734242660417, 0.11035581573963417, 0.12412173816951932, 0.12130134032912554, 0.11364914330330576, 0.12178471782755591, 0.13652894470632015, 0.12132512489225056, 0.1254914704635434, 0.1052871651577213, 0.11479411845367399, 0.11077874075265022, 0.12423477328896303, 0.12493586281651664, 0.11462207260240831, 0.10645926966846009, 0.1203233925383145, 0.1182653859953795, 0.10761701870169912, 0.11686519096838552, 0.10138090514079384, 0.10571815066377718, 0.1143855286387913, 0.09820152828806997, 0.10428981464317276, 0.1128420241784679, 0.107723375294073, 0.11497411819276986, 0.11102017896361516, 0.10610583412363199, 0.09712375106295294, 0.11034560167022699, 0.10067637864033792, 0.09020481088482822, 0.08816709446273101, 0.09740153071075497, 0.1017409972781802, 0.10147410885903645, 0.11561230198877746, 0.10921407410608151, 0.09875931430901104, 0.09297524123896193, 0.10155571302309918, 0.1094829030639, 0.10589134111170113, 0.09712319517506693, 0.08350426129269158, 0.08315650009880268, 0.08397899371784093, 0.09176417678477558, 0.08933383071820669, 0.09275299327663482, 0.08067319167641629, 0.07375609048685976, 0.07662351527635547, 0.08138680117295412, 0.08618070309118626, 0.08612559170762032, 0.08697770117134307, 0.07845180988594268, 0.06898235116167468, 0.06812982740372339, 0.08023109321915362, 0.0681792477421301, 0.07718032910405818, 0.07315392144333717, 0.0790934387176276, 0.06672576621212886, 0.07307943111992152, 0.08584127744770721, 0.08838881515808449, 0.080537601638494, 0.07714430632569692, 0.08456363729669164, 0.07575087809978932, 0.080253036999646, 0.08617611540176119, 0.0793173757958112, 0.08418381384934229, 0.08143522299066627, 0.08103397116443894, 0.08188260905956006, 0.07478280649039631, 0.07428188995863379, 0.08320651749901757, 0.08037532820818691, 0.08075526803504482, 0.08268544964650343, 0.07521969975141837, 0.0835969240926626, 0.07962677022887442, 0.08921966035383974, 0.09987073932786306, 0.0928774310506771, 0.08461286040129709, 0.08040759997552764, 0.0778986425026996, 0.08461164645205498, 0.08054683974946338, 0.07508114567263648, 0.0735886607108803, 0.07304375718897545, 0.07541087978508859, 0.06981161178216576, 0.05836018253707988, 0.06502215006220208, 0.06496215823550108, 0.058435850352795735, 0.06451628439181437, 0.05978289168851602, 0.06458018497634643, 0.06174771867339091, 0.0552114496314654, 0.059246006361588166], ‘token_peaks’: [1672951, 2367040, 2746036, 2450277, 1913249, 1898158]}
    DEBUG:sopare.worker:meta = [{‘adapting’: 1898158, ‘token_peaks’: [1672951, 2367040, 2746036, 2450277, 1913249, 1898158], ‘pos’: 24, ‘volume’: 4647, ‘token’: ‘token’, ‘silence’: 19}]
    DEBUG:sopare.worker:characteristic = 4 {‘dfm’: 321099, ‘peaks’: [0, 1, 2, 3, 4, 5, 6], ‘df’: 21, ‘volume’: 5037, ‘fc’: 40.6, ‘norm’: [0.2619028560998012, 0.2584401248907598, 0.24870154248193332, 0.23974913839581466, 0.21234790979988272, 0.20285966187865048, 0.2059984784201099, 0.18943971048077432, 0.1859114789412215, 0.19205817995384908, 0.18830059743924318, 0.17533988861415378, 0.1615914206493285, 0.17448164297611463, 0.14583016392954318, 0.1340603258526513, 0.13620468457844825, 0.1154727395142478, 0.10854530692114216, 0.1107366900141, 0.10671186398656797, 0.11332331641505256, 0.10807088087701641, 0.11257097719170273, 0.11225130925977467, 0.10917548179855306, 0.1063013349463308, 0.10400749558241827, 0.10493233364455351, 0.10663445446430081, 0.10325094268804799, 0.10687537258448, 0.10486940247261027, 0.10360901909337589, 0.10301063421275973, 0.10420222620633035, 0.0994977497463492, 0.10075792114946375, 0.10272011692404485, 0.09688944456231859, 0.09905152324416647, 0.09640581454982615, 0.09467861413291011, 0.09711167764555939, 0.09627125274411126, 0.10097253787125138, 0.10037061593819081, 0.037791070039412795], ‘token_peaks’: [1982642]}
    DEBUG:sopare.worker:meta = [{‘adapting’: 1982642, ‘token_peaks’: [1982642], ‘pos’: 25, ‘volume’: 5037, ‘token’: ‘start analysis’, ‘silence’: 20, ‘peaks’: [3616417, 3477013, 3741406, 4055078, 4173553, 3966424, 4172321, 4176452, 3750138, 3355692, 3428014, 3324366, 3052382, 3120958, 3103405, 3201110, 3299518, 2769444, 1672951, 2367040, 2746036, 2450277, 1913249, 1898158, 1982642]}]
    INFO:sopare.processing:stop append mode because of silence
    INFO:sopare.buffering:stop buffering
    INFO:sopare.buffering:terminating queue runner
    DEBUG:sopare.worker:characteristic = 0 {‘dfm’: 3892313, ‘peaks’: [1, 4, 8, 21, 25], ‘df’: 42, ‘volume’: 0, ‘fc’: 305.0, ‘norm’: [0.12186802790214678, 0.13080891551103055, 0.1212424618273694, 0.10749034919516054, 0.13049949325253338, 0.12018022923531185, 0.11823400887258916, 0.12203054304889921, 0.13181772199821112, 0.11497576846972322, 0.10956602536368738, 0.10558752026979325, 0.1203345690802792, 0.1192430273653921, 0.10656627421973533, 0.10472071060986202, 0.0997721982387202, 0.116321647767816, 0.11010606129188875, 0.1081948446098083, 0.11441782252900576, 0.1366377857742258, 0.11715404933680348, 0.10904624522273769, 0.1259446607970954, 0.13170974029569618, 0.11462481217629458, 0.10383911108465739, 0.09108323127204541, 0.11234058339799607, 0.10558943137797346, 0.10037767120544433, 0.10295287947313962, 0.10999822415190932, 0.1149227032454728, 0.1023801725143503, 0.09255665153362261, 0.10362962346967078, 0.11170807953850065, 0.09152739302212169, 0.08307715895878871, 0.08431811001418829, 0.08929606563548068, 0.07963977222758192, 0.08744962905833661, 0.09588509638237112, 0.10794972811652653, 0.09284432528414935, 0.09099748426067306, 0.09168117735481741, 0.10339800628948617, 0.09818720216759623, 0.10242589526235996, 0.0982647217804685, 0.09503730976984404, 0.09630465853008012, 0.09377146354281256, 0.0993111135685496, 0.10452497171478106, 0.11628211457065342, 0.09128618246161972, 0.09910844911636962, 0.08783132370324502, 0.10155368522577357, 0.08984106469709383, 0.08958473387061905, 0.07667102222619779, 0.09605945933060424, 0.08148940813469495, 0.08140504737463186, 0.0759031878820749, 0.08240714564233438, 0.08567061103042466, 0.07246599616038686, 0.07099681173423435, 0.07320920917524879, 0.07542749405784382, 0.06916280773541826, 0.06512493038479668, 0.07255639584756063, 0.07985529543398963, 0.07743519860806157, 0.0730592493323577, 0.07252063016994456, 0.08297621567593276, 0.07111807077836756, 0.06570071384315053, 0.06422459973841342, 0.07070934383279139, 0.07187110797359993, 0.06904881924657293, 0.06827812902698556, 0.06810478312933466, 0.0653798309750733, 0.06585177413961527, 0.06746700305329596, 0.06646068456090505, 0.06805150897625659, 0.0673691711322931, 0.0656158642196494, 0.06507348317151576, 0.06576881722881762, 0.06513970327478455, 0.06536203651051563, 0.06510918337921134, 0.06552765463015604, 0.0657021060962171, 0.06474735206414985, 0.06506403668516, 0.06413699386872466, 0.06373374906865399, 0.06519021105065669, 0.06414968883589146, 0.0646257294378876, 0.06415311390701, 0.0643207783485798], ‘token_peaks’: []}
    DEBUG:sopare.worker:meta = [{‘token’: ‘stop’}]
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording

    • During the test SOPARE detects the environmental sound level. This means you should be silent during the test. If this is the normal sound level you should move 😉

  16. Hallo,

    ich habe das ReSpeaker 4-Mic Array (http://wiki.seeedstudio.com/ReSpeaker_4_Mic_Array_for_Raspberry_Pi/#install-driver) von seeedstudio. Aufnahme über die Kommandozeile funktionieren. Die test_audio_py bringt mir aber folgenden Fehler:
    [code]
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
    ALSA lib pcm.c:2495: …

    test_audio init…
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00580498866213
    DEBUG:sopare.audio_factory:maxInputChannels: 4
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 0
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    DEBUG:sopare.audio_factory:name: seeed-4mic-voicecard: – (hw:0,0)
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0348299319728
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    [/code]

    Ich vermute die Samplerate ist zu hoch beim Test, danach ist das Array nicht mehr ansprechbar bis zum Reboot. Wo kann ich diese einstellen? Bei der Befehlszeile “arecord -Dac108 -f S32_LE -r 16000 -c 4 hello.wav” wird z.B. 16k angegeben, weiß nur nicht, ob daß das Maximum darstellt.

    Vielen Dank

  17. Ergänzung:

    „arecord -f S32_LE -r 48000 -c 4 hello.wav“ funktioniert, also hohe Samplerate auch kein Problem. Warum dann nicht im Sopare-Test?
    Ich habe in der test_audio.py nur 16000 eingetragen, dann lief der Test erstmal bis zum Chunktest (‘testing different CHUNK sizes … this may take a while!), ab da erfolgt keine Ausgabe mehr. Strg+C bricht den Test auch nicht ab.

    • Hi. Das ist recht speziell und ich weiß nicht warum das nicht geht. Ohne die Hardware wird das schwierig. Mach bitte einen Bug auf GitHub auf und wir hoffen das das jemand lösen kann.

  18. Hey,

    ansich ein super Programm, tut was es soll.
    Nur habe ich ein Problem, wenn ich per ./sopare.py -l starte, funktioniert die ersten 20-30sek alles super, die Wörter werden erkannt und auch die für die Wörter hinterlegten Befehle werden ausgeführt. Aber nach 20-30sek hängt sich sopare anscheinend auf, zumindest nimmt es keine neuen Befehle mehr wahr, egal ob es gelernte Wörter sind oder nicht(die nichterkannten werden ja mit [] angezeigt, soweit ich das richtig verstehe). Mit “ctrl+x” kann ich das ganze dann beenden un wieder neu starten, dann geht das Spiel wieder von vorne los.

    Auch werden mir bei erkannten Wörtern ein “u” davor gesetzt, was in deinen Videos ja nicht der Fall ist(bei mir sieht das dann so aus [u’an’]). Hat das irgendeine bedeutung, die villeicht dazu führen tut, dass sich sopare aufhängt?

    viele Grüße

    • Hi. Das “u” steht für Unicode und ist ganz normal und soll so sein.
      Für alles andere bräuchte man mehr Info…

  19. Hab grad festgestellt, dass sobald sich sopare aufhängt die cpu für das Pythonscript auf 25% “hängen” bleibt und dessen Memory kontinuirlich ansteigt. Villeicht bleibt das Script in irgend einer Dauerschleife hängen?

      • Werde mal ne log erstellen lassen, vllt kann man daraus dann irgend was brauchbares herausfiltern. Bin momentan aber unterwegs, wird noch 2-3 Tage dauern bis ich das machen kann.

        Was ich auch festgestellt habe, wenn ich das Script starte, und viel hintereinander sage, hängt er sich schnell auf(eben diese 20-30sek). Aber wenn ich zwischen den Ansagen immer eine Pause lasse (60-90sek), dann läuft das Script 5-6min und hängt sich dann erst auf. Eventuell kommt er mit viel „gerede“ nicht klar. Was auch sein kann, dass mein Mic eventuell Probleme macht und den so falsche Signale rein schickt und das zu den Fehler führt(ist nähmlich schon etwas älter und funktioniert auch nicht mehr so ganz 100%tig, aber neues ist schon unterwegs, vllt ist das ja des Rätsels Lösung).

        Habe eine Pi2, mit der altuellen Raspian drauf laufen.

        viele Grüße

  20. Hallo (schon wieder ;))

    das 4MicArray hab ich erstmal bei Seite gelegt (meine Nerven 😉 ) – wenn Du möchtest, schicke ich dir das zu Testzwecken, jetzt ist das 2-MicHat dran. Aber auch hier gibt es Probleme…
    ich habe mir mal die von pyaudio erkannten Geräte anzeigen lassen:
    [code]
    import pyaudio
    p = pyaudio.PyAudio()
    for i in range(p.get_device_count()):#list all available audio devices
    dev = p.get_device_info_by_index(i)
    print((i,dev[‘name’],dev[‘maxInputChannels’]))

    Ausgabe:
    (0, u’seeed-2mic-voicecard: – (hw:0,0)’, 2L)
    (1, u’sysdefault’, 128L)
    (2, u’playback’, 0L)
    (3, u’capture’, 128L)
    (4, u’dmixed’, 0L)
    (5, u’array’, 2L)
    (6, u’dmix’, 0L)
    (7, u’default’, 128L)
    [/code]
    Scheinbar nutzt sopare immer das default Gerät, wird auch immer bei der Ausgabe der test_audio.py angezeigt “DEBUG:sopare.audio_factory:maxInputChannels: 128
    DEBUG:sopare.audio_factory:name: default”,
    war auch beim 4MicArray so…. und ging deshalb vielleicht nicht.
    Die Soundconfig wird bei der Treiberinstallation der Arrays vorgenommen, die Erkennung funktioniert auch und ist über arecord ohne Angabe der Hardware möglich.
    asound.conf
    [code]
    # The IPC key of dmix or dsnoop plugin must be unique
    # If 555555 or 666666 is used by other processes, use another one

    pcm.!default {
    type asym
    playback.pcm “playback”
    capture.pcm “capture”
    }

    pcm.playback {
    type plug
    slave.pcm “dmixed”
    }

    pcm.capture {
    type plug
    slave.pcm “array”
    }

    pcm.dmixed {
    type dmix
    slave.pcm “hw:0,0”
    ipc_key 555555
    }

    pcm.array {
    type dsnoop
    slave {
    pcm “hw:0,0”
    channels 2
    }
    ipc_key 666666
    }
    [/code]

    Ausgabe von arecord:
    [code]
    **** List of CAPTURE Hardware Devices ****
    card 0: seeed2micvoicec [seeed-2mic-voicecard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 []
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    [/code]

    Warum nutzt sopare aber ein anderes Gerät? Wie kann ich das verhindern?
    [code]
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front

    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
    ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
    ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
    ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
    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
    test_audio init…
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 48000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.125
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.125
    DEBUG:sopare.audio_factory:maxInputChannels: 128
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 7
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.125
    DEBUG:sopare.audio_factory:maxOutputChannels: 128
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.125
    Expression ‘alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULL )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 3201
    Expression ‘paUnanticipatedHostError’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 2053
    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
    ERROR:sopare.audio_factory:Error: [Errno -9999] Unanticipated host error
    Expression ‘alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULL )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 3201
    Expression ‘paUnanticipatedHostError’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 2053
    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
    ERROR:sopare.audio_factory:Error: [Errno -9999] Unanticipated host error
    ERROR:sopare.audio_factory:Error: Stream not open
    testing different SAMPLE_RATEs … this may take a while!

    testing different CHUNK sizes … this may take a while!

    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Error: [Errno -9981] Input overflowed
    Excellent. Got all 81920 chunks.

    Your sopare/config.py recommendations:

    SAMPLE_RATE = 48000
    CHUNK = 512
    THRESHOLD = 3400
    [/code]

    Anmerkung: Das System ist gerade neu aufgesetzt, nur die notwendigen Pakete installiert. Keine manuellen Änderungen vorgenommen!

    MfG & Danke

    • Es ist korrekt das SOPARE immer das default nutzt und eine Änderung geht nur über die ALSA config da dies die Python Schnittstelle von pyAudio ist…

      • Ja aber was ist Default Device, wenn es nur dieses eine Device gibt? Die interner Soundkarte ist deaktiviert. Es gibt nur dieses 2Mic Hat… Und wo kommen die 128 Kanäle her. Ich glaube ich gebe echt hier auf…

        Trozdem Danke für dir Hilfe und das Angebot steht immer noch bzgl. des 4Mic Arrays zu testen 😉

  21. …einen Schritt weiter 2Mic-Hat ist jetzt Default, aber wieder ein Problem beim Ausführen von “./sopare.py -v -t test”
    NameError: global name ‘pf’ is not defined
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording

    [code]
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.0087074829932
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00580498866213
    DEBUG:sopare.audio_factory:maxInputChannels: 2
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:index: 0
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.0348299319728
    DEBUG:sopare.audio_factory:maxOutputChannels: 2
    DEBUG:sopare.audio_factory:name: seeed-2mic-voicecard: – (hw:0,0)
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0348299319728
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 48000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    INFO:sopare.processing:starting append mode
    DEBUG:sopare.filter:New window!
    Process buffering queue:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    self.run()
    File “/home/sopare/sopare/buffering.py”, line 43, in run
    self.proc.check_silence(buf)
    File “/home/sopare/sopare/processing.py”, line 74, in check_silence
    self.prepare.prepare(buf, volume)
    File “/home/sopare/sopare/prepare.py”, line 125, in prepare
    self.tokenize(meta)
    File “/home/sopare/sopare/prepare.py”, line 50, in tokenize
    self.filter.filter(self.buffer, meta)
    File “/home/sopare/sopare/filter.py”, line 126, in filter
    chunked_norm = self.get_chunked_norm(nfft)
    File “/home/sopare/sopare/filter.py”, line 61, in get_chunked_norm
    progessive += progessive * pf
    NameError: global name ‘pf’ is not defined
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/atexit.py”, line 24, in _run_exitfuncs
    Process worker for filtered data:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    func(*targs, **kargs)
    File “/usr/lib/python2.7/multiprocessing/util.py”, line 325, in _exit_function
    self.run()
    p.join()
    File “/home/sopare/sopare/worker.py”, line 88, in run
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 145, in join
    obj = self.queue.get()
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 117, in get
    res = self._popen.wait(timeout)
    File “/usr/lib/python2.7/multiprocessing/forking.py”, line 154, in wait
    res = self._recv()
    KeyboardInterrupt
    return self.poll(0)
    File “/usr/lib/python2.7/multiprocessing/forking.py”, line 135, in poll
    pid, sts = os.waitpid(self.pid, flag)
    KeyboardInterrupt
    Error in sys.exitfunc:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/atexit.py”, line 24, in _run_exitfuncs
    func(*targs, **kargs)
    File “/usr/lib/python2.7/multiprocessing/util.py”, line 325, in _exit_function
    p.join()
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 145, in join
    res = self._popen.wait(timeout)
    File “/usr/lib/python2.7/multiprocessing/forking.py”, line 154, in wait
    return self.poll(0)
    File “/usr/lib/python2.7/multiprocessing/forking.py”, line 135, in poll
    pid, sts = os.waitpid(self.pid, flag)
    KeyboardInterrupt
    [/code]

    • Hi. Dieser o.g. Bug wurde vor geraumer Zeit im testing Branch behoben:

      https://github.com/bishoph/sopare/issues/14

      Zum Thema Mic Array: Kommt der Input Stream von dem Mic Array gebündelt rein? Denn das würde erklären warum die Prozessor Last und der Speicher hoch gehen. Hier müsste man (wo kann ich nicht genau sagen) die einzelnen Input Streams mixen bzw. den “besten” extrahieren und nur diesen verwenden….

  22. hey,

    habe das neue Mic jetzt getestet, und das selbe problem besteht weiterhin, nach kurzer zeit hängt sich das script anscheinend auf, die cpu geht auf 25% und der memory steigt immer weiter… wenn ich das ganze jetzt mit ctrl+c beende erhalte ich folgendes:

    sopare 1.5.0
    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
    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
    [u’licht’]
    []
    [u’an’]
    []
    [u’licht’]
    []
    [u’an’, ”]
    []
    [u’licht’]
    []
    []
    []
    [”, u’an’]
    []
    [u’licht’]
    []
    [u’an’]
    []
    [u’licht’]
    [u’licht’, ”]
    []
    [u’an’]
    []
    [u’an’]
    [u’an’, u’an’]
    []
    [u’licht’]
    [u’licht’, u’licht’]
    []
    [u’licht’]
    []
    ^CProcess worker for filtered data:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    Traceback (most recent call last):
    File “./sopare.py”, line 187, in
    self.run()
    File “/home/pi/dev/sopare/sopare/worker.py”, line 88, in run
    Process buffering queue:
    main(sys.argv[1:])
    obj = self.queue.get()
    File “./sopare.py”, line 108, in main
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 117, in get
    recorder.recorder(cfg)
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 44, in __init__
    self.recording()
    res = self._recv()
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 95, in recording
    KeyboardInterrupt
    self.logger.warning(“stream read error “+str(e))
    KeyboardInterrupt
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    self.run()
    File “/home/pi/dev/sopare/sopare/buffering.py”, line 40, in run
    buf = self.queue.get()
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 117, in get
    res = self._recv()
    KeyboardInterrupt

    villeicht hilft das ja weiter?

    viele Grüße

    • Nee, hilft nicht. Das sieht bei mir genau so aus und ist der normale Ablauf. Die Frage ist immer noch offen ob das Mic einen Stream mixt oder ob mehrere Stream parallel ankommen. 25% CPU ist übrigens vollkommen normal. Ruf mal “top -d 1” auf und schalte per “1” in den Core View. Wenn da ein Core dauerhaft auf 100% läuft kommt der Thread nicht mit der Bearbeitung hinterher.

      • ok, läuft dauerhaft auf rund 100%(schwnakt um 5% hin und her).
        Sprich, mein raspberry kommt damit nicht klar, bzw hat zu wenig power, richtig?

        Was ich eben nur nicht verstehe, dass es beim starten immer kurz funktioniert und dann auf einmal zammbricht…

          • Nee, am Pi liegt es nicht, bei mir läuft es auch allen Modellen. Details zum möglichen Vorgehen und Debuggen siehe Kommentar unten.

        • Also, das Architekturbild (https://www.bishoph.org/wp-content/uploads/2018/03/sopare_architecture_20180310.png) zeigt ja was da vor sich geht. Es gibt zwei Möglichkeiten:

          1) SOPARE bekommt einen Stream der aus multiplen Inputs besteht und die Menge ist zu groß (davon geht ich aktuell aus)
          2) Es gibt zu viele Trainingsmodelle und der Vergleich dauert schlicht zu lange

          Punkt 2 kann man einfach testen indem man alle Daten löscht und einen einzigen Test trainiert und gegen diesen testet. Also im Detail:

          rm dict/*.raw
          ./sopare.py -d “*”
          ./sopare -t test
          ./sopare -l

          Und dann die CPU beobachten. Geht die Last jetzt wieder auf 100% liegt es am Input Stream. Ich weiß, das der Amazon Echo aus dem Array den “besten” extrahiert bzw. aus dem multiplen Input einen einzigen mixt. Das sollte ALSA auch können…

          • gerade gefunden, versuche das nämlich auch…

            First, start with a device that allows multiple recording clients:

            pcm.snooped {
            type dsnoop
            slave.pcm “hw:0” # or whatever
            }
            Then extract single channels:

            pcm.channel1 {
            type route
            slave {
            pcm snooped
            channels 2
            }
            ttable [ [ 1 0 ] ]
            }

            pcm.channel2 {
            type route
            slave {
            pcm snooped
            channels 2
            }
            ttable [ [ 0 1 ] ]
            }
            Then put a softvol on each of them:

            pcm.channel1_softvol {
            type softvol
            slave.pcm channel1
            control.name “Channel 1 Capture Volume”
            }
            pcm.channel2_softvol {
            type softvol
            slave.pcm channel2
            control.name “Channel 2 Capture Volume”
            }
            Then merge them into a single device:

            pcm.mixed_with_volumes {
            type multi
            slaves {
            a { pcm channel1_softvol channels 1 }
            b { pcm channel2_softvol channels 1 }
            }
            bindings [
            { slave a channel 0 }
            { slave b channel 0 }
            ]
            }
            … and use a plug plugin to mix the channels together:

            pcm.my_device {
            type plug
            slave.pcm mixed_with_volumes
            ttable [ [ 0.5 0.5 ] ]
            }

          • Ich würde dann auch zu 1. tendieren, habe lediglich 3 Trainingsmodelle, “Licht, An, Aus”. Alle 3 habe ich 3mal “trainiert/gesprochen”, habe das ganze jetzt eben auch mal nur mit dem “test” versucht, kommt zum selben ergebnis.

            Kann das eventuell an der externen Soundkarte liegen? Habe ne ältere USB-Soundkarte von nem Logitech Headset, mit nen 3,5mm Input und Output. (https://www.ebay.de/itm/LOGITECH-USB-3-5mm-AUDIO-INTERFACE-ADAPTER-FOR-MICROPHONE-HEADPHONE-A-5572A/162952908403?epid=1021986816&hash=item25f0c00e73:g:jxUAAOSwWCBarrtJ)

          • Zur Soundkarte Kann ich nicht viel sagen, ich bin da eher Entwickler und Software lastig 😉

            Ein weiterer Bereich für die Datenmenge ist der von SOPARE genutzte Frequenzbereich. Welcher Bereich wird denn da abgedeckt, also speziell die Werte LOW_FREQ und HIGH_FREQ sind relevant?

  23. Good day! How can I make it run upon boot up? I want to make the raspberry pi run the endless loop upon start up. Thank you!

    • You can start SOPARE as a service. There are plenty of examples how to add a Python script as a service. I can add my own start/stop script to GitHub and cover this topic in combination with the plugins in the next video. Stay tuned – I should have time in the next few weeks to do the next video tutorial.

  24. über “sudo arecord -D capture_mono -c 1 -r 48000 test.wav” kann ich jetzt mono aufnehmen

    meine asound.conf

    # The IPC key of dmix or dsnoop plugin must be unique
    # If 555555 or 666666 is used by other processes, use another one

    pcm.!default {
    type asym
    playback.pcm “playback”
    capture.pcm “capture_mono”
    }

    pcm.playback {
    type plug
    slave.pcm “dmixed”
    }

    pcm.capture {
    type plug
    slave.pcm “array”
    }

    pcm.dmixed {
    type dmix
    slave.pcm “hw:1,0”
    ipc_key 555555
    }

    pcm.array {
    type dsnoop
    slave {
    pcm “hw:1”

    }
    ipc_key 666666
    }

    #extract single channel

    pcm.channel1 {
    type route
    slave {
    pcm array
    channels 2
    }
    ttable [ [ 1 0 ] ]
    }

    pcm.channel2 {
    type route
    slave {
    pcm array
    channels 2
    }
    ttable [ [ 0 1 ] ]
    }

    #Then put a softvol on each of them:

    pcm.channel1_softvol {
    type softvol
    slave.pcm channel1
    control.name “Channel 1 Capture Volume”
    }
    pcm.channel2_softvol {
    type softvol
    slave.pcm channel2
    control.name “Channel 2 Capture Volume”
    }

    #Then merge them into a single device:

    pcm.mixed_with_volumes {
    type multi
    slaves {
    a { pcm channel1_softvol channels 1 }
    b { pcm channel2_softvol channels 1 }
    }
    bindings [
    { slave a channel 0 }
    { slave b channel 0 }
    ]
    }

    #… and use a plug plugin to mix the channels together:

    pcm.capture_mono {
    type plug
    slave.pcm mixed_with_volumes
    ttable [ [ 1 1 ] ]
    }

  25. Hallo mal wieder…

    Ich komme einfach nicht voran. Jetzt macht die Queue Probleme, test/test_audio.py bleibt beim chunk-test “stehen”? Ich habe auch schon die SAMPLE_RATES und die CHUNKS Auswahl minimiert.
    SAMPLE_RATES = [ 16000, 44100, 48000 ]
    CHUNKS = [ 512, 2048, 4096 ]

    Wenn ich dann mit STRG+C abbrechen möchte weil es nicht mehr weiter geht, wird mir angezeigt:

    Processing multiprocessing buffering queue:
    Traceback (most recent call last):
    File “usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    self.run()
    File “/home/sopare/test/test_multi.py”, line 30, in run
    buf = self.queue.get()
    File “usr/lib/python2.7/multiprocessing/queues.py” line 117, in get
    res = self._recv()
    KeyboardInterrupt

    Das Programm wird aber nicht beendet, muss die Putty-Sitzung dann beenden.

    Es bleibt auch alles willkürlich hängen, mal bei Chunks 512, mal bei 2048 … auch volume hab ich mir mal anzeigen lassen, mal geht es in die tausender hoch, mal bleibt es bei 713 hängen, mal läuft die Schleife mehrere Male durch, dann nur einmal… Es spielt auch keine Rolle, ob das Mic in Mono oder Stereo läuft, bleibt beides mal hängen.

    irgend eine Idee?

    Pi 3 B,
    Linux raspberrypi 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l GNU/Linux

    • Nope, leider keine Idee außer dem was ich zuvor schon gesagt habe: Ich denke das ein Mic-Array eine spezielle Ansteuerung bzw. Handling benötigt…

  26. bzgl. Mic Array hab ich mal ne Anfrage unter Issues gestellt bzgl der Verwendung von arecord anstelle von pyaudio. Sind auch die Links zu einem Projekt dabei. Da wird auch die Queue anders erzeugt, CPU Last ist auch geringer. Vllt. ist es ja ne Option und für uns alle hilfreich… 🙂

  27. … 🙂
    Aufnahme klappt, ist auch Mono… aber s. Fehler am Ende…

    sopare 1.5.2
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.0087074829932
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00580498866213
    DEBUG:sopare.audio_factory:maxInputChannels: 2
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 2
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.0348299319728
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:maxOutputChannels: 2
    DEBUG:sopare.audio_factory:name: seeed-2mic-voicecard: – (hw:1,0)
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0348299319728
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 16000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    INFO:sopare.processing:starting append mode
    DEBUG:sopare.filter:New window!
    Process buffering queue:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    self.run()
    File “/home/sopare/sopare/buffering.py”, line 43, in run
    self.proc.check_silence(buf)
    File “/home/sopare/sopare/processing.py”, line 74, in check_silence
    self.prepare.prepare(buf, volume)
    File “/home/sopare/sopare/prepare.py”, line 126, in prepare
    self.tokenize(meta)
    File “/home/sopare/sopare/prepare.py”, line 50, in tokenize
    self.filter.filter(self.buffer, meta)
    File “/home/sopare/sopare/filter.py”, line 126, in filter
    chunked_norm = self.get_chunked_norm(nfft)
    File “/home/sopare/sopare/filter.py”, line 62, in get_chunked_norm
    i += int(progessive)
    OverflowError: cannot convert float infinity to integer
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording

    und bitte nicht alles aufs Array schieben, ich habe es jetzt schon zu einem Mono-Mic kastriert 😉

  28. Ich bins wieder,

    habe mich jetzt bisschen mit den Einstellungen rum gespielt und den Chunk-Size auf 1024 erhöht und das ganze mal länger getestet und jetzt scheint es zu laufen 🙂

    viele Grüße

  29. sir,

    first time i have installed SOPARE successfully and get Result [test] but now i am facing this error can you please help me…

    sopare 1.5.0
    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
    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
    INFO:sopare.analyze:checking for plugins…
    DEBUG:sopare.analyze:loading and initialzing plugins/print
    DEBUG:sopare.audio_factory:#### Default input device info #####
    Traceback (most recent call last):
    File “./sopare.py”, line 187, in
    main(sys.argv[1:])
    File “./sopare.py”, line 108, in main
    recorder.recorder(cfg)
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 44, in __init__
    self.recording()
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 82, in recording
    self.stream = self.audio_factory.open(self.cfg.getintoption(‘stream’, ‘SAMPLE_RATE’))
    File “/home/pi/dev/sopare/sopare/audio_factory.py”, line 36, in open
    for k, v in self.pa.get_default_input_device_info().iteritems():
    File “/usr/lib/python2.7/dist-packages/pyaudio.py”, line 949, in get_default_input_device_info
    device_index = pa.get_default_input_device()
    IOError: No Default Input Device Available
    INFO:sopare.worker:worker queue runner started
    INFO:sopare.buffering:buffering queue runner

    • The issue “No Default Input Device Available” means that the device is busy, not connected or unavailable. It could be that an instance of SOPARE is (still) running in the background. You can find out by executing the command:

       ps aux | grep sopare
      

      If you get results you have to kill the processes with the command

      kill -3 PROCESS_ID
      

      The PROCESS_ID is the first number in the line …

      Hope that helps 🙂

  30. Installed perfectly on Raspi 3B running Raspbian Strech. However, the “WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed” is excessive. I simply do not use the verbose parameter. The trick to using this is in the learning. But I give it 5-stars.

    • Thanks for the 5-stars 🙂

      I want to mention that I get the error “-9988” with one microphone (don’t appear with other microphones) so this issue is definitely hardware depended. Even it is annoying, the message is necessary because the issue effects the precision slightly. But as you said correctly it can be suppressed.

  31. Good evening sir,
    can you help for this error ?

    DEBUG:sopare.worker:meta = [{‘token’: ‘stop’}]
    INFO:sopare.buffering:terminating queue runner
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording
    pi@raspberrypi:~/dev/sopare $ ./sopare.py -c
    sopare 1.5.0
    recreating dictionary from raw input files…
    pi@raspberrypi:~/dev/sopare $ ./sopare.py -l
    sopare 1.5.0
    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
    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
    ERROR:sopare.analyze:ImportError: No module named __init__
    []
    []
    []
    []
    []
    []
    []
    []

  32. Dear Sir Good afternoon,
    Thanks for all kind of your support.
    (1) I get ‘ERROR:sopare.analyze:ImportError: No module named __init__’ when given command ./sopare.py -l.

    pi@raspberrypi:~/dev/sopare $ ./sopare.py -l
    sopare 1.5.0
    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
    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
    ERROR:sopare.analyze:ImportError: No module named __init__
    ERROR:sopare.analyze:ImportError: No module named __init__
    []
    []
    []
    [u’LIGHTON’]
    [u’LIGHTON’]
    [u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’]
    [u’LIGHTON’, u’LIGHT’]
    [u’LIGHTON’, u’LIGHT’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’]
    []
    []
    []
    []
    []
    []
    []
    []
    []
    []
    []
    []
    [”, u’LIGHT’]
    [”, u’LIGHT’]
    [”, u’LIGHT’]
    [”, u’LIGHT’, ”, u’LIGHTON’]
    [”, u’LIGHT’, ”, u’LIGHTON’]
    [”, u’LIGHT’, ”, u’LIGHTON’]
    [”, u’LIGHT’, ”, u’LIGHTON’, u’LIGHTON’]
    [”, u’LIGHT’, ”, u’LIGHTON’, u’LIGHTON’]
    [”, u’LIGHT’, ”, u’LIGHTON’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’, u’LIGHTON’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’, u’LIGHTON’, u’LIGHTON’]
    [u’LIGHTON’, u’LIGHT’, u’LIGHTON’, u’LIGHTON’, u’LIGHTON’]
    []
    []
    []
    []
    []
    []
    [u’LIGHTOFF’, u’LIGHT’, u’LIGHTON’, u’LIGHT’, ”]
    [u’LIGHTOFF’, u’LIGHT’, u’LIGHTON’, u’LIGHT’, ”]
    [u’LIGHTOFF’, u’LIGHT’, u’LIGHTON’, u’LIGHT’, ”]
    [u’LIGHTOFF’, u’LIGHT’, u’LIGHTON’, u’LIGHT’, ”, u’LIGHT’, ”]
    [u’LIGHTOFF’, u’LIGHT’, u’LIGHTON’, u’LIGHT’, ”, u’LIGHT’, ”]
    [u’LIGHTOFF’, u’LIGHT’, u’LIGHTON’, u’LIGHT’, ”, u’LIGHT’, ”]
    []
    []
    []

    (2) please verify my code for light on/light off

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    “””
    Copyright (C) 2015 – 2017 Martin Kauss (yo@bishoph.org)

    Licensed under the Apache License, Version 2.0 (the “License”); you may
    not use this file except in compliance with the License. You may obtain
    a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    License for the specific language governing permissions and limitations
    under the License.
    “””

    # Default plugin for output of analysis

    import RPi.GPIO as GPIO

    GPIO.setmode(GPIO.BOARD)

    LIGHT = 17
    GPIO.setup(LIGHT, GPIO.OUT)

    def run(readable_results, data, rawbuf):
    if(len(readable_results) == 1 and readable_results[0] == ‘LIGHTON’):
    GPIO.output(LIGHT, GPIO.HIGH)
    elif(len(readable_results) == 1 and readable_results[0] == ‘LIGHTOFF’):
    GPIO.output(LIGHT, GPIO.LOW)

    • Something in your plugin directory is not set up properly as a path seems to be wrong – can’t tell more as I have no more information.

  33. Hey,
    when i run python test/test_audio.py

    test_audio init…
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.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 pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
    ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
    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
    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
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    Traceback (most recent call last):
    File “test/test_audio.py”, line 129, in
    ta.test_sample_rates()
    File “test/test_audio.py”, line 78, in test_sample_rates
    self.stream = self.audio_factory.open(test_sample_rate)
    File “../sopare/sopare/audio_factory.py”, line 36, in open
    for k, v in self.pa.get_default_input_device_info().iteritems():
    File “/usr/lib/python2.7/dist-packages/pyaudio.py”, line 949, in get_default_input_device_info
    device_index = pa.get_default_input_device()
    IOError: No Default Input Device Available
    mein USB-Mikrofon ist in pi3 angeschlossen aber wurde nicht erkannt, woran kann das Problem liegen?
    Danke im voraus

  34. Moin,

    endlich mal gute Nachrichten … mit diesem MIC Array (http://wiki.seeedstudio.com/ReSpeaker_Mic_Array_v2.0/) und der 1-Channel Firmware geht es nun wie erwartet, da jegliche Filterung auf dem Mic durchgeführt wird und die reine Sprache in Sopare ankommt.
    Ein Problem bleibt… die (für mich) “hohe” Fehlerkennung – wobei ich weniger Fehler als Jarvis mit Snowboy habe, um ehrlich zu sein, ist Jarvis extrem langsam und extrem fehleranfällig, nur der Einrichtungsassistent ist toll ;).
    Ich habe 3 Kommandos, Licht, Lampe und Steckdose. Es kommt oft vor, dass Licht die Steckdose schaltet. Oder ein Husten von mir schaltet die Lampe.
    Nach tagelangem Testen und Videos wiederholt angucken sieht meine Config nun so aus:
    [code]
    #########################################################
    # Stream prep and silence configuration options #########
    #########################################################

    [stream]

    # Read chunk size
    CHUNK = 512

    # Sample rate
    SAMPLE_RATE = 16000
    #mehr kann das Mic nicht

    # Volume threshold when audio processing starts / silence
    THRESHOLD = 500

    # Silence time in seconds when analysis is called
    MAX_SILENCE_AFTER_START = 1
    #kleiner geht nicht, dann wird nichts mehr aufgezeichnet?!

    # Time in seconds after the analysis is forced
    MAX_TIME = 2.4

    # Start the analysis after reaching LONG_SILENCE
    LONG_SILENCE = 20

    # Characteristic length
    CHUNKS = 2048

    #########################################################
    # Characteristic configuration options ##################
    #########################################################

    [characteristic]

    # Steps boil down the data into smaller chunks of data.
    # Smaller steps mean more precision but require
    # normally more learned entries in the dictionary.
    # Progressive value is used if you want to pack not
    # so relevant frequencies
    PROGRESSIVE_FACTOR = 0
    START_PROGRESSIVE_FACTOR = 600
    MIN_PROGRESSIVE_STEP = 25
    MAX_PROGRESSIVE_STEP = 25

    # Specifies freq ranges that are kept for further
    # analysis. Freq outside of the ranges are set to zero.
    # Human language can be found between 20 and 5000.
    LOW_FREQ = 40
    HIGH_FREQ = 1000

    # Make use of Hann window function
    HANNING = true

    # Range factor for peaks
    PEAK_FACTOR = 0.7

    #########################################################
    # Compare configuration options #########################
    #########################################################

    [compare]

    # Min. number of tokens to identify the beginning of a word
    MIN_START_TOKENS = 2

    # Min. value for potential beginning of a word
    MARGINAL_VALUE = 0.8

    # Minimal similarity across all comparison to
    # identify a complete word across all tokens
    MIN_CROSS_SIMILARITY = 0.97

    # Calculation basis or token/word comparison

    SIMILARITY_NORM = 0.7
    SIMILARITY_HEIGHT = 0
    SIMILARITY_DOMINANT_FREQUENCY = 0
    SIMILARITY_ZERO_CROSSING_RATE = 0.3
    #bisher die besten Ergebnisse damit, hab fast alles probiert!

    # Number of best matches to consider.
    # Value must be > 0
    # If not specified or value 95% beim ersten mal, 100% beim zweiten… nur nicht immer richtig.

    Wo kann ich noch dran schrauben?
    Gibt es eine Möglichkeit den Wortanfang noch genauer zu vergleichen? Wegen dem Problem Gicht, Sicht, Nicht -> schaltet auch das Licht.

    Danke

    • irgendwie fehlt der Rest oben… also nochmal
      #########################################################
      # Stream prep and silence configuration options #########
      #########################################################

      [stream]

      # Read chunk size
      CHUNK = 512

      # Sample rate
      SAMPLE_RATE = 16000

      # Volume threshold when audio processing starts / silence
      THRESHOLD = 500

      # Silence time in seconds when analysis is called
      MAX_SILENCE_AFTER_START = 1

      # Time in seconds after the analysis is forced
      MAX_TIME = 2.4

      # Start the analysis after reaching LONG_SILENCE
      LONG_SILENCE = 20

      # Characteristic length
      CHUNKS = 2048

      #########################################################
      # Characteristic configuration options ##################
      #########################################################

      [characteristic]

      # Steps boil down the data into smaller chunks of data.
      # Smaller steps mean more precision but require
      # normally more learned entries in the dictionary.
      # Progressive value is used if you want to pack not
      # so relevant frequencies
      PROGRESSIVE_FACTOR = 0
      START_PROGRESSIVE_FACTOR = 600
      MIN_PROGRESSIVE_STEP = 25
      MAX_PROGRESSIVE_STEP = 25

      # Specifies freq ranges that are kept for further
      # analysis. Freq outside of the ranges are set to zero.
      # Human language can be found between 20 and 5000.
      LOW_FREQ = 40
      HIGH_FREQ = 1000

      # Make use of Hann window function
      HANNING = true

      # Range factor for peaks
      PEAK_FACTOR = 0.7

      #########################################################
      # Compare configuration options #########################
      #########################################################

      [compare]

      # Min. number of tokens to identify the beginning of a word
      MIN_START_TOKENS = 2

      # Min. value for potential beginning of a word
      MARGINAL_VALUE = 0.8

      # Minimal similarity across all comparison to
      # identify a complete word across all tokens
      MIN_CROSS_SIMILARITY = 0.97

      # Calculation basis or token/word comparison
      SIMILARITY_NORM = 0.7
      SIMILARITY_HEIGHT = 0
      SIMILARITY_DOMINANT_FREQUENCY = 0
      SIMILARITY_ZERO_CROSSING_RATE = 0.3

      # Number of best matches to consider.
      # Value must be > 0
      # If not specified or value < 1 value is set to 1
      NUMBER_OF_BEST_MATCHES = 15

      # Min. distance to keep a word
      MIN_LEFT_DISTANCE = 0.3
      MIN_RIGHT_DISTANCE = 0.3

      # Use given number as results to assembly result
      # 0 for all predictions
      MAX_WORD_START_RESULTS = 2
      MAX_TOP_RESULTS = 5

      # Enable or disable strict length check for words
      STRICT_LENGTH_CHECK = true
      # Value to soften the strict length check a bit to still
      # get quite precise results but to be less strict
      STRICT_LENGTH_UNDERMINING = 2

      # Short term memory retention time in seconds. Zero to disable STM
      # 1.2
      STM_RETENTION = 1.2

      # Fill result percentage
      # 0.5 means that half of the values can by empty to still get valid results
      # A lower value should theoretically avoid false positives
      FILL_RESULT_PERCENTAGE = 0.1

      #########################################################
      # Misc configuration options ############################
      #########################################################

      [misc]

      # Loglevel (CRITICAL, ERROR, WARNING, INFO, DEBUG)
      LOGLEVEL = ERROR

      #########################################################
      # Experimental configuration options ####################
      #########################################################

      [experimental]

      # Additional FFT analysis and comparison for CHUNKS/2 length
      FFT_SHIFT = true

    • Die Werte MIN_PROGRESSIVE_STEP und MAX_PROGRESSIVE_STEP können weiter runter geschraubt werden, dazu ist nach einer Anpassung ein neues Training notwendig. Die Werte sind quasi eine Komprimierung der Daten. Probiert doch mal 10, 5 oder sogar 2 aus. Je kleiner der Wert, desto genauer. Irgendwo findet man dann eine Balance zwischen True und False Positives…
      Hier die Werte die ich für Sprache und Lichtsteuerung verwende:

      PROGRESSIVE_FACTOR = 0
      START_PROGRESSIVE_FACTOR = 600
      MIN_PROGRESSIVE_STEP = 5
      MAX_PROGRESSIVE_STEP = 5

      MIN_START_TOKENS = 3
      MARGINAL_VALUE = 0.8
      MIN_CROSS_SIMILARITY = 0.85

      Ebenfalls sehr wichtig diese beiden Werte, die als Filter fungieren (am besten hoch anfangen und dann runter gehen):
      MIN_LEFT_DISTANCE = 0.9
      MIN_RIGHT_DISTANCE = 0.7

      Da das alles stark abhängig ist von der Umgebung, Training und Hardware ist eigenes austesten unumgänglich…

      Eventuell bekommt man aber auch mit der niedrigen Sample Rate keine besseren Resultate … meine Sample Rate liegt bei 48000, JFYI.

      • Danke für die Antwort, aber kannst die nochmal auf git schreiben bitte? Hier fehlt die Hälfte von meinem Text, k.a. warum. Lösche am besten die Frage ganz. 🙂

        Danke

  35. sir,

    first time i have installed SOPARE successfully and get Result [test] but now i am facing this error can you please help me…

    pi@raspberrypi:~/dev/sopare $ ./sopare.py -l
    sopare 1.5.0
    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
    connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
    attempt to connect to server failed
    []
    []
    []

    i use usb audio for mic and 3.5 mm jack for speaker
    I hope help from you..
    thank sir

  36. Hi,

    I cannot train it after successfully training it at first day i got my raspberry pi, it says:

    pi@raspberrypi:~/sopare $ ./sopare.py -t -v test
    sopare 1.5.0
    ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘defaults.bluealsa.interface’
    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.interface’
    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
    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
    pi@raspberrypi:~/sopare $

    after this last line:
    JackShmReadWritePtr::~JackShmReadWritePtr – Init not done for -1, skipping unlock

    it does nothing and finally it closes itself

    please help

    Thanks

    • Not sure but a quick Internet search shows me that you have issues with your ALSA setup. Maybe you installed something manually or your ALSA config is muddled.

      As far as I can tell the above error messages are not related to SOPARE which means I can’t really help.

  37. Hello, im am using SOPARE for voice control and came across some questions

    can it be speech independent recognition?

    is there a limit for commands?

    thanks

    • Hi. Speech independent in terms of sound recognition: yes. There is no real limit but too many commands will lead to lag/delay as the current word identification mechanism needs an optimization/overhaul.

  38. Hallo, ich versuche sopare zu installieren. HW: Raspberry P3+, stretch9.
    Alles installiert nach Anweisung auch wohl fehlerlos bis:dahin
    Fehler:
    python test/test_audio.py

    **************************************************************************
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00868480725624
    DEBUG:sopare.audio_factory:maxInputChannels: 1
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 2
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    Traceback (most recent call last):
    File “test/test_audio.py”, line 129, in
    ta.test_sample_rates()
    File “test/test_audio.py”, line 78, in test_sample_rates
    self.stream = self.audio_factory.open(test_sample_rate)
    File “../sopare/sopare/audio_factory.py”, line 37, in open
    self.logger.debug(str(k) + ‘: ‘ + str(v))
    UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xae’ in position 9: ordinal not in range(128)
    *************************************************************************************************************************************

    warum?? this may take a while! wie lange Stunden???
    Ich habe nach ca. einer halben Stunde abgebrochen
    .Hat das ueberhaupt schon jemand nach der Anweisung fehlerlos installiert???

    Gruss georg

    • Not sure if this error is thrown because your console does not support UTF-8 or the input from pyaudio is not encoded correctly or the passing to the logging module must be different.

      Please add a new issue: https://github.com/bishoph/sopare/issues

      Will take a look whenever I have some more time 😉 Thx for the report!

  39. Hi,

    Can we use Sopare to make short sound recognition?
    I am looking for a system that allows to differentiate the sounds produced by a drumstick strike on different surfaces. About a dozen of different sounds.
    The typical duration of theses sound is about a tenth of a second.
    Any advice will be welcome.

    Thanks

    • Hi. Not sure and never tried it but to differentiate extremely short sounds is difficult. Try to use the visualization feature from SOPARE and check if the sound waves and the frequencies differ. Also this gives you an indication about length and frequency ranges. Furthermore I can imagine that you need a good microphone and some nearly noise free environment and you need to make sure that the training and sounds are made under the same conditions. Finally: with the right config it could work but you have to test it out – I can’t provide any guaranty 😉

      Have fun 🙂

  40. hello, i am nearly completing my project, i only need to detect my hand clap, dont care about the others, but i notice that there are some sound pattern that sopare recognize as “a hand clap” but surely it is not a clap, for example a sound of a creaking door, keys hitting my desk, etc.. I also tried to see the minimum left and right distance using the verbose parameter in sopare, but the thing is they are practically similar (the difference is only 0.1 or less) and i found no way to differentiate these sound patterns with the actual handclap. I have also tried modifying the SIMILARITY value combination but still no luck

    is there any other way to overcome this? btw, i can only use CHUNK=1000 and CHUNKS=4000 otherwise after some time the mic will stop working (input overflow error will appear)

    thanks

    • Hand clap is a short sound without lots of special frequencies involved so my guess is that the hand clap is indeed very similar to other short sounds that only move air. My advice is to review the differences by using the plot function of SOPARE and try to adjust as far as possible. My personal guess is that the CHUNK size of 1024 should play well with a high sample rate. If you are using a lower sample rate than a higher CHUNK size should be better due to the included information for the analysis.

  41. Thank you for this wonderful project! I am having issues with recognizing two words. I can train each word individually, but when attempting to use your example to only execute a plugin when two words are spoken I am not getting the correct response. How can I adjust the configuration to accept more than one word at a time?

    Thank you again, this is an awesome project to work on!

  42. Hi Martin,

    First at all congratulations for your work with Sopare I have been doing some research I have found your work the most convenient around.

    I’m planning to import Pygame to play the sound and also I’m using ReSpeaker Pi Hat ( http://wiki.seeedstudio.com/ReSpeaker_2_Mics_Pi_HAT) for sound and microphone managing, I have setup ReSpeaker and ALSA recognizes it well microphone and sound on my Raspberry Pi 3. Do you think my ecosystem is compatible with Sopare?

    Best,
    Gonzalo

    • Hola Gonzalo,

      thanks for your kind words.

      I have no experience with the ReSpeaker Pi Hat but as it depends on ALSA it should work. Using Pygame with SOPARE could be tricky depending on the modules and functions you want to use. But you can get it to work for sure 😉

      Have fun y un saludo!

  43. thank you very much for your valuable wok
    i just want to know the what type of functions for feature extraction and classification you were used?

    • Thanks and you are welcome.

      I talked about the overall process roughly here and here. As you can configure certain types the answer depends a lot on the individual configuration. But from a high level perspective the features derive from the frequency spectrum and from the domain data itself. But you can also mix in stuff like zero crossing. The classification (I would not call it so) is a more or less a distance calculation for all used and configured features.

  44. Hi,

    Got it working but after ending the endless loop by crtl-z I get the + Stopped message and can not start Sopare again. Instead get the message IOerror: No default input device available. Probably the mic is not released or something

    Any idea what I’m doing wrong here? DO I need to stop Sopare some other way?

    Also, If you would want to have Sopare running continously, how to make sure it starts at boot?

    Thanks.

    regards,
    Hein

        • I already answered this question for you. If you don’t like the answer you can try a different, more specific answer. BTW: You asked 3 times the same question so far…!?

          • Iam so sorry for this problem, i asked the same question three times because there was a problem with my web page.
            your answer was excellent and it was very helpful
            thank you again
            and sorry again

          • If you got the answer and it was helpful I’m delighted. And hopefully you was able to fix your other problem. Have fun 🙂

  45. Compliments on the nice project!

    Question: how do you take Sopare out of its infinite loop if you want to learn it some more commands?

    Kind regards,

    Hein

    • Thanks 🙂

      Start SOPARE without the “-l” option. When SOPARE is running you can stop it by using CTRL-C or just kill the process with the “kill” command. Hope that helps.

  46. Hi,

    One other question: does Sopare do a lot of writes to SD cards ? Reason I ask is because I have domoticz running on my Pi and the Pi in turn is using an SD card. Known issues with SD is that lots of writes have a negative effect on the lifespan of the card.

    regards,
    Ronald

    • Hi.

      SOPARE writes when you train and compile the dict or have the -w option enabled. And of course if you redirect the logging to a file. Other than that SOPARE does not write at all. I have several (nolt only SOPARE) instances running 24/7 since years while using tempfs for some heavy write directories (like /var/log or /tmp and whathaveyou) and never had any sd card corruptions.

      My tip: Just don’t by the cheapest sd cards on the market and make sure to have enough space on the card for the OS to mark bad blocks and potentially for wear leveling.

  47. pi@raspberrypi:~ $ cd
    pi@raspberrypi:~ $ mkdir dev
    pi@raspberrypi:~ $ cd dev
    pi@raspberrypi:~/dev $ git clone https://github.com/bishoph/sopare.git
    bash: git: command not found
    pi@raspberrypi:~/dev $ cd sopare
    bash: cd: sopare: No such file or directory
    pi@raspberrypi:~/dev $ ^C
    pi@raspberrypi:~/dev $ cd
    pi@raspberrypi:~ $ sudo apt-get install git
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    git is already the newest version.
    The following packages were automatically installed and are no longer required:
    coinor-libipopt1 libboost-atomic1.55.0 libboost-filesystem1.55.0
    libboost-program-options1.55.0 libboost-regex1.55.0 libboost-thread1.55.0
    libc-ares2 libffi5 libgmime-2.6-0 libmng1 libmumps-seq-4.10.0 liboauth0
    libqt4-dbus libqt4-xml libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5gui5
    libqt5network5 libqt5opengl5 libqt5printsupport5 libqt5svg5 libqt5widgets5
    libqtdbus4 libqtgui4 libraw10 libruby2.1 libscsynth1 libv8-3.14.5
    libxcb-icccm4 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xkb1
    libxkbcommon-x11-0 libyaml-0-2 qdbus qtchooser qttranslations5-l10n ruby
    ruby2.1 rubygems-integration wolframscript
    Use ‘apt-get autoremove’ to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
    pi@raspberrypi:~ $ ^C
    pi@raspberrypi:~ $ sudo apt-get install gicd dev
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package gicd
    E: Unable to locate package dev
    pi@raspberrypi:~ $ cd
    pi@raspberrypi:~ $ mkdir dev
    mkdir: cannot create directory ‘dev’: File exists
    pi@raspberrypi:~ $ cd dev
    pi@raspberrypi:~/dev $ git clone https://github.com/bishoph/sopare.git
    bash: git: command not found
    pi@raspberrypi:~/dev $ git clone https://github.com/bishoph/sopare.git
    bash: git: command not found
    pi@raspberrypi:~/dev $ cds
    bash: cds: command not found
    pi@raspberrypi:~/dev $ cd
    pi@raspberrypi:~ $ cd wiringPi
    bash: cd: wiringPi: No such file or directory
    pi@raspberrypi:~ $ sudo apt-get install git-core
    Reading package lists… Done

  48. Hi,
    After unavailing with few voice engines,Sopare was the one i got successfully working. Thank you for a user-friendly voice recognition software. I was able to successfully control GPIO’s with it. Now wanted to know if it can be combined with Google Assistant on raspberry pi to control GPIO pins.

    • Great that you got it working 🙂

      In terms of Google Assistant and SOPARE. As SOPARE and the Google Assistant try to read from the mic you can try to generate a wav file to the Google Assistant. Not sure if this is possible but I read the requirement/feature request somewhere. Other than that there are possibilities but not without rewriting large chunks of code. Hope that helps.

      Have fun!

  49. Hi,
    I want to input sound to SoPaRe via bluetooth instead of a usb microphone. How do you suggest I go about with that?
    So far I have installed and trained SoPaRe for a few words and am achieving decent accuracy.
    I will require to do the bluetooth section for my next prototype.Could you please give me a few guidelines on that?

    • If you mean a Bluetooth mic than this could work if you get it to work with the ALSA stack (PulseAudio or Bluetooth Audio ALSA Backend). If you mean your own Bluetooth stack with all the device stuff, pairing and the communication than I can’t give you suggestions or advice as this is beyond the scope and way to complicated.

  50. hi
    when i execute sopare i have got this error:
    Error:sopare.analyze:ImportError: No module named _init_
    can you please explain the reason for this error

    • Without further information help is a bit tricky. I can only guess that your plugin folder structure does not include the necessary __init__.py file or that an import does not point to the correct file…

  51. HI!!
    Could you help tell me what file/function the output that appears in the terminal is coming from when the program is run in -l? I would like to continuously check the output….

    Thank YOU!

  52. Hi,

    I am trying to get Sopare running but I am stuck at getting my threshold.
    If I run test_audio.py, it always says THRESHOLD = 0. If I set this in the config file, it instantly starts listening because it’s 0. If I put it to 1, it doesn’t hear something.

    I have a usb webcam attached to the Raspberry Pi arecord -l returns this:

    fabapi@fabapi:~/Desktop/sopare$ arecord -l
    **** List of CAPTURE Hardware Devices ****
    card 1: Webcam [C922 Pro Stream Webcam], device 0: USB Audio [USB Audio]
    Subdevices: 1/1
    Subdevice #0: subdevice #0

    Audio recording with this microphones also works. So I don’t know why it doesn’t work in Sopare. Do I have to specify something somewhere? Thanks!

  53. We plan to create a voice operated wheelchair.So if I use Sopare based voice recognition will I be able to react to only the voices of trained users.Or will be reactive to every user who speaks the command.(Speaker based or just command based)

    • Depends on your training and your settings. If you train a specific voice command from one speaker and have strict settings only a specific voice will be recognized.

    • I currently have other projects and higher priorities. That said, I’ll continue to make optimizations and changes as my TODO list contains still items I want to solve and to try 😉

    • Great and thx for letting me know!

      As the zero is a multi core device it could work already. I can’t say for sure how good as this depends on dict size, threshold and some other things. Give it a try. If the load is too high and the recognition is delayed than I’m sorry but I can’t do much right now. In the future we might see performance optimizations and a better Pi zero support…;)

  54. Hello! I recently used sopare to control an Arduino powered robot however some of the time the program will stop and not start again, I believe that this is due to one of the cores having too much to do and stopping, is it possible to transfer the work across to two cores? Is there anything else you recommend?

    Also doubt it was my plugin as I have the same issue without it, and I know it is one core out of the 4 because it always says it is under 25% stress when it stops.

    Thanks! Your work is so helpful and much appreciated in Australia!

    • Hey, great to hear and I do this with Pleasure!

      Without further information I can only guess. Let us try to shed some light into this. The following issues are responsible for a potential high load:

      – amount of trained words
      – sample rate
      – used threshold
      – similarities and other values in regard of comparing

      If you encounter high load you can try to remove some trained words from the dict, lower the sample rate or use a higher threshold.
      Other than that, increase the precision and filter out false positives before such words are compared expensively.

      Hope that gives you some ideas what you can optimize by yourself 🙂

      Have fun!

      • Hi, I have since tried to lower the dict word amount to 16 for 4 words; forwards, stop, left, right. This does not help the issue, I have also lowered the sample rate to 5 and have the issue. Finally I adjusted the threshold so no words other than the trained ones are herd, and the issue is the same.

        More information is that after the crash were nothing happens and I have to restart sopare, the % of used power from the CPU is 3 when resting and 18 at maximum, then when it crashes it reaches 25 to 26 and stays there until I restart.

        I re-downloaded sopare and I have the issue regardless of settings and plugins

        • Hi. My robotic arm is controlled by 13 words without any issue. Also a sample rate of 5 makes no sense at all. You need to figure out a sample rate that fits best to your hardware environment. The threshold adjustment seems to be fine.

          However, if you say crash than you get an error message we can work on. File a bug report, tell us how to reproduce and attach stuff that matters like OS environment, used versions, settings, config, output, error messages, stack traces and what have you to make sure we can fix the issue.

          • Depends on your sound card. These are common ones which are tested in the SOPARE audio test suite:

            8000, 11025, 12000, 16000, 22050, 32000, 44100, 48000

  55. Dear Bishop,
    first of all, thankyou for Sopare. Great work and very nice technical explanation of your system.

    I would liketo to use Sopare into my simple project (activate some outputs via voice) on Rpi 3. I modified the simple rate and the sound threshold as suggested by the test program and I prepared the dictionary (6 words each repeated 3 times). When ./sopare -l starts, I am in the same situation described by BlackeG. The software stops to recognize the voice randomly; it seems to be freezed after some words.

    Here we are some technical information:

    –> Rpi 3, raspbian 4.14,79-v7

    –> config:
    CHUNK = 512;
    SAMPLE_RATE = 48000;
    THRESHOLD = 250;

    –> no plugin script modified

    –> top -d 1 (when Sopare is freezed):
    top – 17:42:08 up 3:32, 1 user, load average: 1.57, 1.29, 1.13
    Tasks: 135 total, 2 running, 88 sleeping, 0 stopped, 1 zombie
    %Cpu0 : 7.1 us, 2.0 sy, 0.0 ni, 90.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    %Cpu1 : 98.0 us, 2.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    %Cpu2 : 2.0 us, 0.0 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    %Cpu3 : 5.0 us, 0.0 sy, 0.0 ni, 95.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem : 896664 total, 94520 free, 489596 used, 312548 buff/cache
    KiB Swap: 1023996 total, 954364 free, 69632 used. 351764 avail Mem

    Thanks in advance for you help/suggestions,

    Best Regards,
    Rino

    • Top indicated that there are plenty of resources left. A 4 core CPU can work through a load of 4 and still run smoothly. I would check if the THRESHOLD is too low. There is a good change that your environment encounters some background noise, even in frequencies you don’t hear. This means SOPARE checks constantly against a noisy environment. In fact, the only time when the analysis starts is when the timeouts hit. And this can be seen as kind of hiccup.

      • tanks for replay.
        Ok I modified the theshold value to 2000. The system has become more ‘dull’, but the behavior does not change.
        I added into the config file LOGLEVEL = WARNING and this is the result when the freezing happens:
        WARNING:sopare.recorder:stream read error [Errno -9981] Input overflowed
        WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
        WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
        WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed

        and so on until I press ctrl^C

        • If the stream is closed SOPARE don’t get further audio data from pyAudio and stops/hangs/waits until more data is available.

          There is plenty of advice available for the -9981 error, mostly to use a different sample rate or a different chunk size. Just do some searching. As this issue is pyAudio related (and depends on your hardware/environment/config) I can’t do much ;(

    • As I’m using my own home control system the code would not help as you don’t have the interface. What system or service do you want to use?

  56. Does SOPARE works in Windows?. Currently I am using python 3.4.1 and windows 7. I tried to run SOPARE in python 2.7.12 version in windows it is unable to handle multi-threading.

    can you please suggest how to handle it in windows?

    • Never tried and I really don’t know as the development platform and the target platform is Raspberry Pi in combination with a Linux OS like Raspbian. If you are able to solve the dependencies it could work…

  57. Cloning into ‘sopare’…
    fatal: unable to access ‘https://github.com/bishoph/sopare.git/’: gnutls_handshake() failed: Error in the pull function.

    • SOPARE has no builtin function for “Broadlink Home Automation”. But you can implement whatever you want using a custom plugin. Hope that answers your question.

  58. Hi, is there a way to select the audio device that SOPARE records from please? I have a USB microphone but editing the alsa conf files does not seem to allow me to set a default device. I know, however, that calling it directly e.g. arecord -d 3 -D plughw:2 test.wav allows me to access the microphone. Is this possible with python?

    Cheers,
    Z

  59. hi martin i m a big fan of your work currently working on your project can you please provide me the code of light on and light on gpio basically i m new to pi

  60. I got the program installed and then got my alsa file cleaned up, but I’m still seeing errors when I run the two tests. I think they are mostly on the test_audio.py one, but I included both sets of results here.

    pi@Voice-01:~/dev/sopare $ python sopare.py -u
    sopare 1.5.0
    starting unit tests…
    starting analyze tests…
    analyze test preparation…
    testing analyze get_match…
    testing normal conditions (1)[u’test1′] == [u’test1′]
    testing normal conditions (2)[u’test1′, u’test3′] == [u’test1′, u’test3′]
    testing normal conditions (3)[u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′]
    testing leading space [u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′]
    testing ending space [u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′]
    testing correct order [u’test1′, u’test3′, u’test2′, u’test1′, u’test3′, u’test2′] == [u’test1′, u’test3′, u’test2′, u’test1′, u’test3′, u’test2′]
    testing strict length [u’test1′, u’test3′, ”, u’test2′] == [u’test1′, u’test3′, ”, u’test2′]
    testing false leading results [”, u’test1′, ”, u’test2′] == [”, u’test1′, ”, u’test2′]
    analyze tests run successful.
    filter test preparation…
    testing filter n_shift…
    testing n_shift [5, 6, 7, 8, 9, 10, 11, 12, 13, 14] == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
    testing n_shift [15, 16, 17, 18, 19, 20, 21, 22, 23, 24] == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
    testing n_shift [25, 26, 27, 28, 29, 30, 31, 32, 33, 34] == [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
    filter tests run successful.
    unit_tests run successful!
    done.

    pi@Voice-01:~/dev/sopare $ python test/test_audio.py
    test_audio init…
    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
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00868480725624
    DEBUG:sopare.audio_factory:maxInputChannels: 1
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 2
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
    DEBUG:sopare.audio_factory:maxOutputChannels: 0
    DEBUG:sopare.audio_factory:name: USB PnP Sound Device: Audio (hw:1,0)
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0348299319728
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    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
    ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
    testing different CHUNK sizes … this may take a while!

    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.

    Your sopare/config.py recommendations:

    SAMPLE_RATE = 48000
    CHUNK = 512
    THRESHOLD = 100

    Any suggestions?

      • Ok, I did the training (for “test”), when I run the listener I get the output below.

        ===============
        sopare 1.5.0
        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
        []
        []
        [u’test’]
        []
        [u’test’]
        []
        []
        []
        []
        [u’test’]
        []
        ^CTraceback (most recent call last):
        =========

        What are the errors about “Cannot connect to server” and “jack server” about?

        • This are ALSA warnings and are not related to SOPARE. You can
          a) ignore them
          or
          b) try to get rid of them.

          As I have no further input about ASLA/Jack and your environment I can’t help much.

  61. When I run “python2.7 sopare.py -l” I get the following error message. I am using this inside a virtual environment, but i don’t think that’s the problem as it works outside the environment.

    sopare 1.5.0
    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

    • This is not an error message related to SOPARE. 99% of the output comes from ALSA and you get rid of it by cleaning up your ALSA config,

        • Let’s try to figure this out. As neither SOPARE nor ALSA shows error messages you can just leave it as it is and it should work. But: as the ALSA output is cluttered with warnings I recommend to clean up your ALSA configuration.
          This can be cone by simply commenting out unused devices in your alsa.conf (like in your case the PCM stuff):

          Place a “#” in front of the lines that appear in the warnings, save the file and test if everything works. Before you start make a copy of the file just to be safe:

          Like search for this line
          defaults.pcm.front.card defaults.pcm.card

          and comment it out.
          #defaults.pcm.front.card defaults.pcm.card

          Save, test and repeat.

  62. Hi, thank you for your great work on this. But I’m running into trouble. I have installed SOPARE succesfully and both test runs successfully.

    But when trying to learn the “test” word (or any word) I get the following error:

    0.09402073267550819, 0.07503437200250257, 0.0837933995321481, 0.09745028536740484, 0.06661686489456727, 0.08580949954209392, 0.06002299178606901, 0.10813029430710187, 0.06798151458981183, 0.07285299152412461, 0.10555516512743991, 0.067834334251818], ‘token_peaks’: []}
    DEBUG:sopare.worker:meta = [{‘token’: ‘stop’}]
    INFO:sopare.buffering:terminating queue runner
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording

    Just in case, I have also waited a while before speaking my test word. To see if it would still record noise. But then the number won’t run on the screen. But as soon as I say the word test, the number run and before I can say test for the second time it stops recording.

    Can you help me?

    I have ubuntu 18.04 (I know, not a RPi) and followed your tutorial for installing SOPARE.

    I installed it today (31 march 2019)

    Thank you for all your help

    • With pleasure. There is no error in your output and I really don’t know what the problem is…please try to be specific, provide step by step “how to reproduce” instructions including desired outcome and full output. If you encounter an issue please file an issue on GitHub for easy tracking/reporting. Thx.

      Have fun!

      • Thank you, for your answer. I just sorted it out and can confirm it is working now!
        Just one question, I’m trying to send a curl command on recognizing a word. But I cannot get it tot work. Can you point me in the right direction? This is what I got in custom my __init__.py

        ########################### BEGIN
        #!/usr/bin/env python
        # -*- coding: utf-8 -*-

        “””
        Copyright (C) 2015 – 2017 Martin Kauss (yo@bishoph.org)

        Licensed under the Apache License, Version 2.0 (the “License”); you may
        not use this file except in compliance with the License. You may obtain
        a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
        WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
        License for the specific language governing permissions and limitations
        under the License.
        “””

        # Default plugin for output of analysis

        def run(readable_results, data, rawbuf):
        if (‘lampen’ in readable_results and ‘aan’ in readable_results):
        print (‘Jups, 2 woorden gevonden, best genoch’)
        if (len(readable_results) == 2 and ‘aan’ in readable_results[0] and ‘lampen’ in readable_results[1]):
        import requests

        headers = {
        ‘Content-Type’: ‘text/plain’,
        }

        data = ‘OFF’

        response = requests.post(‘http://192.168.1.253:8080/rest/items/wcd001_schakelaar’, headers=headers, data=data)

        ################################ END

        I know that the curl command is correct, but how do I put it correctly in de init file? Can you help?

        • Great that it is working for you! As you posted the code without indentation I could argue that the indentation is missing/wrong. And the import should be placed on top of the file. I suggest and recommend that you get familiar with Python programming if you want to start coding 😉

          • Thank you, for all your help. I have put this issue on your Github and it is already solved. So. But thank you 😉

  63. Hello,

    I do not know anything about Raspberry Pi or programming, but Google had led me to this page.
    Is it possible to use this with a small 12vdc motor to use voice command to make it run forward or reverse?

    • Short answer is yes. The longer answer is that you need experience in Python development and electronic as you need
      a) a SOPARE plugin for your custom motor control
      b) a motor shield or maybe just a relay to separate the motor from the PI (at least 2 circuits: GPIO 3.3v and 12v)

  64. Hi,
    I have been trying to figure out how to get sopare working, and from all the other comments i see that i need to clear the alsa.conf file. Could you please explain in detail how to do that, because i can’t find any error messages in it. I have tried using a fresh install of raspbian stretch on a raspberry pi 3.

    [DELETED alsa.conf file]

  65. Hello sir,
    I wanted to ask you what classification method did you used in sopare. Is it Feed forward Neural network, Recurrent neural networks or HMM ?

    • Hello. This has been asked before. The classification is something I developed on my own. No neural network involved nor the Hidden Markov Model. It’s just some configurable classifications/parameters derived from selected characteristics. You hopefully get the picture when you read this post 🙂

  66. I am really inspired by your Great effort,
    everything works fine but test_audio give recommendations in which it ask to set
    Threshold value: 32800
    which is very large whereas other ones are normal; i set this value but during training i get stream error and stucks
    i lower the value and set it to 320 but result is the same
    I am using webcam as the microphone

    • While the test_audio is running SOPARE measures the loudness of your environment. 32800 means you are living inside of an airplane engine. Or something similar. Such an environment is maybe too noisy for SOPARE. Not sure…
      Have fun!

    • From my perspective SOPARE is capable to recognition a voice. Can you please explain why do you think hat SOPARE is not voice recognition?

  67. Hi Martin,

    First at all congratulations for your work with Sopare.
    Sopare and my mic work well in ubuntu and I am trying to get Sopare running on Pi 3 but I am stuck at getting my threshold.
    If I run test_audio.py, it always says THRESHOLD = 0. Or if I run ./sopare.py -v -t train, it always stops at “INFO:sopare.recorder:start endless recording” no matter how loud I try to speak (I set THRESHOLD = 500 in config/default.ini).
    I have a usb desktop microphone attached to the Raspberry Pi 3.
    card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
    Audio recording with this microphone also works. So I don’t know why it doesn’t work in Sopare.
    Here is the shortened notice on the terminal:

    pi@raspberrypi:~/dev/sopare $ python test/test_audio.py
    test_audio init…

    Your sopare/config.py recommendations:

    SAMPLE_RATE = 48000
    CHUNK = 512
    THRESHOLD = 0

    pi@raspberrypi:~/dev/sopare $ ./sopare.py -v -t train
    sopare 1.5.0
    Expression ‘alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 924
    ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_alsa.pcm.front.0:CARD=0’


    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.0087074829932
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.0087074829932
    DEBUG:sopare.audio_factory:maxInputChannels: 32
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 4
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.0348299319728
    DEBUG:sopare.audio_factory:maxOutputChannels: 32
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0348299319728
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 48000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    ^CProcess buffering queue:
    Process worker for filtered data:
    Traceback (most recent call last):
    Traceback (most recent call last):
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
    self.run()
    self.run()
    File “/home/pi/dev/sopare/sopare/worker.py”, line 88, in run
    File “/home/pi/dev/sopare/sopare/buffering.py”, line 40, in run
    buf = self.queue.get()
    obj = self.queue.get()
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 117, in get
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 117, in get
    res = self._recv()
    res = self._recv()
    KeyboardInterrupt
    KeyboardInterrupt
    Traceback (most recent call last):
    File “./sopare.py”, line 187, in
    main(sys.argv[1:])
    File “./sopare.py”, line 108, in main
    recorder.recorder(cfg)
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 44, in __init__
    self.recording()
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 88, in recording
    buf = self.stream.read(self.cfg.getintoption(‘stream’, ‘CHUNK’))
    File “/usr/lib/python2.7/dist-packages/pyaudio.py”, line 608, in read
    return pa.read_stream(self._stream, num_frames, exception_on_overflow)
    KeyboardInterrupt

    Do I have to specify something somewhere? Thanks!

    • Seems that you have two sound cards and the one that is able to record sound is not the default card in the ASLA config. As soon as you change this it should work…

  68. Hi Bishoph, first of all thanks for the great work, your program is exactly what I am looking for. Unfortunately I am facing a problem with (I think it is pyaudio) my Alsa. I am using a PS Eye Microphone array, for which I set up a file etc/asound.conf with the following input:

    pcm.!default {
    type asym
    playback.pcm {
    type plug
    slave.pcm “hw:0,0”
    }
    capture.pcm {
    type plug
    slave.pcm “hw:1,0”
    }
    }
    It works fine, I can record and play. Also the test case of your program works (despite the error) fine.
    if I run python test/test_audio.py I am getting:

    test_audio init…
    Expression ‘alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 924
    Expression ‘alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 924
    ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_alsa.pcm.front.0:CARD=0’
    ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM front
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5036:(snd_config_expand) Args evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(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:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5036:(snd_config_expand) Args evaluate error: No such file or directory
    ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM bluealsa
    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
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 16000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.016
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.0239375
    DEBUG:sopare.audio_factory:maxInputChannels: 128
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 4
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.096
    DEBUG:sopare.audio_factory:maxOutputChannels: 128
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.096
    testing different CHUNK sizes … this may take a while!

    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Error: [Errno -9981] Input overflowed
    ERROR:sopare.audio_factory:Error: Stream not open
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.
    Excellent. Got all 5120 chunks.
    Excellent. Got all 10240 chunks.
    Excellent. Got all 20480 chunks.
    Excellent. Got all 40960 chunks.
    Excellent. Got all 81920 chunks.

    Your sopare/config.py recommendations:

    SAMPLE_RATE = 48000
    CHUNK = 512
    THRESHOLD = 600

    Do you know whats wrong, or how I can fix the problem?

    Cheers

    • There is not so much of an issue here. SOPARE simply goes through combination of possible values and in some cases some of the values don’t work well with some kind of hardware…you can ignore the failed test cases and just use the recommended values that should work 😉

      Have fun and happy holidays!

  69. Hallo.
    Ich habe auch das Problem das nach kurzer Zeit ein CPU Kern bei 100% hängen bleibt und das Script nicht mehr reagiert. Konnte das jetzt bei jemandem gelöst werden? Bei mir wird es nur schlimmer wenn ich chunk von 512 auf 1024 erhöhe, und wenn ich auf 256 erniedrige erkennt es kein Wort mehr, und es ist auch wenn ich nur 1x Test trainiere, und Plugins oder etwas geändert habe ich auch nicht (ausser die 3 Vorgeschlagenen Werte). Es ist immer gleich, wenn viele Geräusche erkannt oder nicht erkannt wurden geht es schneller, wenn nichts aufgenommen wird geht es länger, und dann geht 1 CPU Kern immer (soweit ich das bis jetzt gesehen habe) nach einem erkannten oder nicht erkannten Geräusch anstatt kurz hoch auf so 15-30% und wieder herunter, geht er hoch und danach auf 100% hoch und das RAM füllt sich langsam auf, bis irgendwann alles am Raspberry Pi 3 einfriert. Auf dem Pc passiert das eine halbe Stunde lang nicht, also ich denke es liegt am Raspberry.
    Wenn ich im Internet suche, lese ich manchmal etwas von man sollte eine kurze pause in eine Schleife machen, und schauen ob es dann besser ist weil es vielleicht in einem loop steckt. Aber wo soll ich das machen? Ich kann nicht python scripten, nur shell.
    Wenn ich danach mit ctrl+c abbreche kommen noch ein paar Zeilen im Terminal, unter anderem diese:
    File “/usr/lib/python2.7/multiprocessing/queues.py”, line 117, in get
    def read(self, num_frames, exception_on_overflow=True):
    Hat das etwas zu bedeuten?
    Es wäre nett wenn mir jemand helfen könnte, dieses Programm ist genau das was ich brauche..

      • Danke vielmals für die Antwort, aber ich bringe es trotzdem nicht hin… Wenn ich CHUNK und CHUNKS auf ca 1000 und 5000 erhöhe verlängert es nur die Zeit bis 1 Kern bei 100% hängen bleibt, weiter herauf habe ich es noch nicht ausprobiert weil ich nicht wollte das es so lange braucht das ich es nicht mehr richtig mitbekomme, und trotzdem irgendwann wieder einfriert. Und es wird auch immer schlechter weil es immer langsamer reagiert wenn ich CHUNK erhöhe, und nur CHUNKS behebt es nicht.
        Und sample rate kann ich nicht höher oder niedriger stellen als 16000, sonst startet es gar nicht und zeigt unter anderem an das ich die falsche sample rate habe.
        Die Zeile in pyaudio.py ändern nützt auch nichts, ich bin mir auch nicht sicher ob diese Datei bei mir gleich ist, bei mir steht bei Zeile 89 dort: :pa:data:`paCanNotReadFromAnOutputOnlyStream`,
        Und eine Zeile mit buf = findet grep nicht.

        Aber wenn ich das log level auf WARNING stelle kommt beim abbrechen mit ctrl+c sehr viel mal: WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
        Wie auf der 2. verlinkten Seite, aber ich kann sample rate nicht ändern.

        Hast du noch eine Idee? Es würde mir eigentlich auch schon reichen wenn ich einfach den Fehler überspringen könnte und gleich das nächste Wort wieder erkannt wird, ohne 5s lang auf den Neustart des Scriptes zu warten.

        • Ich habe es jetzt doch noch mit chunk und chunks höher probiert, nur zum testen, und komischerweise gibt es sofort die stream read error’s wenn ich chunk höher als 1300 setzte, und sie kommen bevor ich ctrl+c drücke..

          • Was sagt denn die SOPARE Empfehlung, die Bestandteil des Audio Test ist:
            python test/test_audio.py
            ?

          • Das:
            python test/test_audio.py

            test_audio init…
            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
            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
            testing different SAMPLE_RATEs … this may take a while!

            DEBUG:sopare.audio_factory:#### Default input device info #####
            DEBUG:sopare.audio_factory:defaultSampleRate: 16000.0
            DEBUG:sopare.audio_factory:defaultLowOutputLatency: -1.0
            DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.0239375
            DEBUG:sopare.audio_factory:maxInputChannels: 1
            DEBUG:sopare.audio_factory:structVersion: 2
            DEBUG:sopare.audio_factory:hostApi: 0
            DEBUG:sopare.audio_factory:index: 2
            DEBUG:sopare.audio_factory:defaultHighOutputLatency: -1.0
            DEBUG:sopare.audio_factory:maxOutputChannels: 0
            DEBUG:sopare.audio_factory:name: USB Device 0x46d:0x8c5: Audio (hw:1,0)
            DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.096
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            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
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate
            testing different CHUNK sizes … this may take a while!

            Excellent. Got all 5120 chunks.
            Excellent. Got all 10240 chunks.
            Excellent. Got all 20480 chunks.
            Excellent. Got all 40960 chunks.
            Excellent. Got all 81920 chunks.

            Your sopare/config.py recommendations:

            SAMPLE_RATE = 16000
            CHUNK = 512
            THRESHOLD = 300

            Also auf dem Pc ist mir auch 48000 SAMPLE RATE empfohlen worden mit der gleichen USB Kamera mit Mikrofon drin, und auf dem Pc geht es, aber beim Raspberry kann ich 48000 nicht auswählen, sonst kommt beim starten des Scriptes eben falsche sample rate..

          • Die Default Sample Rate für das Mic ist 16000. Die Info kommt vom Treiber, also sollte man die auch nehmen. Sofern es mit den empfohlenen Werten nicht geht, kann SOPARE nicht viel machen, da rein von der Architektur her der Mic-Input von anderem Komponenten übernommen wird (Alsa, Kernel Driver, PulseAudio, pyAudio, etc.). Alternativ mal ein anderes Mic probieren.

            Weiterhin könnte man auch mal die Alsa-Config aufräumen, da etliche Dinge konfiguriert sind die es gar nicht gibt und dieser Umstand wird bei jedem Aufruf immer wieder angemerkt…

          • Das könnte ja dann vielleicht bedeuten das es mit anderen Treibern, die 48000 sample rate unterstützen, funktionieren könnte, da es auf dem Pc mit dieser Änderung funktioniert.
            Ich bestelle sonst mal ein anderes Mikrofon für den Pi, das ich letzten Endes auch benutzen würde, wenn es brauchbar ist. Das könnte vielleicht eine Weile dauern bis das ankommt…

            Und bei der Alsa-Config wüsste ich nicht was ich da wie aufräumen sollte, so gut kenne ich mich mit all dem nicht aus, und ich habe auch nie etwas mit Sound am Raspberry verändert oder installiert soweit ich weiss, ausser vielleicht mplayer oder so installiert. Aber solange es nur Meldungen verursacht und keine Fehler…

  70. Ich habe jetzt das Mikrofon erhalten, aber bei dem muss ich so laut reden wenn es nicht direkt vor meinem Mund ist dass es nicht wirklich brauchbar wäre, und es bleibt auch wieder hängen nach kurzer Zeit, aber habe gar nicht mehr mit den Werten getestet, da es ja sowieso nicht wirklich zu gebrauchen wären.
    Wüsstest du ein Usb Mikrofon das mit dem Raspberry ohne Probleme funktioniert (aus eigener Erfahrung), das klein und billig ist, und auch aus 1-2m Entfernung noch funktioniert mit ruhiger Stimme?

    • Die Werte in der Config sind für jedes Mic anders, außerdem bestimmt der THRESHOLD die Schwelle, ab der Geräusche wahrgenommen werden. Ich empfehle alle bisher gelernten Daten zu löschen, auch die “raw” Dateien. Weiterhin empfehle ich die Original Werte der Config zu verwenden. Danach die Empfehlungen für das neue Mic auslesen und in Config schreiben. Nun kann man starten und schauen ob es hängt und ob noch Fehler kommen. Sofern vorhanden die Fehler beheben/lösen und erst dann mit dem Lernen beginnen. Hier schreibe ich welche Mics ich im Einsatz habe. Das preiswerteste liegt bei ca. 5€ und steuern meinen Magic Mirror, 24/7 aus 1-3 Metern Entfernung.

      • Ah ja, danke vielmals 🙂 Das muss ich mir mal genau durchlesen mit den 3 Mics.
        DIe empfohlenen Config Werte habe ich schon so eingetragen, aber ich habe glaube ich vergessen die bereits gelernten Wörter zu löschen, das könnte ich noch versuchen. Aber es ist sowieso so extrem leise, bei TRESHOLD konnte ich glaube ich sogar unter 100 einstellen, und trotzdem durfte es nicht weiter als 30cm oder so entfernt sein. Ich probiere es mal mit dem billigsten dieser 3 Mics, das scheint auch nicht so gross zu sein.

  71. Ich brauche umbedingt Hilfe:
    Ich habe sopare ganz normal installiert und alles hat so funktioniert wie ich es wollte. Ich habe eigene Wörter trainiert und habe eigene Programme schreiben können. Alles Perfekt. Als ich dann Gestern ein neues Wort trainieren und dies anschließend speichern wollte, kam auf einmal folgende Fehlermeldung, obwohl ich vorher ERFOLGREICH mehrer Wörter trainieren und speichern konnte.
    ——————-
    pi@raspberrypi:~/sopare $ ./sopare.py -c
    sopare 1.5.0
    recreating dictionary from raw input files…
    Traceback (most recent call last):
    File “./sopare.py”, line 187, in
    main(sys.argv[1:])
    File “./sopare.py”, line 100, in main
    recreate_dict(debug, cfg)
    File “./sopare.py”, line 130, in recreate_dict
    utilities.recreate_dict_from_raw_files()
    File “/home/pi/sopare/sopare/util.py”, line 195, in recreate_dict_from_raw_files
    self.writeDICT(self.getCompiledDict())
    File “/home/pi/sopare/sopare/util.py”, line 156, in getCompiledDict
    json_obj = json.load(raw_json_file, object_hook=sopare.numpyjsonencoder.numpyjsonhook)
    File “/usr/lib/python2.7/json/__init__.py”, line 291, in load
    **kw)
    File “/usr/lib/python2.7/json/__init__.py”, line 352, in loads
    return cls(encoding=encoding, **kw).decode(s)
    File “/usr/lib/python2.7/json/decoder.py”, line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File “/usr/lib/python2.7/json/decoder.py”, line 382, in raw_decode
    raise ValueError(“No JSON object could be decoded”)
    ValueError: No JSON object could be decoded
    ———————-
    Bitte um Rückmeldung (dringend)
    Danke

    • Hi. Ich kenne den Fehler nicht und kann nur raten. Kann es sein, dass die Datei “dict.json” komplett leer ist? Wenn ja, lege einfach die im Git befindliche Originale wieder an und versuche erneut das DICT via “-c” zu erstellen. Wenn nein, muss man genauer gucken aber nicht hier im Forum, sondern bitte über einen neuen “Git Issue”…

  72. hi sir….
    plz help me for this error?
    test_audio init…
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    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
    testing different SAMPLE_RATEs … this may take a while!

    DEBUG:sopare.audio_factory:#### Default input device info #####
    Traceback (most recent call last):
    File “test/test_audio.py”, line 129, in
    ta.test_sample_rates()
    File “test/test_audio.py”, line 78, in test_sample_rates
    self.stream = self.audio_factory.open(test_sample_rate)
    File “../sopare/sopare/audio_factory.py”, line 36, in open
    for k, v in self.pa.get_default_input_device_info().iteritems():
    File “/usr/lib/python2.7/dist-packages/pyaudio.py”, line 946, in get_default_input_device_info
    device_index = pa.get_default_input_device()
    IOError: No Default Input Device Available

    i’ve connected mic with pi but i’m getting this error

    • There is no mic that can be used. If you have a mic attached it means that the sound system is not able to use it for whatever reasons…

  73. Hey Bishoph
    I’ve been trying to integrate SOPARE for my home automation project that works on offline speech recognition.
    The basic set ups all went very well. The problem arises when I’m training SOPARE to learn keywords.

    When I speak after the endless recording has started, I first get a stream of data and then an error appears
    The message displayed is: sopare.recorder:stream read error [Errno -9988] Stream closed
    The message is displayed continuously and I have to force an interrupt using ctrl+C to come out of it.

    Is this something you can help me out with?
    Thanks in advance

    • Not much I can do about the error as it comes from the ALSA sub system. There are some information in the SOPARE GitHub issues and the internet itself has tons of stuff that could be eventually helpful…

  74. Hallo, ich bin es nochmals. Kennst du vielleicht auch ein Programm oder einen einfachen Weg das selbe mit Objekt Erkennung zu machen? Also anstatt ein paar mal ein Wort sagen ein paar Bilder mit dem selben Objekt zeigen (und evtl. auch ein paar ohne das Objekt), und danach soll es dieses Objekt wieder erkennen irgendwo im Zimmer. Kennst du irgend einen so einfachen weg wie bei Sopare, auch offline und ohne über einen Server etwas anzufragen? Besser wäre natürlich wenn es schon eine Datenbank dazu hat mit trainierten Bilder (aber nur wenn auch offline), jedoch wäre ohne vor trainierte Bilder auch schon ausreichend.

    • Hat zwar nichts mir SOPARE zu tun aber was solls 🙂 Mir fallen spontan die folgenden Projekte ein, die bei offline Object Detection passen sollten: OpenCV, Tensorflow Lite, MobileNet. Einfach den Context in eine Suchmaschine der Wahl eingeben und schon gibt es Zugriff auf Tutorials u.a. für den Raspberry PI inkl. Beispielcode…

      Have fun!

      • Bei OpenCV und Tenserflow (Lite) bin ich auch immer wieder mal vorbei gekommen, aber habe es nie so richtig verstanden…
        Aber ich bin jetzt mal auf einer Spur bei OpenCV. Geht nur alles nicht so schnell. Wenn ich es noch heraus finde ergänze ich noch.
        Danke für die Info.

    • There is a Python 3 branch for SOPARE on GitHub, but I don’t know the exact state. Can’t really answer the custom lib question because of the word “custom” 😉 Kidding apart, as SOPARE uses no fancy stuff, code should work as expected.

  75. Hello
    I am new to all of this and don’t consider myself a techy, but I’m trying to have fun.
    What I want to do is this :
    Use raspberry pi3 to voice recognize numbers and words
    Take these numbers and words and generate a gpio signal
    Take that signal and connect it to a circuit board and close a relay
    Each unique number and word would generate a different signal to close a different relay
    Each relay does a different function
    Voice recognition needs to start only when a trigger word or phrase is spoken

    Any chance that you can help me build this project?
    Please remember that I don’t know a thing about programming,but can follow instructions well.
    So while this project is easy for you,the challenge is to make it happy through my eyes and effort

    I hope you can help me, this is a project that will help many elderly people work this covid virus.
    Thank you.

    • Hi. I already developed SOPARE, wrote lots of tutorial, recorded videos and answered quite some questions. I also help elderly people and spend my free time to make the world a better place. What I will not do is provide detailed instructions for an individual project while you have no idea what you are doing. It would end up in frustration for you and me for obvious reasons. Start to learn programming or hire a local person with a good skill set to get your desired project. BTW: learning is part of the fun 😉

  76. Yes thank you
    I was hoping for pointers and not baby sitting
    Thank you for responding, at least toy acknowledged, most people would have given me the dinner.
    I work on this myself.

    • You are welcome. Start small and easy and train only a few numbers like one, two, three. Check if the training and recognizing meets your expectations. If not, try to tweak configurations and maybe test different microphones/conditions. When you are satisfied with the results add more words. Test again. Remember that SOPARE was designed to train only a few words! Until this phase you don’t need to know a thing about programming and development. Now you dive into SOPARE plugin development and take the source code/examples I provided at GitHub (like the example for the robotic arm). Adapt and code your desired GPIO stuff. Integrate your code into the plugin (lots of different possibilities), test, fix bugs, enhance, optimize and repeat the last 4 steps. Have fun 🙂

  77. Hey bishop

    First your work is really appreciated, I like the ideas behind SOPARE. I was searching for something working offline, something which can be trained (because normally there is no support for my native language), and works on my Raspberry Pi. Great work!

    It was quite easy to write a plugin to start a bash script based on the detected word, and like this I already have the connection to my home automation. After a few tests with a mic that only works when I’m very close, I decided to buy a ReSpeaker 4-Mic Array. I had a lot of troubles to set it up for SOPARE, but for now it seems to work ok, the recorded tokens seem to be the same as when I record it for example with arecord. Then I was struggling with the threshold, the test_audio always gave me a quite high value (like 2600), and when training I had problems that my word was detected. When I lowered the threshold a bit, the detection started already at the beginning and then stopped, before I even said a word. As I could not resolve this problem, I almost gave up… but later on I decided to dig deeper, so I logged the current volume from check_silence in processing.py. The volume when it is silent is normally below 150. But when the recording starts, there is an extra noise, which goes away after a few chunks. I think it comes from the mic itself. So I just needed a way to crop or ignore the first few chunks of the recorded stream. I changed the code that at the beginning it waits until there is silence (volume under the threshold value), and then it really starts and goes through the normal code. Like this I can lower the threshold to for example 300 and then I can train a word normally. Do you know this problem and you have already foreseen a way to handle this? If not, maybe you could consider to put something in, like waiting for silence or just cropping the first chunks of the stream when training?

    • Thanks. In terms of sound recognition, it’s important to get all information available as a lot of information sticks in the very beginning of a sound, e.g. a word. Very true for short sounds. That said, your noise floor THRESHOLD is 150. When you speak into the mic you get test values above 2000 which is very reasonable. But 2000 could be way too high for speaking from the distance. In this case SOPARE may already miss important information from the beginning. I should note that test_audio threshold is the highest value for a sound in the test period and config THRESHOLD is the value when SOPARE starts the process of recognition to detect a sound. The test_case value helps you to detect your noise floor (silence) while the THRESHOLD value is when you start speaking. Very different, right.

      My recommendation is to lower the THRESHOLD to let’s say 300-500. Go as low as SOPARE triggers the process when you speak your words but as high that SOPARE does nothing for normal back ground noise. So, in my opinion, if you are using a very high THRESHOLD SOPARE should have something in contrary to your feature request. SOPARE should take some information before the peak occurs. And in fact, SOPARE is doing exactly that. The buffer is hard coded to three – I may change this in the future…

  78. Hi, I came across a comment similar to my question although I couldn’t seem to resolve it with the information given. I am trying to run Sopare as a service but with no luck:( Is there any other way to initiate the program on boot-up? The software works great though! Wonderful job thanks, Ben

  79. hi bro
    Thank you for the great information
    i was able to install Sopare.
    but….!
    How cant i run a python file(file.py) after i saying a word to Sopare??
    pls help me 🙂
    Thanks!!

  80. Is this project still being developed? I have looked into offline voice recognition for the pi 3 years ago, there were no good solutions. This I think I also tried, I would give it another shot but as I see the git repo is very out of date.
    Anyone knows better option for completely offline voice recog for the pi with a microphone?

    Thanks!

  81. Your tutorial and code are great! I can not get mine to work fully yet as I’m missing the module called sopare.log even though I have the directories set up correctly. is there something I may be missing?

    • Make sure you start SOPARE from the directory where the files sopare.py and readme.md are located – but this is just a guess in the dark as I don’t have the exact error message…

  82. The script from github for sopare to run on boot no longer works. I’ve also tried with a simpler script following the tutorial here: https://www.raspberrypi.org/documentation/linux/usage/systemd.md
    This is the script I came up with:

    [Unit]
    Description=sopare service
    After=network.target

    [Service]
    ExecStart=/usr/bin/python2 -u sopare.py -l
    WorkingDirectory=/home/pi/CODE_sopare
    StandardOutput=inherit
    StandardError=inherit
    Restart=always
    User=pi

    [Install]
    WantedBy=multi-user.target

    It seems to work for a few seconds then fail. Please could you find a way for sopare to run at boot.

  83. Hi Bishoph! Thanks a lot for sharing your work, and for having explained everything step-by-step so that even a tech dummy as I am could follow through.
    I’m a neuroscientist working in songbirds, neurosciences of vocal production and language, and I’m trying to adapt this to recognize birdsong and operate a pump to deliver them sugar water, to train them to sing in specific patterns. I’ve tried several scripts, but yours seems to be the most promising one. I’m encountering a few issues, in particular with the specificity of the trigger, but I’m going through all your posts and I hope I’ll be able to get it to work.
    I just wanted to thank you very much. I’ll probably write again if I won’t be able to solve the issues, but for the time being, THANK YOU!

    • Thanks for your feedback and good luck with your project. I think that training and activating specific bird songs is quite challenging as they are normally quite and mixed with background noise.

      Have fun!

  84. Hallo Martin,

    Vielen lieben Dank, das Du dieses Projekt mit uns teilst. Bisher versuchte ich mit Jarvis zurecht zu kommen, aber Deine Spracherkennung ist nicht nur um einiges kompakter, sondern auch schneller und irgendwie flüssiger.

    Eine Rückfrage hätte ich da, als absoluter Anfänger. Die Installation war reibungslos. Ich nutze ein BT Headset, was auch von Sopare erkannt und genutzt wird. Das “Test” Training habe ich zumindest abgeschlossen, und auf mein Kommando Test wurde auch jedesmal reagiert. Aber bei der anschließenden Prüfung reagiert Sopare bei jedem Geräusch. Also egal ob ich Test sage oder auch nur huste.

    Kannst Du mir sagen, was ich da falsch gemacht habe?

    Vielen Dank und viele Grüße.

    • Hallo und gerne.

      Wenn SOPARE trainiert wurde und nun alles mögliche falsch erkennt liegt es entweder an der Qualität des Trainings oder an einer zu laschen Konfiguration. Es gibt ja einige Tutorials wie man vorgehen sollte um eine möglichst genaue Erkennung zu erreichen. Ohne weitere Infos kann ich nur generell Tips geben. Fang damit an den richtigen Threshold zu finden. SDOPARE sollte nur dann reagieren wenn du das gewünschte Wort auch sagst und nicht bei jedem Hintergrund Geräusch.

      Viel Spaß!

  85. Hallo Martin

    ich bin sehr interessiert die SOPARE auf meinem rasperry 3B zu nutzen. Habe alles gem. Instruktionen oben installiert. Das python test/test_audio.py liefert plausible Daten, ausser threshold = 0?
    Aber beim Versuch mit ./sopare.py -v -t test erhalte ich lange Meldungen von ALSA und dann passiert nichts mehr nach dem erwarteten endless recording. Sind die Meldungen von Alsa relevant für die Funktion von sopare? ev ein Tipp, wie ich diese hinkriegen könnte? (Rasperry habe ich kürzlich neu installiert und alle updates eigentlich gemacht.)
    Beste Grüsse
    Martin Eschle

    sopare 1.5.5

    INFO:sopare.analyze:checking for plugins…
    DEBUG:sopare.analyze:loading and initialzing plugins/print
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 44100.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.00868480725624
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00868480725624
    DEBUG:sopare.audio_factory:maxInputChannels: 32
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 11
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.0348072562358
    DEBUG:sopare.audio_factory:maxOutputChannels: 32
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.0348072562358
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 48000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    ^CProcess buffering queue:
    KeyboardInterrupt

    • Hallo. Ich habe in deinem Kommentar alle ALSA Meldungen gelöscht. Soweit ich sehen konnte trat kein Fehler auf. Auch SOPARE meldet keinen Fehler. Kann es sein das du SOPARE noch nicht trainiert hast? Oder du hast noch kein “DICT” generiert? Wie man einfach startet erkläre ich hier.

      Wenn es um Fehler oder Anhänge von Fehlerreports geht, so bitte ich darum diese über GitHub zu melden, da sich das Forum nicht wirklich zur Fehleranalyse eignet.

      Ciao,
      Martin

      • Hallo Martin
        super, danke für die schnelle Antwort! Dann habe ich evtl. nur ein Problem mit dem Alsa mit dem Mic, oder brauche noch ein anderes Mic, werde dies prüfen. Das trainieren und DICT generieren hatte ich gemacht, resp. versucht, aber mir schien, dass es nicht erfolgreich war.
        Gruss
        Martin

        • Also “THRESHOLD = 0” ist ja schon ein Indiz dafür das bei SOPARE nicht wirklich etwas ankommt…versuch doch mal mit einem anderem Programm ob du Sound aufnehmen kannst…

          Have fun!

  86. Hallo,

    erstmal danke für dieses Tool, leider bekomm ich es nihct zum laufen. 🙁
    Vorweg:
    Mein Mikro dürfte funktionieren, da ich mit den Befehlen unten einen WAV ertsellen/abhören kann.
    arecord –device=hw:2,0 –format S16_LE –rate 48000 -c1 test.wav
    speaker-test -c2 –test=wav -w test.wav

    Aber wenn ich ” ./sopare.py -v -t test ” starte kommt nur ein Fehler und ich kann nichts tun.
    MELDUNG:

    root@HAUSPANEL-1:/sopas/sopare# ./sopare.py -v -t test
    sopare 1.5.5
    [Useless ALSA Mess deleted]
    INFO:sopare.analyze:checking for plugins…
    DEBUG:sopare.analyze:loading and initialzing plugins/print
    INFO:sopare.worker:worker queue runner started
    DEBUG:sopare.audio_factory:#### Default input device info #####
    DEBUG:sopare.audio_factory:defaultSampleRate: 48000.0
    DEBUG:sopare.audio_factory:defaultLowOutputLatency: 0.00797916666667
    DEBUG:sopare.audio_factory:defaultLowInputLatency: 0.00797916666667
    DEBUG:sopare.audio_factory:maxInputChannels: 1
    DEBUG:sopare.audio_factory:structVersion: 2
    DEBUG:sopare.audio_factory:hostApi: 0
    DEBUG:sopare.audio_factory:index: 10
    DEBUG:sopare.audio_factory:defaultHighOutputLatency: 0.032
    DEBUG:sopare.audio_factory:maxOutputChannels: 2
    DEBUG:sopare.audio_factory:name: default
    DEBUG:sopare.audio_factory:defaultHighInputLatency: 0.032
    INFO:sopare.buffering:buffering queue runner
    DEBUG:sopare.recorder:SAMPLE_RATE: 48000
    DEBUG:sopare.recorder:CHUNK: 512
    INFO:sopare.recorder:start endless recording
    INFO:sopare.processing:starting append mode
    DEBUG:sopare.filter:New window!
    DEBUG:sopare.worker:characteristic = 0 {‘volume’: 12495, ‘peaks’: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 14, 15, 16, 17, 0.030881918039923573, 0.04144987311916884, 0.025982725147215224], ‘token_peaks’: []}
    DEBUG:sopare.worker:meta = [{‘token’: ‘stop’}]
    INFO:sopare.buffering:terminating queue runner
    INFO:sopare.recorder:Buffering not alive, stop recording
    INFO:sopare.recorder:stop endless recording

    • Hallo. Da ist kein Fehler bei dem ich irgendwie helfen könnte. Die vielen ALSA Meldungen habe ich gelöscht, aber das waren auch nur Infos und keine Fehler. Fehler kann man häufig daran erkennen das im Log irgendwo “ERROR”, “FAILURE” oder manchmal auch “CRASH” vorkommt…
      Mit der Option “-t” startet SOPARE den Trainingsmodus. Das heißt, es wird auf eine bestimmte Lautstärke gewartet, dann ein Sound aufgenommen und abgespeichert. Nach einer konfigurierbaren Pause beendet sich SOPARE. Genau das ist passiert 🙂

    • UPDATE:

      Ich denke es geht schonmal. 🙂 JUHU
      Nachdem ich diese Datei geändert hatte: sudo nano /usr/share/alsa/alsa.conf
      defaults.ctl.card 2
      defaults.pcm.card 2
      von 0 auf 2 ging es.

      ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
      ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
      ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
      []
      []
      [u’Schlafzimmer’]
      []
      [u’Wohnzimmer’]
      []
      []
      []
      [u’Schlafzimmer’]
      []
      []
      []
      []
      []
      [u’Wohnzimmer’]
      []

      Wie ich das jetzt in ein Script bekomme oder zu FHEM senden muss ich mal googlen 🙂

      DANKE für das TOOL!

        • Hi nochmal,

          meinst das liegt am Mcro das es so oft keine Sprache erkennt:

          ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
          [u’an’]
          []
          []
          []
          []
          []
          [u’aus’]
          []
          []
          []
          []
          []
          []
          []
          [u’an’]
          []
          []
          []
          []
          []
          []
          [u’aus’]
          []
          []
          []
          []
          []
          []
          [u’an’]
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          []
          [u’an’]
          []
          []
          []
          Hast du eine Empfehlung für ein gutes Micro?

          LG
          KOAL

          • Schwer zu sagen. Die Mics die ich verwende habe ich in einem Post aufgelistet. Ich verwende sehr unterschiedliche, je nach Bedarf und Situation…

  87. Hello Bishoph sir, you have done a tremendous work i must say. Besides you have open sourced the whole thing. God bless you.
    I am currently studying in an university in Bangladesh and working on a project of Home automation with raspberry pi. So, i am trying to use your voice recognition. I am amazed to see it works on any sound also working in our native language which is BANGLA.
    But it don’t recognize our Bangla word.
    Whenever i train it named “১” [ “১” means one ]
    it shows “\u09e7” instead of “১”

    Can you help me to get rid of this situation, thank you

    • Hey. Glad you like my work and good to know it works for your native language as well 🙂
      In terms of the output, I can only guess that this is some Unicode issue somewhere. If you want me to look into it and think this is a bug related to SOPARE, open a GitHub issue as this forum is not well suited for bug reporting and handling. In addition, add helpful information like how to reproduce, your environment and alike. In this special case information about your OS console locales settings and used Python versions, OS etc. could be handy. You get the locale information by running the locale command. Please attach the output and additional information if you file the issue.

      Have fun!

  88. Hi Bishoph

    When i run python3 sopare.py -u it keeps getting tuck at ModuleNotFoundError: No module named ‘prepare’. I have uninstalled it and installed it again but its the same error. i dont know if this is a path error but its in the same dir as all the others i thought.

  89. hello bishoph,
    I have two questions in my mind>>
    1. Is there any provision for changing dictionary ?
    2. is there any provision for training from the stored dataset ?

    • 1.) The dict is more or less a specialized JSON file so copy/move/delete should do the job
      2.) Not sure as I don’t understand the question 🙂

      • quistion 2 correction>> is there any provision for training from the stored audio file ?
        so happy to see a quick response from you
        god bless you

  90. thanks for the quick reply,
    I seriously loved the way you helping others
    sir, can i know these information>>
    1. is there any chance of including new library replacing JSON ?
    2. is there any provision to train the SOPARE from the saved audio file ?

    can i have your email ID >?

    • You are welcome 🙂

      1.) As the source code is available you can try to replace the JSON lib
      2.) No, training is currently only possible from the “raw” files created by SOPARE

      I usually do not answer questions by mail as mail is one to one and does not scale. Please use the forum or GitHub issues as my answer is reaching all users.

      Have fun!

  91. pi@raspberrypi:~/dev/sopare $ python sopare.py -u
    Traceback (most recent call last):
    File “sopare.py”, line 23, in
    import sopare.util as util
    File “/home/pi/dev/sopare/sopare/util.py”, line 29, in
    from scipy.io.wavfile import write
    ImportError: No module named scipy.io.wavfile

    I am stucked here. Please help me. How to solve?

    • Seems like you did not install the scipy package. Just follow the instructions and resolve the dependencies like described in the README file 🙂

  92. Hallo,

    leider komme ich beim Alsamixer nicht weiter, da mein USB-Mikrofon die Einstellung zum erhöhen der Lautstärke nicht akzeptiert bzw. ich kann mit den Pfeiltasten nicht rauf oder runter von “00” gehen. Gibt es da Lösungsansätze? Fehlt da ein Treiber ?

    • Hallo,

      ich denke das Mic wird nicht erkannt da man sonst ja die Werte ändern könnte, keine Ahnung ob das an fehlenden Treibern liegt. Brauchbare Hilfe könntest du aber eher in der ALSA Community bekommen, da ich ALSA auch nur als User benutze und kein Experte bin 🙂

          • Super, der RaspPi erkennt das Mic jetzt ohne Probleme, sogar mit dem Firmennamen.

            Jedoch erscheint bei dem Befehl “python test/test_audio.py” mehrzeilig sowas wie:

            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: 2718
            Expression ‘PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 2842
            ERROR:sopare.audio_factory:Error: [Errno -9997] Invalid sample rate

            Ist das schlimm oder nur als debug information gedacht?
            Denn beim Befehl “./sopare.py -v -t test” wenn ich test sage kommen aufeinmal einige fehlermeldungen wie:

            sopare 1.5.6
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.front.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM front

            und weiter unten von Python selbst:

            Traceback (most recent call last):
            File “/usr/lib/python3.9/multiprocessing/process.py”, line 315, in _bootstrap
            self.run()
            File “/home/pi/sopare/sopare/worker.py”, line 125, in run
            self.util.store_raw_dict_entry(self.cfg.getoption(‘cmdlopt’, ‘dict’), self.raw_character)
            File “/home/pi/sopare/sopare/util.py”, line 108, in store_raw_dict_entry
            json.dump(json_obj, json_file, cls=sopare.numpyjsonencoder.numpyjsonencoder)
            File “/usr/lib/python3.9/json/__init__.py”, line 179, in dump
            for chunk in iterable:
            File “/usr/lib/python3.9/json/encoder.py”, line 431, in _iterencode
            yield from _iterencode_dict(o, _current_indent_level)
            File “/usr/lib/python3.9/json/encoder.py”, line 405, in _iterencode_dict
            yield from chunks
            File “/usr/lib/python3.9/json/encoder.py”, line 325, in _iterencode_list
            yield from chunks
            File “/usr/lib/python3.9/json/encoder.py”, line 405, in _iterencode_dict
            yield from chunks
            File “/usr/lib/python3.9/json/encoder.py”, line 439, in _iterencode
            yield from _iterencode(o, _current_indent_level)
            File “/usr/lib/python3.9/json/encoder.py”, line 431, in _iterencode
            yield from _iterencode_dict(o, _current_indent_level)
            File “/usr/lib/python3.9/json/encoder.py”, line 405, in _iterencode_dict
            yield from chunks
            File “/usr/lib/python3.9/json/encoder.py”, line 438, in _iterencode
            o = _default(o)
            File “/home/pi/sopare/sopare/numpyjsonencoder.py”, line 38, in default
            return json.JSONEncoder(self, obj)
            TypeError: __init__() takes 1 positional argument but 3 were given
            DEBUG:sopare.filter:New window!
            INFO:sopare.processing:stop append mode because time is up

            Fehlen da Dateien oder oder da eine einstellung falsch? Jedenfalls tut sich mit dem neuem Mic zumindest was, also ein Stimmeneingang kommt beim Programm jedenfalls an.

          • Hi, das sieht doch schon mal gut aus. Die Ausgaben sind ein Mix aus ALSA Meldungen (hier hilft es die ALSA Config zu “säubern” und einigen Fehlern. Der Fehler ” Invalid sample rate” könnte an einer falschen Sample Rate liegen. Hier sollte man die Werte nehmen die SOPARE vorschlägt.

            Bei Python 3 gibt es ein Problem da sich eine Lib geändert hat. Einen Fix von mir gibt es noch nicht. Da hilft es nur Python 2 verwenden oder aber den Fix von “cahein” verwenden: https://github.com/bishoph/sopare/issues/98

          • Auf dem aktuellem Raspbian “Bullseye” wird Python2 nicht mehr unterstüzt, da einige Pakete fehlen. Tagelange probiererei ohne Erfolg mit Python2…

            Nun wollte ich den Fix probieren, bin ich jetzt auf ein anderes Problem gestoßen, ohne, dass ich etwas am Quellcode verändert hatte 🙁 Das ist doch verhext…

            sopare 1.5.6
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.front.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM front
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround51.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround21
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround51.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround21
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround40.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround40
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround51.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround41
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround51.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround50
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround51.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround51
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.surround71.0:CARD=0’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround71
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM spdif
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM spdif
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
            ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition ‘cards.bcm2835_headpho.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
            ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
            ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
            ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
            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

            ab da geht nichts mehr weiter… Kämpfe seit Tage, das Ding zum laufen zu bringen, aber es will einfach nicht! Was ist nun das für ein Fehler? Vorhin hatte ich den noch nicht!

          • Hi, ich sehe da keinen SOPARE Fehler, nur ALSA Meldungen…Bezgl. Python 3 bin ich leider noch nicht dazu gekommen Bullseye und das Python 3 Problem anzuschauen da ich dafür ein komplett neues System aufsetzen muss und auch die nächsten Monate sieht das schlecht aus da ich recht viel unterwegs bin. Sorry dafür.

  93. Traceback (most recent call last):
    File “../sopare.py”, line 187, in
    main(sys.argv[1:])
    File “../sopare.py”, line 108, in main
    recorder.recorder(cfg)
    File “/home/pi/dev/sopare/sopare/recorder.py”, line 41, in __init__
    self.buffering = sopare.buffering.buffering(self.cfg, self.queue)
    File “/home/pi/dev/sopare/sopare/buffering.py”, line 30, in __init__
    self.proc = sopare.processing.processor(self.cfg, self)
    File “/home/pi/dev/sopare/sopare/processing.py”, line 39, in __init__
    self.prepare = prepare.preparing(self.cfg)
    File “/home/pi/dev/sopare/sopare/prepare.py”, line 30, in __init__
    self.util = sopare.util.util(self.cfg.getbool(‘cmdlopt’, ‘debug’), self.cfg.getfloatoption(‘characteristic’, ‘PEAK_FACTOR’))
    File “/home/pi/dev/sopare/sopare/config.py”, line 33, in getfloatoption
    return self.config.getfloat(section, option)
    File “/usr/lib/python2.7/ConfigParser.py”, line 362, in getfloat
    return self._get(section, float, option)
    File “/usr/lib/python2.7/ConfigParser.py”, line 356, in _get
    return conv(self.get(section, option))
    File “/usr/lib/python2.7/ConfigParser.py”, line 607, in get
    raise NoSectionError(section)
    ConfigParser.NoSectionError: No section: ‘characteristic’

    I got this error after running python sopare.py

  94. Excellent Work…. I am testing to create a robot for my dauther.

    About the common error [Errno -9988] Stream closed, I changed this line in recorder.py

    buf = self.stream.read(self.cfg.getintoption(‘stream’, ‘CHUNK’))

    to

    buf = self.stream.read(self.cfg.getintoption(‘stream’, ‘CHUNK’), exception_on_overflow = False)

    And now the SOPARE Infinite loop is not stopping.

    You made a fantastic job with this library… the Offline Voice recognition is the best.

  95. This is completely broken and it’s a shame. It could become the quintessential sound recognition application for Raspberry and small computers, but it is a disaster due to the abandonment of its creator.

    I have not been able to make it work, I have installed 3 different versions of Python and it gives non-stop errors of missing libraries or lines in the code.

    Then the youtube tutorials from the developer and the installation guide are different, everything is absolute chaos.

    A pity that the developer does not put the batteries with something worthwhile. Anyway. To look for an alternative with more life.

    • Do you get any error messages? You should provide some kind of information including a good “how to reproduce” if you expect some kind of help.

  96. Hi Martin,
    I am trying to make a voice controlled house using raspberry pi. Then I found sopare and it sounded promising. I came across a problem in first steps and I don’t even know what is “xrange”. Can you help me?
    Here is the error:

    pi@raspberrypi:~/dev/sopare $ python sopare.py -u
    sopare 1.5.5
    starting unit tests…
    starting analyze tests…
    analyze test preparation…
    testing analyze get_match…
    testing normal conditions (1)[‘test2’] == [‘test2’]
    testing normal conditions (2)[‘test2’, ‘test1’] == [‘test2’, ‘test1’]
    testing normal conditions (3)[‘test2’, ‘test1’, ‘test3’] == [‘test2’, ‘test1’, ‘test3’]
    testing leading space [‘test2’, ‘test1’, ‘test3’] == [‘test2’, ‘test1’, ‘test3’]
    testing ending space [‘test2’, ‘test1’, ‘test3’] == [‘test2’, ‘test1’, ‘test3’]
    testing correct order [‘test2’, ‘test1’, ‘test3’, ‘test2’, ‘test1’, ‘test3’] == [‘test2’, ‘test1’, ‘test3’, ‘test2’, ‘test1’, ‘test3’]
    testing strict length [‘test2’, ‘test1’, ”, ‘test3’] == [‘test2’, ‘test1’, ”, ‘test3’]
    testing false leading results [”, ‘test2’, ”, ‘test3’] == [”, ‘test2’, ”, ‘test3’]
    analyze tests run successful.
    filter test preparation…
    testing filter n_shift…
    Traceback (most recent call last):
    File “/home/pi/dev/sopare/sopare.py”, line 187, in
    main(sys.argv[1:])
    File “/home/pi/dev/sopare/sopare.py”, line 104, in main
    unit_tests(debug, cfg)
    File “/home/pi/dev/sopare/sopare.py”, line 162, in unit_tests
    tests.unit_tests(debug, cfg)
    File “/home/pi/dev/sopare/test/unit_tests.py”, line 28, in __init__
    test.test_filter.test_filter(debug, cfg)
    File “/home/pi/dev/sopare/test/test_filter.py”, line 34, in __init__
    self.test_filter_n_shift()
    File “/home/pi/dev/sopare/test/test_filter.py”, line 41, in test_filter_n_shift
    for x in xrange(0, len(data_object_array), self.CHUNKS):
    NameError: name ‘xrange’ is not defined

Schreibe einen Kommentar zu bishoph Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert