I need your help because at the moment I use "engine.say()" from "pyttsx3" so my program "speaks" with me. That's already working but now I want an audio visualizer for this voice how can I do that?
Example
import pyttsx3
engine = pyttsx3.init()
engine.say("Hello World")
engine.runAndWait()
And I want something like this.
What I have
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)
This already visualizes my microphone audio but how can I make the voice the source? Hope you can help me Thank you very much!