【问题标题】:I want to output what I received as a microphone to a specific speaker我想将收到的麦克风作为麦克风输出到特定的扬声器
【发布时间】:2021-10-06 11:01:06
【问题描述】:

告诉我们如何重新输出麦克风输入的声音或修复它,因为您在使用虚拟音频电缆时使用电缆时听不到任何声音。(现场)我现在想要的是不输出微音频,而是用扬声器将输出的内容输出到麦克风。

【问题讨论】:

标签: python


【解决方案1】:
# 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()

【讨论】:

  • 我想在现场播放
猜你喜欢
  • 2014-08-11
  • 1970-01-01
  • 1970-01-01
  • 2014-10-31
  • 2011-12-25
  • 2011-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多