0

Tell us how to re-output the sound entered by the microphone or fix it because you can't hear any sound while using the cable when using the virtual audio cable.(in live) What I want now is not to output micro audio, but to output what is output to the microphone with the speaker.

  • Please do not create duplicate questions – Mahrkeenerh Oct 06 '21 at 11:02
  • What I want now is not to output micro audio, but to output what is output to the microphone with the speaker. – SilverPage Oct 06 '21 at 11:09
  • Does this answer your question? [I want to send the audio I'm listening to on my computer through the microphone](https://stackoverflow.com/questions/69462968/i-want-to-send-the-audio-im-listening-to-on-my-computer-through-the-microphone) – Kartikey Oct 06 '21 at 21:15

1 Answers1

0
# 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()
Mahi
  • 332
  • 3
  • 11