Environment:
I am on macOS Mojave and installed the latest version of PyGame. I am running the code to install the terminal.
You can get some of this info from the text that pops up in the console when you run a pygame program.
Operating system MacOS Mojave.
Python version 3.7.6
When I run the following code to change the output device with a device name as follows:
import pygame
import pygame._sdl2 as sdl2
pygame.init()
names = [str(sdl2.get_audio_device_name(i, 0), encoding="utf-8") for i in range(num)]
dev_name = names[0] # device number
pygame.mixer.pre_init(devicename= dev_name)
It returns the following error with the mac error message to quit python as in the screenshot below. I tried this with the string literals such as: "Sennheiser USB headset" or b'"Sennheiser USB headset" which are values returned from list "names" in above code. All of them return the same error as below.
Any help would be much appreciated.
I don't think you would require all this
import pygame._sdl2 as sdl2
pygame.init()
names = [str(sdl2.get_audio_device_name(i, 0), encoding="utf-8") for i in range(num)]
dev_name = names[0] # device number
pygame.mixer.pre_init(devicename= dev_name)
Try this
import pygame
pygame.init()
pygame.mixer.init()
For the past several weeks I have been using videowriter.write() and it has been working fine. I needed to give the program to several coworkers that have random python installations so I packaged it up in pyinstaller, which I have used successfully on other projects.
Almost everything seems to be working fine when run under pyinstaller, I can read images, capture images from the camera, show them on the screen, and write out individual images. The problem is that when I use videowriter.write() somewhere down in the bowels of the code it crashes, complaining that the images have the incorrect size. This only happens when running under pyinstaller, not when running it directly from python.
Below is a portion of the code that I extracted with a generated test image. A coworker tried to run the same example, using his copy of opencv, python, and pyinstaller and his executable seems to work. I spent the last several days trying to duplicate that setup but I don't get the same results. I have completely removed python 3 (I have a copy of 2.7 that is specifically for other tests), cleared the pip cache, cleared environment variables, and made sure all the python directories were removed prior to re-installation. I have tried python back to 3.7, different versions of opencv 4.1 through current, and all behave the same way. I have also tried using a virtual environment and setting up the core python sitting in Program Files.
The current version of opencv_videoio_ffmpeg is: opencv_videoio_ffmpeg420_64.dll.
The version that my coworker used successfully is opencv_ffmpeg410_64.dll
While it doesn't seem to make much difference, the command I have been using to build the executable is:
pyinstaller videowriter_test.py --onefile
I have also tried it without the --onefile option, it works the same but its a little harder to find the executable.
The python installation has the following installed: opencv-python, opencv-contrib-python, imutils, pynput, keyboard, virtualenv, pyinstaller. These were all installed using pip.
pyinstaller stats:
129 INFO: PyInstaller: 3.6
129 INFO: Python: 3.7.7
131 INFO: Platform: Windows-10-10.0.18362-SP0
133 INFO: wrote C:\Users\tbray\Desktop\MyProjects\Python3\Play\videowriter\videowriter_test.spec
137 INFO: UPX is not available. 139 INFO: Extending PYTHONPATH with paths
The test code:
import traceback
import cv2
import numpy as np
import imutils
# the rest are just there to make sure pyinstaller includes the same modules
# as my regular code
import copy
import platform
import pathlib
import select
import argparse
import warnings
import datetime
import json
import time
if __name__ == '__main__':
w = 640
h = 480
currentVideoLogFilename = "test.avi"
print(os.getenv('temppath'))
try:
print("Attempting to open Video Log:", currentVideoLogFilename)
video_log_file = cv2.VideoWriter(currentVideoLogFilename,
cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 30, (w, h),True)
print("Open Success")
except:
traceback.print_exc()
print("Test Image Shape:", w, h)
image = np.zeros((w, h, 3))
try:
video_log_file.write(image)
except:
traceback.print_exc()
print("Completed")
video_log_file.release()
print("file closed/released")
sys.exit(0)
If I run the using idle or pyCharm, I get this result:
================== RESTART: C:\Users\tbray\Desktop\MyProjects\Python3\Play\videowriter\videowriter_test.py ==================
None
Attempting to open Video Log: test.avi
Open Success
Test Image Shape: 640 480
Completed
file closed/released
>>>
if I run it from the virtual environment I get:
C:\Users\tbray\Desktop\MyProjects\Python3\Play\videowriter\dist>videowriter_test.exe
None
Attempting to open Video Log: test.avi
[ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (415) cv::VideoWriter::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): test.avi in function 'cv::icvExtractPattern'
Open Success
Test Image Shape: 640 480
Traceback (most recent call last):
File "videowriter_test.py", line 39, in <module>
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_mjpeg_encoder.cpp:476: error: (-215:Assertion failed) imgWidth == frameWidth && imgHeight == frameHeight && channels == 3 in function 'cv::mjpeg::MotionJpegWriter::write'
Completed
file closed/released
One interesting note is what I assume is the temp directory that is referenced in the first error message. I have no idea where the directory comes from and what happens to it, it is missing when I go looking for it.
Any suggestions?
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.
my problem starts here:
pyttsx and gTTS module errors
gTTS works well, takes text from text file, but first creates mp3 file, then if I want listen, I must call this mp3, so it is good but it would be better if I can avoid any audio files, and get just read from text file. maybe somehow I can use google voice to read from text file..? anyway main question now is other
if I can use only gTTS what is the best way to play mp3 on Windows 10-64 bit, Python 3.5
ok with os:
import os
os.startfile("D:\my path/rec1.mp3")
it is good, but I don't want use default player, need something like simpleaudio for mp3...
with pygame I have installation problem and not sure, how good is use it this way:
from pygame import mixer
mixer.init()
mixer.music.load('D:/my path/rec1.mp3')
mixer.music.play()
vlc just how to install it? with easy_install vlc I got error: could not find suitable distribution for requirement.parse ('vlc') and with pip install vlc error: could not find a version that satisfies the requirement vlc (from versions: ) no matching distribution found for vlc
import vlc
p = vlc.MediaPlayer("file:/my path/rec1.mp3")
p.play()
p.stop()
with pyglet:
import pyglet
music=pyglet.media.load('D:/my path/rec1.mp3')
music.play()
pyglet.app.run()
I got this error:
'AVbin is required to decode compressed media')
pyglet.media.riff.WAVEFormatException: AVbin is required to decode compressed media
subprocess also uses default player:
import subprocess
sound_program = "path to player"
sound_file = "D:/my path/rec1.mp3"
subprocess.call([sound_program, sound_file])
with mp3play, not sure how to use it:
import mp3play
filename = (r'D:\my path/rec1.mp3')
clip = mp3play.load(filename)
clip.play()
I tried it this way:
filename = ('D:\my path/rec1.mp3')
this way:
filename = r'D:\my path/rec1.mp3'
In all cases I got error:
Traceback (most recent call last):
File "D:/dt/PyCharm_project/0_ASK.py", line 18, in <module>
import mp3play
File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\mp3play\__init__.py", line 4, in <module>
from .windows import AudioClip as _PlatformSpecificAudioClip
File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\mp3play\windows.py", line 27
print 'Error %s for "%s": %s' % (str(err), txt, buf)
^
SyntaxError: invalid syntax
ok so with pydub:
from pydub import AudioSegment
from gtts import gTTS
import simpleaudio as sa
blabla = ('my voice')
tts = gTTS(text=blabla, lang='en')
tts.save("D:/my path/rec.mp3")
rec = AudioSegment.from_mp3("D:\my path\rec.mp3")
rec.export("rec.wav", format="wav")
#rec = AudioSegment.ffmpeg ("D:\my path\rec.mp3")
#rec.export("rec.wav", format="wav")
#rec = AudioSegment.converter ("D:\my path\rec.mp3")
#rec.export("rec.wav", format="wav")
wave_obj = sa.WaveObject.from_wave_file('D:/my path/rec.wav'')
play_obj = wave_obj.play()
play_obj.wait_done()
Errors in the sequence first with AudioSegment.from_mp3 :
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Traceback (most recent call last):
File " D:/dt/PyCharm_project/0_ASK.py", line 9, in <module>
rec = AudioSegment.from_mp3("D:\my path\rec.mp3")
File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\pydub\audio_segment.py", line 438, in from_mp3
return cls.from_file(file, 'mp3')
File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\pydub\audio_segment.py", line 366, in from_file
file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False)
File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\pydub\utils.py", line 59, in _fd_or_path_or_tempfile
fd = open(fd, mode=mode)
OSError: [Errno 22] Invalid argument: 'D:\my path\rec.mp3'
with AudioSegment.ffmpeg :
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "D:/dt/PyCharm_project/0_ASK.py ", line 12, in <module>
rec = AudioSegment.ffmpeg ("D:\my path\rec.mp3")
TypeError: 'str' object is not callable
with AudioSegment.converter:
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "D:/dt/PyCharm_project/0_ASK.py", line 15, in <module>
rec = AudioSegment.converter ("D:\my path\rec.mp3")
TypeError: 'str' object is not callable
not sure maybe webbrowser, but how to install it?
import webbrowser
webbrowser.open("D:/my path/rec1.mp3")
Same problem here. It works with playsound 1.2.1 for me.
Install with :
$ pip install playsound
test with:
>>>from playsound import playsound
>>>playsound('/path/to/a/sound/file/you/want/to/play.mp3')
You can use "subprocess".
from subprocess import call
from gtts import gTTS
import os
blabla = input('Type IN: ')
tts = gTTS(text=blabla, lang='en')
tts.save("test.mp3")
call(["vlc", "test.mp3"])
This program asks user to type in anything and it will say that trough vlc.
I use this on Linux but i don't now if it works on Windows.
with pygame I have installation problem and not sure, how good is use it this way:
Can you provide more details about the pygame installation error?
I was able to use PYGAME with this code, where "hello.mp3" is a file in the same directory
from gtts import gTTS
tts = gTTS(text='Hello', lang='en')
tts.save("hello.mp3")
from Tkinter import *
root = Tk()
from pygame import mixer
mixer.init()
mixer.music.load('hello.mp3')
mixer.music.play()
root.mainloop()
vlc just how to install it?
I also used VLC. I have installed it with these commands:
sudo pip install python-vlc
And I got this error:
NameError: no function 'libvlc_new
So, I tryed the command:
sudo apt-get install vlc
And it worked with this code:
from gtts import gTTS
tts = gTTS(text='Hello', lang='en')
tts.save("hello.mp3")
from Tkinter import *
root = Tk()
import vlc
p = vlc.MediaPlayer("hello.mp3")
p.play()
root.mainloop()
Hope It help You.
This will do the job and without the need for files:
def say(text, lang='en'):
""" Speak the provided text.
"""
import pygame
from gtts import gTTS
import io
tts = gTTS(text=text, lang=lang, slow=False)
pygame.mixer.init()
pygame.init() # this is needed for pygame.event.* and needs to be called after mixer.init() otherwise no sound is played
with io.BytesIO() as f: # use a memory stream
tts.write_to_fp(f)
f.seek(0)
pygame.mixer.music.load(f)
pygame.mixer.music.set_endevent(pygame.USEREVENT)
pygame.event.set_allowed(pygame.USEREVENT)
pygame.mixer.music.play()
pygame.event.wait() # play() is asynchronous. This wait forces the speaking to be finished before closing f and returning
I think you are looking for :
pyttsx3
Its an offline cross-platform TTS that's compatible with python3 and python2.
Install :
pip install pyttsx3
If u want an offline TTS for python unlike gTTS , pyttsx3 is your best choice in my opinion.
I don't know the solution to all of the questions, but the issue you're having with pydub is that you don't have ffmpeg or avconv installed. There are instructions on the pydub github:
Windows:
Download and extract libav from Windows binaries provided here.
Add the libav /bin folder to your PATH envvar
pip install pydub
webbrowser should be part of you standard python install.
Check if there is a webbrowser.py under C:\Your_Python_Folder\Lib.
Below code works just fine for me as webbrowser.py is present at above mentioned folder.
import webbrowser
webbrowser.open("rec.mp3")
install pyglet using python -m pip install pyglet
Download installed here Link to AVbin setup ( it's a must )
32/64 bit
import pyglet
song = pyglet.media.load('file.mp3')
song.play()
pyglet.app.run()
That's all.
You can use playsound module
from playsound import playsound
playsound(file.mp3)
Boom that's it.it plays the audio right way works like charm
If you are on windows then this should do the job,
import winsound
winsound.PlaySound('your_file.mp3',winsound.SND_FILENAME)
Remember this package is only present in python for windows.
If AVbin error occurs...
First download AVbin.exe and Install it
then Go to local disk C --> windows --> System32 --> search the Avbin.dll and copy that file
then paste that particular file in your root directory
Error will vanish
import os
os.system("music.mp3")
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