Commit 3820451b authored by LiniEisha's avatar LiniEisha

Integrate

parent adb48fef
import sounddevice as sd
from scipy.io.wavfile import write
import wavio as wv
import os
# Sampling frequency
freq = 44100
def AudioRecorder(audio):
# Recording duration
duration = 10
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Start recorder with the given values of
# duration and sample frequency
recording = sd.rec(int(duration * freq),
samplerate=freq, channels=2)
#for the array
DESTINATION_DIR = os.path.join(BASE_DIR, "audioArray\\{}".format(audio))
# Record audio for the given number of seconds
sd.wait()
#for the audio
LECTURE_AUDIO_DIR = os.path.join(BASE_DIR, "lectures\\{}".format(audio))
# This will convert the NumPy array to an audio
# file with the given sampling frequency
write("recording0.wav", freq, recording)
# Sampling frequency
freq = 44100
# Recording duration
duration = 20
# Start recorder with the given values of
# duration and sample frequency
recording = sd.rec(int(duration * freq),samplerate=freq, channels=2)
# Record audio for the given number of seconds
sd.wait()
# This will convert the NumPy array to an audio
# file with the given sampling frequency
write("recording0.wav", freq, recording)
#Convert the NumPy array to audio file
wv.write("recording1.wav", recording, freq, sampwidth=2)
\ No newline at end of file
wv.write("recording1.wav", recording, freq, sampwidth=2)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment