pyaudio

Prevent ALSA underruns with PyAudio

孤街浪徒 提交于 2019-12-12 09:54:33
问题 I wrote a little program which records voice from the microphone and sends it over network and plays it there. I'm using PyAudio for this task. It works almost fine but on both computers i get errors from ALSA that an underrun occurred. I googled a lot about it and now I know what an underrun even is. But I still don't know how to fix the problem. Most of the time the sound is just fine. But it sounds a little bit strange if underruns occur. Is there anything I should take care of in my code?

Audio Recording in Python

走远了吗. 提交于 2019-12-12 07:32:51
问题 I want to record short audio clips from a USB microphone in Python. I have tried pyaudio, which seemed to fail communicating with ALSA, and alsaaudio, the code example of which produces an unreadable files. So my question: What is the easiest way to record clips from a USB mic in Python? 回答1: This script records to test.wav while printing the current amplitute: import alsaaudio, wave, numpy inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE) inp.setchannels(1) inp.setrate(44100) inp.setformat

Play mp3 file not using default output (playback) device in Python

江枫思渺然 提交于 2019-12-12 05:11:56
问题 I know that on PyAudio it is possible to choose on what playback device to stream on but PyAudio doesnt support mp3 files. My script would work if one of the following problem was solved: Play mp3 file on PyAudio Convert from mp3 to wav without without any data loss and without PyDub (with this method of converting, I found out that in a longer audio, the ends are missing) Somehow play sound from a mp3 file to different playback device (the device is not a default one) Personally I want to

Could not find pyaudio check installation in mac

旧街凉风 提交于 2019-12-12 04:39:12
问题 I have installed portaudio using brew and installed speechRecognition, pyaudio using pip3 in my macos. I am getting error while running following code CODE: #!/usr/bin/env python # Python 3 import os import sys import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source: print ("say something!"); audio = r.listen(source) try: print("google thinks you said" +r.recognize_google(audio)) except: pass ERROR: Traceback (most recent call last): File "test.py", line 8, in

PyAudio Wheel is Unsupported?

强颜欢笑 提交于 2019-12-11 19:35:52
问题 PyAudio. It's been a well-known problem for a while now that when installing PyAudio, you can't do pip install PyAudio , because it will tell you that it couldn't find portaudio.h . So, as you go on your journey to be taught by some Indian guy on YouTube, you realize that all the videos say the same thing: you have to manually install the wheel (https://pypi.org/project/PyAudio/#files), by downloading it, then doing pip install <path-to-wheel> . However, as of September 2019, this method no

PyAudio - How mix wave file into a continuous stream

穿精又带淫゛_ 提交于 2019-12-11 14:22:26
问题 I want to write a very basic application that passes audio from microphone to speakers. This is very simple with pyaudio as described on https://people.csail.mit.edu/hubert/pyaudio/ . def passthrough(): WIDTH = 2 CHANNELS = 1 RATE = 44100 p = pyaudio.PyAudio() def callback(in_data, frame_count, time_info, status): return (in_data, pyaudio.paContinue) stream = p.open(format=p.get_format_from_width(WIDTH), channels=CHANNELS, rate=RATE, input=True, output=True, stream_callback=callback) stream

Python PyAudio installation on windows problems in importing PortAudio V19

▼魔方 西西 提交于 2019-12-11 13:40:04
问题 I'm trying to install PyAudio for an application to record audio clips from microphone input. I installed PyAudio from executable file (Windows 7, python 2.6). However when I try to import this library in my code, I get the following error. Please build and install the PortAudio Python bindings first. I tried the solution provided at Python PyAudio installation problems (with PortAudio) but I got the following error message when I installed it using the executable given at http://www.lfd.uci

pyaudio associate a sample with system clock?

送分小仙女□ 提交于 2019-12-11 13:07:28
问题 I have an application where I have some other signal referenced to the system clock ( time.time() ) and I would like to record the audio input and figure out when it happened relative to the other signal. At first I tried using the callback API, thinking that they would occur right when the data was available from the sound card. You would expect the callbacks to occur regularly with a difference of roughly the sample period * number of samples, but as other have noted, this isn't the case. I

install Pyaudio - whl

痞子三分冷 提交于 2019-12-11 10:56:08
问题 I tried to install PyAudio on Windows 7 64bit. Installing it with pip throws dependency errors which end up in the question how to satisfy those. So i tried to install it with wheel, the suggestion was to just use pip install: D:\Programming\Kivy>dir ... 27.03.2015 08:11 113.556 PyAudio.whl D:\Programming\Kivy>pip install PyAudio.whl Downloading/unpacking PyAudio.whl Could not find any downloads that satisfy the requirement PyAudio.whl No distributions at all found for PyAudio.whl Storing

How to separate frequency of audiofile

孤街浪徒 提交于 2019-12-11 10:15:16
问题 I simply want to determine frequencies of a .mp3 or .wav file and print it import pyaudio import wave import numpy as np chunk = 2048 wf = wave.open('/home/pi/Adhuri.wav', 'rb') swidth = wf.getsampwidth() RATE = wf.getframerate() window = np.blackman(chunk) p = pyaudio.PyAudio() stream = p.open(format = p.get_format_from_width(wf.getsampwidth()), channels = wf.getnchannels(), rate = RATE, output = True) # read some data data = wf.readframes(chunk) # play stream and find the frequency of each