Open kensuke opened 3 years ago
$ arecord --device=hw:1,0 --format S16_LE -c 2 -r 48000 -d 10 /home/pi/Videos/test.wav
Recording WAVE '/home/pi/Videos/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
arecord: set_params:1345: Channels count non available
I don't know correct fix, so let's try duty fix.
$ arecord --device=hw:1,0 --format S16_LE -c 1 -r 48000 -d 10 /home/pi/Videos/test.wav
Voice recognition to speech AND Weather voice recognition Install component.
$ sudo apt-get install flac
for this error.
Please speak:
Traceback (most recent call last):
File "voice_recognition_to_speech.py", line 52, in <module>
said_text = r.recognize_google(audio)
File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 828, in recognize_google
convert_width=2 # audio samples must be 16-bit
File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 445, in get_flac_data
flac_converter = get_flac_converter()
File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 1196, in get_flac_converter
raise OSError("FLAC conversion utility not available - consider installing the FLAC command line application by running `apt-get install flac` or your operating system's equivalent")
OSError: FLAC conversion utility not available - consider installing the FLAC command line application by running `apt-get install flac` or your operating system's equivalent
comment out
#except KeyboardInterrupt:
# lcd_screen.clear()
# lcd_screen.turn_off()
# GPIO.cleanup()
buzzer_pin replaced to ir_pin
ir_pin = 19
GPIO.setmode(GPIO.BCM)
#GPIO.setup(buzzer_pin, GPIO.IN)
GPIO.setup(ir_pin, GPIO.IN)
Fullwidth Quotation to Halfwidth
#lcd_screen.write_lcd(“Detected:\nblack”)
lcd_screen.write_lcd("Detected:\nblack")
#lcd_screen.write_lcd(“Detected:\nno black”)
lcd_screen.write_lcd("Detected:\nno black")
add definition
LED_BRIGHTNESS = 10
change parameter
#strip.setPixelColor(val,0,0)
strip.setPixelColor(i, Color(val, 0, 0))
$ sudo pip3 install adafruit-tcs34725
typo adta to data
# r = abnormal_adta_processing(r)
# g = abnormal_adta_processing(g)
# b = abnormal_adta_processing(b)
r = abnormal_data_processing(r)
g = abnormal_data_processing(g)
b = abnormal_data_processing(b)
Fullwidth Quotation to Halfwidth, fix format
# print(‘Color: red={0} green={1} blue={2}’,format(r,g,b))
print("Color: red={0} green={1} blue={2}".format(r,g,b))
fix indent
#def getBPMLoop(self):
def getBPMLoop(self):
I didn't found correct solution for No.1 This is Googling result memo but too long.
(or my misunderstanding. I don't know Linux hardware recognition, sound device, ALSA etcetc..)
$ arecord --device=hw:1,0 --format S16_LE -c 2 -r 48000 -d 10 /home/pi/Videos/test.wav
Recording WAVE '/home/pi/Videos/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
arecord: set_params:1345: Channels count non available
$ arecord --device=hw:1,0 --format S16_LE -c 1 -r 48000 -d 10 /home/pi/Videos/test.wav
Recording WAVE '/home/pi/Videos/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
$ file Videos/test.wav
Videos/test.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 48000 Hz
$ aplay Videos/test.wav
Playing WAVE 'Videos/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
$ sox -d -b 16 -e signed-integer -c 2 -r 48000 /home/pi/Videos/soxtest.wav trim 0 10
sox WARN alsa: can't encode 0-bit Unknown or not applicable
Input File : 'default' (alsa)
Channels : 2
Sample Rate : 48000
Precision : 16-bit
Sample Encoding: 16-bit Signed Integer PCM
In:0.00% 00:00:10.07 [00:00:00.00] Out:480k [ | ] Clip:0
Done.
$ file Videos/soxtest.wav
Videos/soxtest.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 48000 Hz
$ aplay Videos/soxtest.wav
Playing WAVE 'Videos/soxtest.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
https://superuser.com/questions/889912/how-to-record-10-seconds-of-audio-with-sox
$ ls -al Videos/*.wav
-rw-r--r-- 1 pi pi 1920044 Jan 29 16:03 Videos/soxtest.wav
-rw-r--r-- 1 pi pi 960044 Jan 29 16:03 Videos/test.wav
...
Bus 001 Device 007: ID 058f:3841 Alcor Micro Corp.
...
https://linux-hardware.org/index.php?id=usb:058f-3841
...
[ 172.783139] usb 1-1.3: new high-speed USB device number 7 using xhci_hcd
[ 172.940459] usb 1-1.3: New USB device found, idVendor=058f, idProduct=3841, bcdDevice= 0.01
[ 172.940473] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 172.940483] usb 1-1.3: Product: USB 2.0 PC Camera
[ 172.940493] usb 1-1.3: Manufacturer: Alcor Micro, Corp.
[ 172.944187] uvcvideo: Found UVC 1.00 device USB 2.0 PC Camera (058f:3841)
[ 172.960330] uvcvideo 1-1.3:1.0: Entity type for entity Processing 2 was not initialized!
[ 172.960345] uvcvideo 1-1.3:1.0: Entity type for entity Extension 6 was not initialized!
[ 172.960356] uvcvideo 1-1.3:1.0: Entity type for entity Camera 1 was not initialized!
[ 172.960635] input: USB 2.0 PC Camera: PC Camera as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/input/input7
...
**** List of CAPTURE Hardware Devices ****
card 1: Camera [USB 2.0 PC Camera], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
TOO LOOONG results
Recording WAVE '/home/pi/Videos/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
HW Params of device "hw:1,0":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: [8000 48000]
PERIOD_TIME: [1000 32768000]
PERIOD_SIZE: [32 262144]
PERIOD_BYTES: [64 524288]
PERIODS: [2 1024]
BUFFER_TIME: (1333 65536000]
BUFFER_SIZE: [64 524288]
BUFFER_BYTES: [128 1048576]
TICK_TIME: ALL
--------------------
arecord: set_params:1345: Channels count non available
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "output"
}
capture.pcm {
type plug
slave.pcm "input"
}
}
pcm.output {
type hw
card 0
}
pcm.input {
type hw
card 1
}
ctl.!default {
type hw
card 0
}
https://stackoverflow.com/questions/39552522/raspberry-pi-aplay-default-sound-card https://developers.google.com/assistant/sdk/guides/service/python/embed/audio
https://github.com/alsa-project/alsa-utils/blob/master/aplay/aplay.c#L1372 https://github.com/alsa-project/alsa-lib/blob/master/src/pcm/pcm.c#L4525
I found 6 error on Python Lesson.