Spaces:
Sleeping
Sleeping
File size: 445 Bytes
3c2d709 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import sounddevice as sd
from scipy.io.wavfile import write
import os
def record_audio(duration=10, filename="output.wav", fs=16000):
print("Recording audio...")
audio = sd.rec(int(duration * fs), samplerate=fs, channels=1)
sd.wait() # Wait until recording is finished
audio_path = os.path.join("audio_files", filename)
write(audio_path, fs, audio)
print(f"Audio recording saved as {audio_path}")
return audio_path
|