Skip to content

Commit

Permalink
Merge pull request #55 from abhisheky1806/patch-2
Browse files Browse the repository at this point in the history
added feature of audio recording
  • Loading branch information
anupkafle committed Oct 18, 2022
2 parents 8cdd501 + 9fc4fbe commit 3eda1c7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions python/audio.py
@@ -0,0 +1,28 @@
import sounddevice as sd
from scipy.io.wavfile import write
import wavio as wv


from pydub import AudioSegment
from os import path


#sampling frequency
freq = 44100

#recording duration in seconds
duration = 60

#start recorder with given values of duration and frequency
recording = sd.rec(int(duration * freq), samplerate=freq, channels=2)

sd.wait()

#save the audio
write("testAudio0.wav", freq, recording)
wv.write("testAudio1.wav", recording, freq, sampwidth=2)


# if you want to convert f.wav file in .mp3
#sound = AudioSegment.from_mp3('testAudio0.wav')
#sound.export('testAudio0.mp3', format="wav")

0 comments on commit 3eda1c7

Please sign in to comment.