노현욱

init

File mode changed
import pyaudio
from pydub import AudioSegment
from pydub.effects import normalize
# set up PyAudio
pa = pyaudio.PyAudio()
stream = pa.open(format=pyaudio.paInt16,
channels=1,
rate=44100,
input=True,
frames_per_buffer=1024)
# record some audio from the microphone
audio_data = []
for i in range(0, int(44100 / 1024 * 5)):
data = stream.read(1024)
audio_data.append(data)
# convert the audio data to a PyDub audio segment
audio_segment = AudioSegment(
data=b''.join(audio_data),
sample_width=2,
frame_rate=44100,
channels=1
)
# apply an echo effect to the audio segment
echoed_segment = normalize(audio_segment)
# save the output audio file
echoed_segment.export("output.mp3", format="mp3")
# clean up
stream.stop_stream()
stream.close()
pa.terminate()