Pyaudio sound quality issues - audio
I have a know good wave file of a voice that does not play back well when using the example Python programs supplied with the PYAUDIO install. It does play back well with -aplay
Using play_wave.py the sound quality is good with the exception of a loud repetitive noise(~ 6 hz) in the background
Using play_wave_callback.py the pitch of the record voice increased significantly and the background noise is more of a buzz now (40-70 hz)
The sound quality is good when using
**aplay** -vv -D plughw:1,0 -f s16_le output.wav
It is interesting that the two sample programs yield vastly different quality while the -aplay sound quality is good. It could be the same issue. The frequency of the background noised increase by approximately 10X and the pitch of the voice increased significantly.
Any suggestions?
Some more details:
I am running these sample programs on Raspberry Pi 2 with Raspbian Jessie build that I down load March 2016. The sound is played back through a USB sound card. I removed the onboard sound card by removing one line in /boot/config.txt
#dtparam=audio=on
aplay -l yields
pi#raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
pi#raspberrypi:~ $
Using aplay the sound quality is good, here is the output
pi#raspberrypi:~/programs $ aplay -vv -D plughw:1,0 -f s16_le output.wav
Playing WAVE 'output.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
Plug PCM: Route conversion PCM (sformat=S16_LE)
Transformation table:
0 <- 0
1 <- 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 22050
period_size : 5513
period_time : 125011
tstamp_mode : NONE
period_step : 1
avail_min : 5513
period_event : 0
start_threshold : 22050
stop_threshold : 22050
silence_threshold: 0
silence_size : 0
boundary : 1445068800
Slave: Hardware PCM card 1 'C-Media USB Headphone Set' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 22050
period_size : 5513
period_time : 125011
tstamp_mode : NONE
period_step : 1
avail_min : 5513
period_event : 0
start_threshold : 22050
stop_threshold : 22050
silence_threshold: 0
silence_size : 0
boundary : 1445068800
appl_ptr : 0
hw_ptr : 0
# + | 04%
pi#raspberrypi:~/programs $
Using play_wave.py the sound quality is good with the exception of a loud repetitive noise(~5-10 hz) in the background. heres the complete code :
"""PyAudio Example: Play a wave file."""
import pyaudio
import wave
import sys
CHUNK = 1024 * 8
#if len(sys.argv) < 2:
# print("Plays a wave file.\n\nUsage: %s filename.wav" % sys.argv[0])
# sys.exit(-1)
wf = wave.open('output.wav', 'rb')
# instantiate PyAudio (1)
p = pyaudio.PyAudio()
# open stream (2)
#stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
# channels=wf.getnchannels(),
# rate=wf.getframerate(),
# output=True)
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(),
rate=wf.getframerate(),
output=True)
# read data
data = wf.readframes(CHUNK)
# play stream (3)
while data != '':
stream.write(data)
data = wf.readframes(CHUNK)
# stop stream (4)
stream.stop_stream()
stream.close()
# close PyAudio (5)
p.terminate()
The output from this program is
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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 sysdefault
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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 sysdefault
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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 confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
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 dmix
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
------------------
(program exited with code: 0)
Press return to continue
I don't know what's the problem with PyAudio, but if you want to try something different, have a look at this example: http://python-sounddevice.readthedocs.org/en/latest/examples.html#play-a-sound-file.
This is a quick extract from the example:
import sounddevice as sd
import soundfile as sf
data, fs = sf.read('myfile.wav')
sd.play(data, fs)
This example needs NumPy.
If you don't want to install that, it'll get a bit more complicated (similar to your PyAudio code), but it still works.
You can install the necessary libraries with
python3 -m pip install soundfile sounddevice
Related
Use of ffprobe in kivy 'File not Found'
i am trying to convert audio from webm to mp3 using pudub module in android using kivy. I've included pydub,ffprobe-python,ffmpeg-python in buildozer.spec file but when i run the app i get the following error ! FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'
You will need to embed ffmpeg suite binaries. ffprobe-python and ffmpeg-python are only connectors to call the binaries.
How to run pygame gui in docker container on remote server?
I want to develop a pygame environment on a remote server. How can I run pygame gui on remote-container connected using vscode? Please provide a simple example code. thank you. pygame simple code import pygame import pygame_gui pygame.init() pygame.display.set_caption("Quick Start") window_surface = pygame.display.set_mode((800, 600)) background = pygame.Surface((800, 600)) background.fill(pygame.Color("#000000")) manager = pygame_gui.UIManager((800, 600)) is_running = True while is_running: for event in pygame.event.get(): if event.type == pygame.QUIT: is_running = False window_surface.blit(background, (0, 0)) pygame.display.update() error log pygame 2.1.2 (SDL 2.0.16, Python 3.8.6) Hello from the pygame community. https://www.pygame.org/contribute.html 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 default Traceback (most recent call last): File "/home/jovyan/local/1_user/srlee#agilesoda.ai/TIL/pygame/gui_test.py", line 8, in <module> window_surface = pygame.display.set_mode((800, 600)) pygame.error: No available video device
Issue installing pdftotext in Python 3.6 on CentOS due to poppler
I'm having some issues getting installing pdftotext in Python 3.6 (Anaconda 5.1.0) on CentOS. Some quick notes first: I'm using CentOS 6.7 on VirtualBox I know it can work because my IT group has it installed on our server. NOTE: I found that our server did have the C++ wrapper installed and I'm trying to figure out how the got it. I'm trying to get an existing application to work, so I'm not looking for an alternative to pdftotext the library at this time. I followed the instructions from the github repo and already tried this step: Fedora, Red Hat, and friends: sudo yum install gcc-c++ pkgconfig poppler-cpp-devel python-devel redhat-rpm-config But the problem seems to be around poppler-cpp-devel. I don't see that package within yum search poppler: ============================= N/S Matched: poppler ============================= poppler-devel.i686 : Libraries and headers for poppler poppler-devel.x86_64 : Libraries and headers for poppler poppler-glib.i686 : Glib wrapper for poppler poppler-glib.x86_64 : Glib wrapper for poppler poppler-qt.i686 : Qt3 wrapper for poppler poppler-qt.x86_64 : Qt3 wrapper for poppler poppler-qt4.i686 : Qt4 wrapper for poppler poppler-qt4.x86_64 : Qt4 wrapper for poppler poppler.i686 : PDF rendering library poppler.x86_64 : PDF rendering library poppler-data.noarch : Encoding files poppler-glib-devel.i686 : Development files for glib wrapper poppler-glib-devel.x86_64 : Development files for glib wrapper poppler-qt-devel.i686 : Development files for Qt3 wrapper poppler-qt-devel.x86_64 : Development files for Qt3 wrapper poppler-qt4-devel.i686 : Development files for Qt4 wrapper poppler-qt4-devel.x86_64 : Development files for Qt4 wrapper poppler-utils.x86_64 : Command line utilities for converting PDF files My IT group gave me the instructions of what they had attempted and I tried installing poppler-devel and poppler-glib. But every time I try pip install pdftotext I'm getting the following output: [root#localhost stack]# pip install pdftotext Collecting pdftotext Using cached https://files.pythonhosted.org/packages/21/35/60094dbadd9de2035873390b1cac25e01da605844eba6a07a53a82fa4adc/pdftotext-2.1.1.tar.gz Building wheels for collected packages: pdftotext Building wheel for pdftotext (setup.py) ... error Complete output from command /root/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1mu2f1n2/pdftotext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-khm9zova --python-tag cp36: /root/anaconda3/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running bdist_wheel running build running build_ext building 'pdftotext' extension creating build creating build/temp.linux-x86_64-3.6 gcc -pthread -B /root/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -I/root/anaconda3/include/python3.6m -c pdftotext.cpp -o build/temp.linux-x86_64-3.6/pdftotext.o -Wall cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ pdftotext.cpp:3:42: error: poppler/cpp/poppler-document.h: No such file or directory pdftotext.cpp:4:40: error: poppler/cpp/poppler-global.h: No such file or directory pdftotext.cpp:5:38: error: poppler/cpp/poppler-page.h: No such file or directory pdftotext.cpp:20: error: ‘poppler’ has not been declared pdftotext.cpp:20: error: ISO C++ forbids declaration of ‘document’ with no type pdftotext.cpp:20: error: expected ‘;’ before ‘*’ token pdftotext.cpp: In function ‘void PDF_clear(PDF*)’: pdftotext.cpp:26: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp:27: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘int PDF_create_doc(PDF*)’: pdftotext.cpp:66: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp:66: error: ‘poppler’ has not been declared pdftotext.cpp:67: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘int PDF_unlock(PDF*, char*)’: pdftotext.cpp:75: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘int PDF_init(PDF*, PyObject*, PyObject*)’: pdftotext.cpp:105: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘PyObject* PDF_read_page(PDF*, int)’: pdftotext.cpp:119: error: ‘poppler’ has not been declared pdftotext.cpp:119: error: expected initializer before ‘*’ token pdftotext.cpp:120: error: ‘poppler’ has not been declared pdftotext.cpp:120: error: expected ‘;’ before ‘layout_mode’ pdftotext.cpp:123: error: ‘page’ was not declared in this scope pdftotext.cpp:123: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp:129: error: ‘poppler’ has not been declared pdftotext.cpp:129: error: expected initializer before ‘rect’ pdftotext.cpp:130: error: ‘rect’ was not declared in this scope pdftotext.cpp:133: error: ‘layout_mode’ was not declared in this scope pdftotext.cpp:133: error: ‘poppler’ has not been declared pdftotext.cpp:135: error: ‘poppler’ has not been declared pdftotext.cpp:137: error: ‘poppler’ has not been declared pdftotext.cpp:138: error: type ‘<type error>’ argument given to ‘delete’, expected pointer error: command 'gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for pdftotext Running setup.py clean for pdftotext Failed to build pdftotext Installing collected packages: pdftotext Running setup.py install for pdftotext ... error Complete output from command /root/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1mu2f1n2/pdftotext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ghuhvuhl/install-record.txt --single-version-externally-managed --compile: /root/anaconda3/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running install running build running build_ext building 'pdftotext' extension creating build creating build/temp.linux-x86_64-3.6 gcc -pthread -B /root/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -I/root/anaconda3/include/python3.6m -c pdftotext.cpp -o build/temp.linux-x86_64-3.6/pdftotext.o -Wall cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ pdftotext.cpp:3:42: error: poppler/cpp/poppler-document.h: No such file or directory pdftotext.cpp:4:40: error: poppler/cpp/poppler-global.h: No such file or directory pdftotext.cpp:5:38: error: poppler/cpp/poppler-page.h: No such file or directory pdftotext.cpp:20: error: ‘poppler’ has not been declared pdftotext.cpp:20: error: ISO C++ forbids declaration of ‘document’ with no type pdftotext.cpp:20: error: expected ‘;’ before ‘*’ token pdftotext.cpp: In function ‘void PDF_clear(PDF*)’: pdftotext.cpp:26: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp:27: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘int PDF_create_doc(PDF*)’: pdftotext.cpp:66: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp:66: error: ‘poppler’ has not been declared pdftotext.cpp:67: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘int PDF_unlock(PDF*, char*)’: pdftotext.cpp:75: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘int PDF_init(PDF*, PyObject*, PyObject*)’: pdftotext.cpp:105: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp: In function ‘PyObject* PDF_read_page(PDF*, int)’: pdftotext.cpp:119: error: ‘poppler’ has not been declared pdftotext.cpp:119: error: expected initializer before ‘*’ token pdftotext.cpp:120: error: ‘poppler’ has not been declared pdftotext.cpp:120: error: expected ‘;’ before ‘layout_mode’ pdftotext.cpp:123: error: ‘page’ was not declared in this scope pdftotext.cpp:123: error: ‘struct PDF’ has no member named ‘doc’ pdftotext.cpp:129: error: ‘poppler’ has not been declared pdftotext.cpp:129: error: expected initializer before ‘rect’ pdftotext.cpp:130: error: ‘rect’ was not declared in this scope pdftotext.cpp:133: error: ‘layout_mode’ was not declared in this scope pdftotext.cpp:133: error: ‘poppler’ has not been declared pdftotext.cpp:135: error: ‘poppler’ has not been declared pdftotext.cpp:137: error: ‘poppler’ has not been declared pdftotext.cpp:138: error: type ‘<type error>’ argument given to ‘delete’, expected pointer error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/root/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1mu2f1n2/pdftotext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ghuhvuhl/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-1mu2f1n2/pdftotext/ I'm assuming the problem here is that it's looking for the C++ compiled files and I could only get the glib? What I can look into?
pdftotext should be in poppler-utils, so try yum install poppler-utils EDIT: Hmm. There's a package called pypoppler available for CentOS 6 in the EPEL repository, which describes itself as "Python bindings for the Poppler PDF rendering library." I see no indication that it includes poppler/cpp/{anything}, but you can give it a try. (You may need to install pycairo first.) Failing that, you might try installing an earlier version of pdftotext (e.g. pip install pdftotext==1.0.0) to find one compatible with CentOS 6. The earliest version came out in June of 2017, though, so that may not help. I don't suppose you're interested in upgrading to CentOS 7?
There actually is a proper CentOS 7 package. It is not enough to install the poppler-devel package as it does not include the CPP header files that is required and you simply need to install the poppler-cpp and poppler-cpp-devel packages: yum install poppler-cpp poppler-cpp-devel After this you can pip/pip3 install the pdftotext package without custom compiling and setting environment path variables.
I found the solution to this. By following the instructions for installing libpoppler-cpp from this link, I was able to successfully install the pdftotext. Following the instructions from this repo: On CentOS On CentOS the libpoppler-cpp library is not included with the system so we need to build from source. Note that recent versions of poppler require C++11 which is not available on CentOS, so we build a slightly older version of libpoppler. # Build dependencies yum install wget xz libjpeg-devel openjpeg2-devel # Download and extract wget https://poppler.freedesktop.org/poppler-0.47.0.tar.xz tar -Jxvf poppler-0.47.0.tar.xz cd poppler-0.47.0 # Build and install ./configure make sudo make install By default libraries get installed in /usr/local/lib and /usr/local/include. On CentOS this is not a default search path so we need to set PKG_CONFIG_PATH and LD_LIBRARY_PATH to point R to the right directory: export LD_LIBRARY_PATH="/usr/local/lib" export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
PyAudio prints ALSA warnings and does not work
I am trying to run a basic python speech to text code. This is the code. import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source: audio = r.listen(source) try: print("You said " + r.recognize(audio)) except LookupError: print("Could not understand audio") The code works fine until it reaches the print stage, then it throws this error. Is there anything that I have done wrong? ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
if someone is still looking for getting rid of ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map I just commented out all pcm.surround* lines in "PCM interface" section in /usr/share/alsa/alsa.conf file and it works fine for me.
It seems that you have multiple audio input sources, and the first one is not supported by the speech-recognition library. There is another possibility that you have no audio inputs at all. Try different indexes (e.g. 0, 1, 2, etc) with sr.Microphone(...) as per example below: with sr.Microphone(device_index=0) as source: But first, it's a good idea to run cat /proc/asound/card to see what audio devices you've got.
ERROR: modinfo: could not find module
I am installing new kernel 3.12.x on redhat 6 machine. Below is my steps which I followed to install the new kernel. extract kernel in /usr/src/ directory Switch to cd /usr/src/linux-3.12.x make menuconfig saved defaults to config file make make modules_install make install In this process I am getting the following error: ERROR: modinfo: could not find module fuse ERROR: modinfo: could not find module autofs4 ERROR: modinfo: could not find module target_core_iblock ERROR: modinfo: could not find module target_core_file ERROR: modinfo: could not find module target_core_pscsi ERROR: modinfo: could not find module target_core_mod ERROR: modinfo: could not find module configfs ERROR: modinfo: could not find module 8021q ERROR: modinfo: could not find module bnx2fc ERROR: modinfo: could not find module fcoe ERROR: modinfo: could not find module libfcoe ERROR: modinfo: could not find module libfc ERROR: modinfo: could not find module scsi_transport_fc ERROR: modinfo: could not find module scsi_tgt ERROR: modinfo: could not find module garp ERROR: modinfo: could not find module stp ERROR: modinfo: could not find module llc ERROR: modinfo: could not find module sunrpc ERROR: modinfo: could not find module be2iscsi ERROR: modinfo: could not find module iscsi_boot_sysfs ERROR: modinfo: could not find module bnx2i ERROR: modinfo: could not find module cnic ERROR: modinfo: could not find module uio ERROR: modinfo: could not find module ib_iser ERROR: modinfo: could not find module rdma_cm ERROR: modinfo: could not find module ib_cm ERROR: modinfo: could not find module iw_cm ERROR: modinfo: could not find module ib_sa ERROR: modinfo: could not find module ib_mad ERROR: modinfo: could not find module ib_core ERROR: modinfo: could not find module ib_addr ERROR: modinfo: could not find module iscsi_tcp ERROR: modinfo: could not find module libiscsi_tcp ERROR: modinfo: could not find module libiscsi ERROR: modinfo: could not find module scsi_transport_iscsi ERROR: modinfo: could not find module cachefiles ERROR: modinfo: could not find module fscache ERROR: modinfo: could not find module ipv6 ERROR: modinfo: could not find module dm_mirror ERROR: modinfo: could not find module dm_region_hash ERROR: modinfo: could not find module dm_log ERROR: modinfo: could not find module uinput ERROR: modinfo: could not find module iTCO_wdt ERROR: modinfo: could not find module iTCO_vendor_support ERROR: modinfo: could not find module sg ERROR: modinfo: could not find module coretemp ERROR: modinfo: could not find module kvm_intel ERROR: modinfo: could not find module kvm ERROR: modinfo: could not find module microcode ERROR: modinfo: could not find module serio_raw ERROR: modinfo: could not find module pcspkr ERROR: modinfo: could not find module i2c_i801 ERROR: modinfo: could not find module i2c_core ERROR: modinfo: could not find module lpc_ich ERROR: modinfo: could not find module mfd_core ERROR: modinfo: could not find module shpchp ERROR: modinfo: could not find module dm_mod ERROR: modinfo: could not find module e1000e ERROR: modinfo: could not find module i5400_edac ERROR: modinfo: could not find module edac_core ERROR: modinfo: could not find module i5k_amb ERROR: modinfo: could not find module ioatdma ERROR: modinfo: could not find module dca ERROR: modinfo: could not find module floppy ERROR: modinfo: could not find module ext4 ERROR: modinfo: could not find module mbcache Can you guys please help me to resolve this issue?
Create a link like this : ln -s /usr/src/linux-3.12.x /usr/src/linux and then proceed with the steps Check this link : https://unix.stackexchange.com/questions/147478/error-installinig-kernel-on-centos-from-source 2. Also if 1 doesnt work before your Step 3 copy the .config_XX file from the /boot directory of redhat6 to /usr/src/linux-3.12.x/.config. Then give your step 3 as make oldconfig. Say no to the new features added in the new kernel. Then proceed with step 5.