Toggle navigation
Toggle navigation
This project
Loading...
Sign in
노현욱
/
AR_instrument
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
노현욱
2023-03-30 18:34:29 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ea0eb11962211ea5a8e51c8c1336ffe1c0d61dcc
ea0eb119
1 parent
63bdc8de
init
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
output.mp3
streamToOut.py
output.mp3
0 → 100644
View file @
ea0eb11
File mode changed
streamToOut.py
0 → 100644
View file @
ea0eb11
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
()
Please
register
or
login
to post a comment