如何在 python 3 上生成正弦波音调
Posted
技术标签:
【中文标题】如何在 python 3 上生成正弦波音调【英文标题】:How to generate a Sine wave tone on python 3 【发布时间】:2019-07-26 00:39:55 【问题描述】:我想使用 1kHz 频率的 python 3 生成正弦音调。我在 *** (old question) 上发现了一个关于它的老问题,但那是使用用于 python 2 的 pyaudio
。
有没有其他方法可以使用 python 3 做到这一点?
尝试安装音阶时出错
Successfully built tonescale propyte shijian sklearn docopt pyprel pytg technico
lor DictObject backcall pyrsistent prometheus-client pandocfilters
Failed to build pyaudio
Installing collected packages: docopt, python-magic, websocket-client, pushbulle
t.py, pickleshare, backcall, ipython-genutils, decorator, traitlets, pygments, p
rompt-toolkit, parso, jedi, colorama, ipython, tornado, pyzmq, jupyter-core, jup
yter-client, ipykernel, pyrsistent, jsonschema, nbformat, entrypoints, pandocfil
ters, webencodings, bleach, mistune, testpath, MarkupSafe, jinja2, defusedxml, n
bconvert, prometheus-client, pywinpty, terminado, Send2Trash, notebook, widgetsn
bextension, ipywidgets, kiwisolver, cycler, pyparsing, matplotlib, scipy, seabor
n, joblib, scikit-learn, sklearn, technicolor, shijian, pyprel, luckydonald-util
s, DictObject, pytg, psutil, propyte, pyaudio, tonescale
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\myUser\appdata\local\programs\python\python37-32\python.exe
' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\myUser\\Ap
pData\\Local\\Temp\\pip-install-zn_0i9s8\\pyaudio\\setup.py'"'"'; __file__='"'"'
C:\\Users\\myUser\\AppData\\Local\\Temp\\pip-install-zn_0i9s8\\pyaudio\\setup.py'"'
"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'
"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'
))' install --record 'C:\Users\myUser\AppData\Local\Temp\pip-record-5j63osr6\instal
l-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\myUser\AppData\Local\Temp\pip-install-zn_0i9s8\pyaudio\
Complete output (9 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
copying src\pyaudio.py -> build\lib.win32-3.7
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\myUser\appdata\local\progr
ams\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.
argv[0] = '"'"'C:\\Users\\myUser\\AppData\\Local\\Temp\\pip-install-zn_0i9s8\\pyaud
io\\setup.py'"'"'; __file__='"'"'C:\\Users\\myUser\\AppData\\Local\\Temp\\pip-insta
ll-zn_0i9s8\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__
file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compi
le(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\myUser\AppData\Loca
l\Temp\pip-record-5j63osr6\install-record.txt' --single-version-externally-manag
ed --compile Check the logs for full command output.
【问题讨论】:
【参考方案1】:tonescale installation instructions 建议使用python3版本的pyaudio:python3-pyaudio。
还有pygame。
pyaudio install instructions for Windows 建议 它应该顺利进行,因为提供了二进制***。 但是他们确实提到在不寻常的情况下 可能需要对 PortAudio 进行编译。
您可能想尝试使用archive 的降速轮。
【讨论】:
那么我将如何 pip 安装 python3 版本?只是pip install tonescale
?
我刚试过pip install tonescale
。它出错了。用错误更新了我的第一篇文章。编辑:对不起,我不小心试图编辑你的帖子...请忽略这个以上是关于如何在 python 3 上生成正弦波音调的主要内容,如果未能解决你的问题,请参考以下文章