【发布时间】:2020-10-30 19:46:08
【问题描述】:
我需要你的帮助,因为目前我使用“pyttsx3”中的“engine.say()”,所以我的程序会和我“说话”。这已经可以了,但现在我想要这个声音的音频可视化器,我该怎么做?
示例
import pyttsx3
engine = pyttsx3.init()
engine.say("Hello World")
engine.runAndWait()
我有什么
import pyaudio
import struct
import matplotlib.pyplot as plt
import numpy as np
mic = pyaudio.PyAudio()
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 5000
CHUNK = 3000#int(RATE/20)
stream = mic.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, output=True, frames_per_buffer=CHUNK)
fig, ax = plt.subplots(figsize=(14,6))
x = np.arange(0, 2 * CHUNK, 2)
ax.set_ylim(-500, 500)
ax.set_xlim(0, CHUNK)
line, = ax.plot(x, np.random.rand(CHUNK))
while True:
data = stream.read(CHUNK)
data = np.frombuffer(data, np.int16)
line.set_ydata(data)
fig.canvas.draw()
fig.canvas.flush_events()
plt.pause(0.01)
这已经可视化了我的麦克风音频,但我怎样才能使声音成为源? 希望您能帮帮我,非常感谢!
【问题讨论】:
-
请尝试自己制作,然后向我们提出更具体的问题。
标签: python python-3.x audio