【发布时间】:2021-10-06 11:01:06
【问题描述】:
告诉我们如何重新输出麦克风输入的声音或修复它,因为您在使用虚拟音频电缆时使用电缆时听不到任何声音。(现场)我现在想要的是不输出微音频,而是用扬声器将输出的内容输出到麦克风。
【问题讨论】:
-
请不要创建重复的问题
-
我现在想要的不是输出微音频,而是用扬声器输出到麦克风的输出。
标签: python
告诉我们如何重新输出麦克风输入的声音或修复它,因为您在使用虚拟音频电缆时使用电缆时听不到任何声音。(现场)我现在想要的是不输出微音频,而是用扬声器将输出的内容输出到麦克风。
【问题讨论】:
标签: python
# Audio settings
CHUNK = 1024 # number of data points to read at a time
FORMAT = pyaudio.paInt16 # audio format. paInt16 = 16-bit resolution
CHANNELS = 1 # 1 channel for microphone
RATE = 44100 # 44.1kHz sampling rate
RECORD_SECONDS = 5 # total seconds to record
WAVE_OUTPUT_FILENAME = "output.wav" # name of .wav file
# Create the audio stream object
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
print("Audio Stream Created")
# Create the audio object and start recording
print("Recording...")
frames = [] # list of recorded data chunks
# Record for the amount of time we want
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK) # read a chunk of data
frames.append(data) # add to list of chunks
print("Finished Recording")
# Stop and close the audio stream
stream.stop_stream()
stream.close()
p.terminate()
# Write the data to a wav file
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb') # wf = wave file
wf.setnchannels(CHANNELS) # Set number of channels
wf.setsampwidth(p.get_sample_size(FORMAT)) # Set sampling format
wf.setframerate(RATE) # Set sampling rate
wf.writeframes(b''.join(frames)) # Join frames into a single byte string and write to the file
wf.close()
【讨论】: