bishoph / sopare Goto Github PK
View Code? Open in Web Editor NEWReal time sound pattern recognition in Python for Raspberry/Banana Pi.
License: Other
Real time sound pattern recognition in Python for Raspberry/Banana Pi.
License: Other
Hi,
I'm wondering if you could help me figure out what is wrong with my plugin.
after running for a few moment raspian freezes.
Thank you!
my code is below.
from gtts import gTTS
import time
import alsaaudio
import sys
import os
sys.path.append(os.path.abspath("/home/pi/Documents/AH_project/Player/"))
import mp3player
# Default plugin for output of audio control from environment sound
# print alsaaudio.cards()
# print alsaaudio.Mixer.cardname()
#m = alsaaudio.Mixer('Speaker', cardindex=1)
# m = alsaaudio.Mixer('PCM', cardindex=1)
master, slave = os.openpty()
mixer = alsaaudio.Mixer('Speaker', cardindex=1)
is_mute = mixer.getmute()[0]
usr_vol = mixer.getvolume()
# Call a function here for bike_bell, horn and announcement
def speak(name):
tts = gTTS(text= name, lang='en')
tts.save("speaker.mp3")
os.system("mpg123 speaker.mp3")
def conversation_vol():
#mixer.setvolume(int(3))
volume_down()
print 'someone is calling you'
def volume_up(usr_vol):
#mixer = alsaaudio.Mixer('Speaker', cardindex=1)
mixer.setvolume(int(usr_vol))#brings back the audio to the users originally set audio volume
def volume_down():
#mixer = alsaaudio.Mixer('Speaker', cardindex=1)
mixer.setvolume(int(3)) #this is the lowest volume that alsaaudio can go with the usb audio card
def toggle_mute():
global is_mute
mixer.setmute(1 - is_mute)
is_mute = mixer.getmute()[0]
if is_mute:
print('Muted')
else:
print('Un-muted')
def run(readable_results, data, rawbuf):
#mix = alsaaudio.Mixer('Speaker', cardindex=1)
global usr_vol
try:
if not readable_results:
print 'empty'
elif (readable_results[0] == 'hey'):
conversation_vol()
time.sleep(10)
volume_up(usr_vol)
elif (readable_results[0] == 'bike_bell'):
mp3player.pause()
speak("Watch out for the bike")
volume_down()
time.sleep(5)
mp3player.pause()
volume_up(usr_vol)
elif (readable_results[0] == 'horn'):
mp3player.pause()
speak("Watch out for the car")
volume_down()
time.sleep(5)
mp3player.pause()
volume_up(usr_vol)
elif ( readable_results[0] == 'announcement' ):
mp3player.pause()
speak("announcement")
volume_down()
time.sleep(5)
mp3player.pause()
volume_up(usr_vol)
else:
print "Listening"
except Exception as err:
print err
mp3player.play()
mp3player code
import os
import subprocess
master, slave = os.openpty()
def play():
#add function to play song
global master
global mp3_files
subprocess.Popen(['mpg123', '-C','-q', '/home/pi/Documents/AH_project/Player/track04.mp3'], stdin=master)
def stop():
#add function to quit song
global slave
os.write(slave, 'q')
def pause():
#add function to pause song
global slave
os.write(slave, 's')
I'm trying to get the print plugin to write to a file, but it doesn't seem to work.
file = "./output.txt"
def run(readable_results, data, rawbuf):
output = open(file, "a")
if(len(readable_results) < 1 ):
output.write('no response')
elif('weather' in readable_results):
output.write('weather')
elif('news' in readable_results):
output.write('news')
elif('video' in readable_results):
output.write('video')
output.write("\n")
output.close()
Hi,
when I Use
sopare -t
I get always the message:
start endless recording
Buffering not alive, stop recording
stop endless recording
or a
start endless recording
Process buffering queue:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/pi/sopare/sopare/buffering.py", line 42, in run
self.proc.check_silence(buf)
File "/home/pi/sopare/sopare/processing.py", line 82, in check_silence
self.stop("stop append mode because of silence")
File "/home/pi/sopare/sopare/processing.py", line 51, in stop
self.prepare.stop()
File "/home/pi/sopare/sopare/prepare.py", line 72, in stop
self.filter_reset()
File "/home/pi/sopare/sopare/prepare.py", line 89, in filter_reset
self.filter.reset()
File "/home/pi/sopare/sopare/filter.py", line 42, in reset
self.queue.put({ 'action': 'reset' })
File "/usr/lib/python2.7/multiprocessing/queues.py", line 100, in put
assert not self._closed
AssertionError
Buffering not alive, stop recording
if I play a .raw-file in the dict-directory with
aplay
I cannot hear any of my spoken words. I hear only random noise.
I am Using Raspberry Pi 3 Model B with Jessie and a USB Kinobo microphone.
Here the first lines of my config.py:
CHUNK = 512
#SAMPLE_RATE = 44100
SAMPLE_RATE = 32000
THRESHOLD = 250
MAX_SILENCE_AFTER_START = 1
MAX_TIME = 3.2
LONG_SILENCE = 30
CHUNKS = 2048
I tried it also with CHUNK = 500. Does also not work.
./sopare.py -u shows ...
filter tests run successful.
unit_tests run successful!
done.
python test_audio.py shows...
ImportError : No module named sopare.log
Kindly advise how to fix this. :-)
Hello,
so i've started training now, but I run into a new problem.
I've tried to train a new word using ./sopare.py -t "Dere"
But right after i speak the word, sopare crashes with the following error message:
sopare 1.4.9
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
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/queues.py", line 268, in _feed
send(obj)
IOError: [Errno 32] Broken pipe
Maybe you can also help me with that as I would really like to get it running.
Thanks!
Hi, it seems there are "problems"? with pyaudio and mic arrays. There is an Url to a discussion on git. Maybe it is possible to implement something like this, so that we can choose the record methode in config file.
record with arecord :
https://github.com/Kitt-AI/snowboy/blob/master/examples/Python/snowboydecoder_arecord.py
Hi, I'm getting the below error message when running ./sopare.py -l -v. Randomly it seems to work for some time but will eventually crash. Here is the output. Any clue what is going wrong?
pi@raspberrypi:~/sopare $ ./sopare.py -l -v 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 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 INFO:sopare.worker:worker queue runner started 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 INFO:sopare.buffering:buffering queue runner DEBUG:sopare.recorder:SAMPLE_RATE: 44100 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/pi/sopare/sopare/buffering.py", line 43, in run self.proc.check_silence(buf) File "/home/pi/sopare/sopare/processing.py", line 74, in check_silence self.prepare.prepare(buf, volume) File "/home/pi/sopare/sopare/prepare.py", line 125, in prepare self.tokenize(meta) File "/home/pi/sopare/sopare/prepare.py", line 50, in tokenize self.filter.filter(self.buffer, meta) File "/home/pi/sopare/sopare/filter.py", line 126, in filter chunked_norm = self.get_chunked_norm(nfft) File "/home/pi/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
Hi there,
after setting up the environment following the instructions on your blog (https://www.bishoph.org/step-by-step-raspberry-pi-offline-voice-recognition-with-sopare/), i really like the project. However, I've found a major problem that blocks further use.
When letting ./sopare.py -l
run for a longer time, at a certain point the script hangs. This is noticeable due to is high CPU usage (a full core) and the fact that no more audio is processed (no output in the log). It seems that things like music which are above the THRESHOLD level and therefore trigger a continuous activity of the application cause this problem after a certain amount of time. However, this does not occur for short periods of sound above this level.
I'm running a freshly pulled version of sopare on a raspberry pi 2 with a USB sound card that has a microphone attached to it. In normal situations, the detection works flawlessly.
The following stacktrace shows up when interrupting the application with CTRL+C:
^CTraceback (most recent call last):
File "./sopare.py", line 187, in <module>
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 95, in recording
self.logger.warning("stream read error "+str(e))
KeyboardInterrupt
Process 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()
File "/usr/lib/python2.7/multiprocessing/queues.py", line 117, in get
obj = self.queue.get()
File "/usr/lib/python2.7/multiprocessing/queues.py", line 117, in get
res = self._recv()
res = self._recv()
KeyboardInterrupt
KeyboardInterrupt
Hi,
I am using sopare and using sounds such as heart monitor, alarm etc. from https://www.soundsnap.com/tags/hospital_machines link.
I tried increasing the sample rate and adjusting the thresold and other values however I could not manage to do it. The default version of the default.ini works for some sounds, but since I want to use hospital sounds, It did not work. I increased the frequency to 8000 but I think I am doing something wrong.
How should I configure the values in the default.ini file?
Thank you
#########################################################
# Stream prep and silence configuration options #########
#########################################################
[stream]
# Read chunk size
CHUNK = 512
# Sample rate
SAMPLE_RATE = 48000
# Volume threshold when audio processing starts / silence
THRESHOLD = 380
# Silence time in seconds when analysis is called
MAX_SILENCE_AFTER_START = 1.4
# 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 = 3072
#########################################################
# 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 = 5
MAX_PROGRESSIVE_STEP = 5
# 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 = 20
HIGH_FREQ = 600
# 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 = 3
# Min. value for potential beginning of a word
MARGINAL_VALUE = 0.7
# Minimal similarity across all comparison to
# identify a complete word across all tokens
MIN_CROSS_SIMILARITY = 0.8
# Calculation basis or token/word comparison
SIMILARITY_NORM = 0.6
SIMILARITY_HEIGHT = 0.4
SIMILARITY_DOMINANT_FREQUENCY = 0
# 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 = 2
# Min. distance to keep a word
MIN_LEFT_DISTANCE = 0.9
MIN_RIGHT_DISTANCE = 0.7
# Use given number as results to assembly result
# 0 for all predictions
MAX_WORD_START_RESULTS = 2
MAX_TOP_RESULTS = 3
# 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
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 = false
`
```
perhaps there is a typo in filter.py:
./sopare/filter.py: progessive += progessive * soparee.config.PROGRESSIVE_FACTOR
Must be sopare.config?
Sometimes I get a
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/pi/sopare_1.4.0/sopare/sopare/buffering.py", line 44, in run
self.proc.check_silence(buf)
File "/home/pi/sopare_1.4.0/sopare/sopare/processing.py", line 76, in check_silence
self.prepare.prepare(buf, volume)
File "/home/pi/sopare_1.4.0/sopare/sopare/prepare.py", line 127, in prepare
self.tokenize(meta)
File "/home/pi/sopare_1.4.0/sopare/sopare/prepare.py", line 52, in tokenize
self.filter.filter(self.buffer, meta)
File "/home/pi/sopare_1.4.0/sopare/sopare/filter.py", line 129, in filter
chunked_norm = self.get_chunked_norm(nfft)
File "/home/pi/sopare_1.4.0/sopare/sopare/filter.py", line 64, in get_chunked_norm
progessive += progessive * soparee.config.PROGRESSIVE_FACTOR
NameError: global name 'soparee' is not defined
Hello,
i've already written you on your blog and opened now the issue like you suggested.
https://www.bishoph.org/sopare-precision-and-accuracy/#comment-198
So the program crashed as soon as the sound level got over threshold with the following message:
Process buffering queue:
Traceback (most recent call last):
File „/usr/lib/python2.7/multiprocessing/process.py“, line 258, in _bootstrap
self.run()
File „/home/pi/testing_sopare/sopare/buffering.py“, line 43, in run
self.proc.check_silence(buf)
File „/home/pi/testing_sopare/sopare/processing.py“, line 74, in check_silence
self.prepare.prepare(buf, volume)
File „/home/pi/testing_sopare/sopare/prepare.py“, line 125, in prepare
self.tokenize(meta)
File „/home/pi/testing_sopare/sopare/prepare.py“, line 50, in tokenize
self.filter.filter(self.buffer, meta)
File „/home/pi/testing_sopare/sopare/filter.py“, line 130, in filter
if (shift_fft != None and self.cfg.hasoption(‚experimental‘, ‚FFT_SHIFT‘) and self.cfg.getbool(‚experimental‘, ‚FFT_SHIFT‘) == True):
I've tried the change you suggested
if ((shift_fft is not None) and self.cfg.hasoption('experimental', 'FFT_SHIFT') and self.cfg.getbool('experimental', 'FFT_SHIFT') == True):
at line 130 in the filter.py and it works!
The program is now working and I will start training words :)
Thanks very much!
Hi!
I'm trying to train sopare but after I've ran ./sopare -t test
and I pronounced "test" but nothing happens...
I installed all dependencies, and I tested mic with arecord and it works fine.
I'm using usb mic. Is it necessary to configure the default mic device somewhere in sopare?
Adrian says:
8. Mai 2017 at 20:16
Thank you very much for sharing this project.
It is very interesting and works without any effort on Orange PI LITE.
Question: Can take the pattens from files already generated in .wav format?
This would avoid having to use the microphone to capture each of the sounds.
Greetings from Mallorca.
Antworten
bishoph says:
8. Mai 2017 at 22:16
You are welcome and great to hear that it works for you on an Orange PI LITE!
In regards to your questions: training from „wav“ files is currently not supported. But there is an option to store recorded input:
../sopare.py -w samples/test.raw
and the recorded file can be used for training or testing:
./sopare.py -r samples/test.raw – t test -v
As this options are already available, it should be possible to create a converter to transform „wav“ to „raw“ files, to achieve what you are asking for. I’ve added this to my to-do list, but I remember something that there was an issue converting „wav“ files so it’s not guaranteed that this becomes a feature 😉
Saludos
Antworten
Adrian says:
9. Mai 2017 at 10:21
Thank you for answering so quickly!
With your suggestion I have found this great tutorial where it explains how to do the conversion
https://www.hellomico.com/getting-started/convert-audio-to-raw/
After that, I have using:
./sopare.py -r samples/test.raw -t test -v
./sopare.py -c
But there are no changes in the dict.json file so it does not recognize the new „test“ pattern.
There is any way to attach or send the test.raw so that you take a look and validity this method of conversion?
Thanks in advance!
Antworten
Adrian says:
9. Mai 2017 at 10:55
I have also tried:
./sopare.py -w samples/test.raw
./sopare.py -r samples/test.raw -t test -v
./sopare.py -c
The same, no changes.
But, if you open the test.raw file generated by sopare in audacity, the format is Signed 16 bit PCM – Little-endian – 1 Channel (MONO) and the audio is correct, same like generated by the conversion from wav to raw.
Antworten
bishoph says:
9. Mai 2017 at 18:02
Hmm, what’s possible is that the volume is below the THRESHOLD and therefore „test“ doesn’t show up in the dict.json file as it was never learned, but this is just a wild guess. I tested again and as expected, everything works in my environment 🙂
I would like to suggest to move this thread and the issue we are discussing to GitHub, as you can easily attach files, track the issue and I can close it when its done: https://github.com/bishoph/sopare/issues/new
BTW: You can check what’s already learned with the command:
./sopare.py -o
The output is a string pair which consists of the ID and a UUID, which corresponds with the a JSON file in the dict/directory (even if the suffix pretends something different) …
In the case you want to see only unique learned IDs, this command chain is quite handy:
./sopare.py -s '' | sed 's/[^a-z].//' | sed 's///g' | grep -v '^$' | sort | uniq
Thanks y un saludo 🙂
Recording works, in mono, too. But there is an overflow error...
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
same error if i read a .wav or .raw file.
Hi,
I notice that sometimes the threshold value suggestion is changing (not always) after the pi is rebooted, i can assure you that the background noise level is exactly on the same level..
All i can do if this is happening, is keep rebooting the pi until it behaves normally again (the threshold would change back to 100-300, and again in the exactly same background noise level)
Is there any fix for this?
Thanks,
Alvin
Similarly to how arecord handles selecting of the input device, sopare could allow users to specify the desired input card.
./sopare.py --device "hw:CARD=Loopback,DEV=1,SUBDEV=0" -t test_word
This would solve more than one existing issues.
Hi,
I suddenly have the following problem, when starting Sopare and give a voicecommand, Sopare runs all commands inside plugins folder. Even when it doesn't recognize any word.
When it doesn't recognize a word the output shows this:
Lampen zijn aan Lampen zijn aan Lampen zijn uit Lampen zijn uit
and nothings happens (no lights go on/off).
When it detects a word, it executes the commands behind it (both commands)
So when I'm saying a trained word like "Lights On" and sopare recognizes it, it starts at the top of the init.py file and turns my lights on, they then immediately turn off. Because the next command is the lights off command.
If I speak the lights off command, he first runs the light on command and then the light off command.
output then is:
Lampen zijn aan Lampen zijn aan Lampen zijn uit Lampen zijn uit [u'dubbelklap'] Lampen zijn aan Lampen zijn aan Lampen zijn uit Lampen zijn uit [u'dubbelklap', u'dubbelklap'] Lampen zijn aan Lampen zijn aan Lampen zijn uit Lampen zijn uit [] Lampen zijn aan Lampen zijn aan Lampen zijn uit Lampen zijn uit
Here is my setup....
my config/default.ini :
######################################################### ### Stream prep and silence configuration options ######### ######################################################### [stream] ### Read chunk size CHUNK = 512 ### Sample rate SAMPLE_RATE = 48000 ### Volume threshold when audio processing starts / silence THRESHOLD = 350 ### Silence time in seconds when analysis is called MAX_SILENCE_AFTER_START = 1.4 ### 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 = 3072 ######################################################### ### 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 = 5 MAX_PROGRESSIVE_STEP = 5 ### 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 = 20 HIGH_FREQ = 600 ### 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 = 3 ### Min. value for potential beginning of a word MARGINAL_VALUE = 0.7 ### Minimal similarity across all comparison to ### identify a complete word across all tokens MIN_CROSS_SIMILARITY = 0.8 ### Calculation basis or token/word comparison SIMILARITY_NORM = 0.6 SIMILARITY_HEIGHT = 0.4 SIMILARITY_DOMINANT_FREQUENCY = 0 ### 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 = 2 ### Min. distance to keep a word MIN_LEFT_DISTANCE = 0.9 MIN_RIGHT_DISTANCE = 0.7 ### Use given number as results to assembly result ### 0 for all predictions MAX_WORD_START_RESULTS = 2 MAX_TOP_RESULTS = 3 ### 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 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 = false
My init.py
###!/usr/bin/env python ### -*- coding: utf-8 -*- """ Copyright (C) 2015 - 2017 Martin Kauss ([email protected]) 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 subprocess ### Lampen aan - Spraak def run(readable_results, data, rawbuf): if ('dubbelklap' in readable_results): subprocess.call("curl -H 'Content-Type: text/plain' -X POST -d 'ON' http://192.168.1.253:8080/rest/items/wcd001_schakelaar", shell=True) print ('Lampen zijn aan') ### Lampen aan - Klappen if ('lampen-aan' in readable_results): subprocess.call("curl -H 'Content-Type: text/plain' -X POST -d 'ON' http://192.168.1.253:8080/rest/items/wcd001_schakelaar", shell=True) print ('Lampen zijn aan') ### Lampen uit - Spraak if ('lampen-uit' in readable_results): subprocess.call("curl -H 'Content-Type: text/plain' -X POST -d 'OFF' http://192.168.1.253:8080/rest/items/wcd001_schakelaar", shell=True) print ('Lampen zijn uit') if ('vingerknip' in readable_results): subprocess.call("curl -H 'Content-Type: text/plain' -X POST -d 'OFF' http://192.168.1.253:8080/rest/items/wcd001_schakelaar", shell=True) print ('Lampen zijn uit')
I'm running Ubuntu 18.04
What could be wrong?
Thanks for your help.
Hi,
I'm able to track environmental noises and detect certain sounds from my pc. I also have a pi and i2s mems microphone, which record sounds with arecord command in wav format smoothly. However when I try to run the program from my pi, my recommended threshold is too high (around 8k) and also it gives me an error about samplerate matching. I guess it recognized my microphone but something went wrong and I'm not able to use it because it does not sense any sounds. Should I do any more settings
Secondly not related but can I run the program for a determined time interval? I do not want to loop forever but without -l command time is not sufficient. I want to run it for 10 seconds etc.
Hi,
Is it possible to execute commands from the python script?
As an example:
def run(readable_results, data, rawbuf): if ('lights' in readable_results and 'on' in readable_results): execute (curl command)
Or any other shell action for that matter
i get false positive on these commands:
[lampe] triggers on "wampe" "pampe" "rampe" ...
[licht] on "gicht" "sicht" "nicht" ...
[steckdose] on "becksdose" ...
which parameters do i need to change or which is the most important? i'm stuck in the finetuning
I wrote a following plugin for rapiro voice control. Unforunately it doesn't seem to work.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
# Plugin for Rapiro speech recognition
def run(readable_results, data, rawbuf):
if ('rapiro_activate' in readable_results):
os.environ['ISLISTENING'] = '1'
execute('echo \"#PR000G255B000T010\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('rapiro_sleep' in readable_results):
os.environ['ISLISTENING'] = '0'
execute('echo \"#PR000G000B255T010\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('rapiro_shutdown' in readable_results):
os.environ['ISLISTENING'] = '0'
execute('echo \"#Z\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
execute('echo \"#PR000G000B000T010000\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
execute('sudo shutdown now')
if (os.environ['ISLISTENING'] == '1'):
if ('stop_action' in readable_results):
execute('echo \"#M0\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('go_forward' in readable_results):
execute('echo \"#M1\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('go_back' in readable_results):
execute('echo \"#M2\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('go_left' in readable_results):
execute('echo \"#M4\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('go_right' in readable_results):
execute('echo \"#M3\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('wave_hand' in readable_results):
execute('echo \"#M5\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('action_six' in readable_results):
execute('echo \"#M6\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('action_seven' in readable_results):
execute('echo \"#M7\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('wave_goodbye' in readable_results):
execute('echo \"#M8\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
if ('action_nine' in readable_results):
execute('echo \"#M9\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
def execute(command):
command_line = command
os.system(command_line)
I launch it with the following script
import os
import subprocess
os.environ['ISLISTENING'] = '0'
os.system('echo \"#PR000G000B255T010\" | sudo minicom -b 57600 -o -D /dev/ttyAMA0')
subprocess.Popen('python sopare.py -l')
Sopare freezes right after start. If I use ./sopare.py -v -t test for training very often the following error starts appearing "[Errno -9988] Stream closed"
Does somebody else having similiar issues?
Before when i was using fewer commands(3-4) and no environmental variables everything was working fine.
could you please tell me where the code specifically for the output is?
(where does it print the output directly?)
maybe this helps someone...
my /etc/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 4
}
ttable [ [ 1 0 0 0 ] ]
}
pcm.channel2 {
type route
slave {
pcm array
channels 4
}
ttable [ [ 0 1 0 0] ]
}
pcm.channel3 {
type route
slave {
pcm array
channels 4
}
ttable [ [ 0 0 1 0 ] ]
}
pcm.channel4 {
type route
slave {
pcm array
channels 4
}
ttable [ [ 0 0 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"
}
pcm.channel3_softvol {
type softvol
slave.pcm channel3
control.name "Channel 3 Capture Volume"
}
pcm.channel4_softvol {
type softvol
slave.pcm channel4
control.name "Channel 4 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 }
c { pcm channel3_softvol channels 1 }
d { pcm channel4_softvol channels 1 }
}
bindings [
{ slave a channel 0 }
{ slave b channel 0 }
{ slave c channel 0 }
{ slave d 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 1 1 ] ]
}
next i need to know which index the capture_mono device has
list.py
import pyaudio
p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
dev = p.get_device_info_by_index(i)
print((i,dev['name'],dev['maxInputChannels']))
for me it is 15
next, put it in the sopare config
[hardware]
CARD_INDEX = 15
a small change to audio_factory.py
...
self.stream = self.pa.open(format = input_format,
channels = 4, # mono
rate=sample_rate,
input=True,
---> input_device_index = self.cfg.getintoption('hardware', 'CARD_INDEX'),
...
for me it looks like it records mono now (checked in audacity). I have a 4 mic Playstation 3 Eye USB cam/mic.
can someone try this too pls?
It seems something goes wrong with the buffering, after the command
~: python sopare.py -t main
I use Python 2.7.12 on Ubuntu (16.04)
Tracelog below (some paths changed for privacy)
Process buffering queue:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "../sopare/sopare/buffering.py", line 44, in run
self.proc.check_silence(buf)
File "../sopare/sopare/processing.py", line 83, in check_silence
self.stop("stop append mode because time is up")
File "../sopare/sopare/processing.py", line 52, in stop
self.prepare.stop()
File "../sopare/sopare/prepare.py", line 72, in stop
self.filter_reset()
File "../sopare/sopare/prepare.py", line 89, in filter_reset
self.filter.reset()
File "../sopare/sopare/filter.py", line 48, in reset
self.queue.put({ 'action': 'reset' })
File "/usr/lib/python2.7/multiprocessing/queues.py", line 100, in put
assert not self._closed
AssertionError
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/queues.py", line 268, in _feed
send(obj)
IOError: [Errno 32] Broken pipe
Error occurs in both master and testing branch
I need help,
you mentioned i should add "SIMILARITY_ZERO_CROSSING_RATE", but i dont't know where to add and which value it needs.
Pls give me a hint. :)
thx
i run sopare with -v option and after some time, the mic stops scanning..
right before the mic stops scanning, it shows these messages:
WARNING:sopare.recorder:stream read error [Errno -9981] Input overflowed
WARNING:sopare.recorder:stream read error [Errno -9988] Stream closed
and if it runs without -v option (after some time), the error is:
ERROR:sopare.audio_factory:Error: Stream not open
Hello and happy new year, I would like to know if there is any way I can recognize the voice through a file instead of being by the microphone (loop)? I know I can use files to train, but can I use files to recognize them?
Let's say I wanted a simple 1 or 2 word command to be recognized. How many audio samples do you think would be needed for Sopare to train on?
Pretty cool tool you developed!
I installed on my Rpi3 and can run the sopare.py
But I guess I first have to do something like learning words?
Can you please describe in a few basic words how the workflow of this tool goes.
Thank you very much!
btw: searching a simple voice control tool to make an art installation where you can ask the figures who they are.... messed around with jasper and wit.ai, but in the gallery I am offline....
Hi,
thank you for neat little project! I almost gave up hope that I would find some kind of voice recognition software that works offline and here it is!
anyway: I’ve forked sopare and started working on a python3 port. You’ll find the repository here.
I already got it running on my Raspberry Pi 3 though it keeps eating RAM and CPU until it dies.
There are a few other changes I’ve made and that I would like to do:
Done:
ToDo:
getopt
with argparse
imp
module with importlib
test
:). I think you should look into python -m unittest discover
. Generally speaking: there’s too much local state in the test classes and some of the tests feel more like application runtime checks and configuration generation. I’d love to get the tests back working so I can feel safe making other changes.Anyway… I hope this is not overwhelming.
If you’d like we could use this issue for further communication on the state of my changes or I can open up a pull request right away.
is there any built-in function to detect different kind of alarm sounds? i tried to train it for police/ambulance siren, but failed. can it be succeeded? or is it just for voices?
This is kind of strange, all of the tests are passing but I'm getting microphone errors:
python sopare.py -u
yields:
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.
But this command python test/test_audio.py
:
test_audio init...
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown 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 confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
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
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: 44100.0
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: 6
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
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.
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 = 300
As you can see, all of the tests seem to pass, but I've got some serious microphone errors. Any help would be appreciated. Thanks for the library!
Since everyone has a smartphone, is there a way that the samrtphone can act as mic for sopare? Can you build such a feature? One advantage would be, that no one has to mess with the ALSA configuration.
Hi,
I'm wondering if a series of .wav or .raw file can be use for training.
I saw that there is a way to read a raw file but not sure how is that used.
Thank you!
This is not An issue, it's Just An question.
Would sopare work with An audio stream? I'm working on a project where the only microphone that is available is on an ip camera.
Thnx in advance!
Hi Bishoph.
Your project sounds really nice and probably exactly what I am looking for... a lightweight speech recognition for the RPi. Unfortunately it is not working.
I use a RPi 2 with the new Raspbian Stretch lite. I installed all dependencies from your readme.
The software is going to start:
pi@RPI2:~/sopare $ sudo python sopare.py -l >> run.log
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
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
The output of the run.log is:
sopare 1.3.0
start endless recording
sopare 1.3.0
start endless recording
stream read error [Errno -9981] Input overflowed
stream read error [Errno -9988] Stream closed
stream read error [Errno -9988] Stream closed
... million of times
I guess it is an issue with the sound system. I use a USB Soundcard, which is device 0. Internal is device 1.
How to solve this problem? I guess I need to tell the recorder that the microphone is at hwplug:0,0. But sound output shall be at hwplug:1,0.
Hello,
when trying to run the test train script, I receive the following error.
I use a fresh RPi3 with latest Raspbian stretch on it.
_```
./sopare.py -t -v "Test"
sopare 1.4.0
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835.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.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.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.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.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.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.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.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.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.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.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
/home/pi/sopare/sopare/filter.py:133: FutureWarning: comparison to None
will result in an elementwise object comparison in the future.
if (shift_fft != None and (hasattr(sopare.config, 'FFT_SHIFT') and sopare.config.FFT_SHIFT == True)):
Process buffering queue:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/pi/sopare/sopare/buffering.py", line 44, in run
self.proc.check_silence(buf)
File "/home/pi/sopare/sopare/processing.py", line 83, in check_silence
self.stop("stop append mode because time is up")
File "/home/pi/sopare/sopare/processing.py", line 52, in stop
self.prepare.stop()
File "/home/pi/sopare/sopare/prepare.py", line 72, in stop
self.filter_reset()
File "/home/pi/sopare/sopare/prepare.py", line 89, in filter_reset
self.filter.reset()
File "/home/pi/sopare/sopare/filter.py", line 48, in reset
self.queue.put({ 'action': 'reset' })
File "/usr/lib/python2.7/multiprocessing/queues.py", line 100, in put
assert not self._closed
AssertionError
Do you have any ideas on how to fix this?
Hi Bishop, ./sopare -l -v works fine but when I try to ./sopare -t main it gives back the shell prompt, what can it be ?
hey
Just looked at this project and was curious as to
What technology is being used for Speech to text?
hi Martin,
I'm using 1.5.0
I tried to do sopare.py -t test but it stucks on this log message:
INFO:sopare.recorder:start endless recording
and after I've spoken nothing happens..
I need to do ctrl-c stop stop the script.. After ctrl-C the dict.json is empty so I don't have nothing to compile....
another thing... I'm trying sopare.py test/test_audio.py but it remains blocked on
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.
any suggestion?
Hi,
i set CHUNKS = 1024 and sometimes this occurs in training (mostly in the third training round of a word)...
/home/sopare/sopare/filter.py:138: RuntimeWarning: divide by zero encountered in log10
shift_nfft = numpy.log10(nfft)**2
/home/sopare/sopare/filter.py:143: RuntimeWarning: invalid value encountered in divide
shift_nfft = numpy.tanh(shift_nfft/shift_nam)
any idea?
thx
Hello,
I don't understand what the unittest is supposed to output. I ran
python sopare.py -u
and here's the output
pi@raspberrypi:~/sopare $ ./sopare.py -u
sopare 1.5.0
starting unit tests...
starting analyze tests...
analyze test preparation...
ERROR:sopare.analyze:ImportError: No module named __init__
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...
ERROR:sopare.analyze:ImportError: No module named __init__
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.
It says that the unit test ran successfully, but then again it thrw 2 errors (No module named __init__
). Is this normal and expected behaviour?
Following the instructions for initial testing found on the blog and in the README
python sopare.py -u
python test/test_audio.py
python throws an error about import sopare.log
, saying sopare.log coudn't be found. The path is modified to include "../sopare" via sys.path.append('../sopare')
which means import log
ought to work (since log is inside the sopare folder), but I found that it didn't (I'm befuddled). Using sys.path.append('../')
in combination with import sopare.log
also failed; equally befuddling.
In the interest of making as few changes as possible, I added the main directory to the system path using sys.path.append(sys.path[0] + '/..')
, thus fixing the imports sopare.log
, sopare.config
, and sopare.audio_factory
.
I'm not sure whether other people experience this problem -- I'm running ubuntu 18.04 with python 2.7 (the default, I presume). This is my first issue submission, so I hope I've done it all right.
Moin... leider wird im Forum nicht der ganze Text angezeit, deshalb hier nochmal.
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:
#########################################################
# 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
Schalten tut er zu >95% beim ersten mal, und 100% beim Wiederholen des Kommandos, nur leider 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
Hi, i noticed that there is a delay in sopare when it recognizes a trained word, for example i make it to turn on the led if a trained word recognized, the result is there is like nearly 1 second delay until the led turns on.. which parameter in default.ini should i tweak to change this behavior?
First of all, thanks for developing this.
I want to ask that have you integrated something for noise filtering/cancellation from mic stream/wav file? I tried to look into the code but couldn't find.
I'm having some problems setting up Sopare on OSX Sierra.
After some investigation, I've found out that there are some issues with the multiprocessing module on osx.
https://docs.python.org/2/library/multiprocessing.html#multiprocessing.Queue.qsize
qsize()
Return the approximate size of the queue. Because of multithreading/multiprocessing semantics, this number is not reliable.
Note that this may raise NotImplementedError on Unix platforms like Mac OS X where sem_getvalue() is not implemented.
also:
vterron/lemon#11
Since I'm completely alien to the python ecosystem, I'm not sure if there is a known workaround for this problem (I did not find any).
Can you point me in the right direction?
Thanks.
Error while running python ./test/test_audio.py
Traceback (most recent call last):
File "test/test_audio.py", line 132, in <module>
ta.stop()
File "test/test_audio.py", line 118, in stop
while (self.queue.qsize() > 0):
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 143, in qsize
return self._maxsize - self._sem._semlock._get_value()
NotImplementedError
Error while running python sopare.py -t "test"
sopare 1.5.0
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 268, in _feed
send(obj)
IOError: [Errno 32] Broken pipe
From watching your video on the magic mirror, it seemed like you compiled all your code into a folder called events in the output folder (/plugins/print/events/init.py). Is that the way to do it, or could you use an external compiler or IDE to do the same job?
i have a small USB mic that seems to register properly on boot (seems to be recognized in /var/log/messages). when i run
python test/test_audio.py
i see this below -- any suggestions?
test_audio init...
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown 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 confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
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
connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
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 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
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.
Your sopare/config.py recommendations:
SAMPLE_RATE = 48000
CHUNK = 512
THRESHOLD = 100
pi@chroma:~/dev/sopare $
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.