pyaudio

Generating a sine wave sound in python

点点圈 提交于 2020-05-13 14:18:28
问题 I've been trying to generate a sine wave using the following code and playing it thought my speakers, but it sounds horrible. Anyone knows why? It does not sound like a sine wave. dur = int(FS * float(duration) / 1000) for i in range(dur): a = frequency * i * 2 * math.pi / FS y = math.sin(a) outbuf[i] = y * 0.2 p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paFloat32, channels=1, rate=44100, output=True) stream.write(outbuf) stream.stop_stream() stream.close() p.terminate() play_sound(

Generating a sine wave sound in python

你说的曾经没有我的故事 提交于 2020-05-13 14:13:41
问题 I've been trying to generate a sine wave using the following code and playing it thought my speakers, but it sounds horrible. Anyone knows why? It does not sound like a sine wave. dur = int(FS * float(duration) / 1000) for i in range(dur): a = frequency * i * 2 * math.pi / FS y = math.sin(a) outbuf[i] = y * 0.2 p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paFloat32, channels=1, rate=44100, output=True) stream.write(outbuf) stream.stop_stream() stream.close() p.terminate() play_sound(

Maintain a streaming microphone input in Python

别来无恙 提交于 2020-05-11 03:16:06
问题 I'm streaming microphone input from my laptop computer using Python. I'm currently using PyAudio and .wav to create a 2 second batches (code below) and then read out the frame representations of the newly created .wav file in a loop. However I really just want the np.ndarray represented by "signal" in the code that is the Int16 representation of the .wav file. Is there a way to bypass writing to .wav entirely and make my application appear to be "real-time" instead of micro-batch? import

ros下基于百度语音的,语音识别和语音合成

╄→尐↘猪︶ㄣ 提交于 2020-04-28 11:12:05
代码地址如下:<br> http://www.demodashi.com/demo/13153.html #概述: 本demo是ros下基于百度语音的,语音识别和语音合成,能够实现文字转语音,语音转文字的功能。 #详细: ##1. 安装库与环境 首先确保已经安装了以下两个库文件。 ###1.1 Python 音频处理库 PyAudio python -m pip install pyaudio ###1.2 Python 音频处理库 vlc pip install python-vlc ###1.3 ROS 确保安装了ROS http://wiki.ros.org/indigo 2. 实时语音识别与语音合成 2.1 运行 Speech Recognition(语音识别): roslaunch simple_voice simple_voice.launch Text To Speech(语音合成): roslaunch simple_voice simple_speaker.launch 2.2 概述 在运行前先确保安装了python的pyaudio 以及 vlc 库文件. 百度语音识别为开发者提供业界优质且免费的语音服务,通过场景识别优化,,准确率达到90%以上,让您的应用绘“声”绘色。 本文中的 语音识别 功能:采用百度语音识别库,实现 语音转化为文字 的功能

Getting “error: Microsoft Visual C++ 14.0 is required.” when installing PyAudio

我的未来我决定 提交于 2020-03-25 17:57:50
问题 C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\gabri\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe' -u -c 'import sys,

Getting “error: Microsoft Visual C++ 14.0 is required.” when installing PyAudio

非 Y 不嫁゛ 提交于 2020-03-25 17:57:25
问题 C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\gabri\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe' -u -c 'import sys,

Tkinter start/stop button for recording audio in Python

风流意气都作罢 提交于 2020-03-23 15:40:21
问题 I am writing a program to record audio with the use of a Tkinter GUI. For recording audio itself, I use this code: https://gist.github.com/sloria/5693955 in nonblocking mode. Now I want to implement something like a start/stop button, but feel like I am missing out on something. Following suppositions: I can't use a while True statement either a time.sleep() function because it's going to break the Tkinter mainloop() As a result, I will probably have to use a global bool to check whether my

by installing PyAudio (Python3) on my Raspberry pi 3 (noobs) I get an error, how could i fix this?

我们两清 提交于 2020-03-23 02:24:14
问题 pip install pyaudio Downloading/unpacking pyaudio Downloading PyAudio-0.2.11.tar.gz Running setup.py (path:/tmp/pip-build-u0HEK5/pyaudio/setup.py) egg_info for package pyaudio Installing collected packages: pyaudio Running setup.py install for pyaudio building '_portaudio' extension arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2

How to select a specific input device with PyAudio

流过昼夜 提交于 2020-03-14 06:59:41
问题 When recording audio via PyAudio, how do you specify the exact input device to use? My computer has two microphones, one built-in and one via USB, and I want to record using the USB mic. The Stream class has an input_device_index for selecting the device, but it's unclear how this index correlates to the devices. For example, how do I know which device index 0 refers to? If I had to guess, I'd say 0 refers to the built-in device while 1 refers to the USB device, but I'd like to find some

How to select a specific input device with PyAudio

自闭症网瘾萝莉.ら 提交于 2020-03-14 06:57:08
问题 When recording audio via PyAudio, how do you specify the exact input device to use? My computer has two microphones, one built-in and one via USB, and I want to record using the USB mic. The Stream class has an input_device_index for selecting the device, but it's unclear how this index correlates to the devices. For example, how do I know which device index 0 refers to? If I had to guess, I'd say 0 refers to the built-in device while 1 refers to the USB device, but I'd like to find some