Vitalis_Devcore / src /audio_ear /recorder.py
FerrellSyntheticIntelligence
feat: audio ear, cognition modules, dream engine, vitalis IDE, test encoder
63dd1f4
import sounddevice as sd
import soundfile as sf
import numpy as np
from pathlib import Path
def record_to_wav(duration_sec: int, out_path: Path, fs: int = 16000) -> None:
"""
Interfaces directly with the local machine's sound architecture
to capture a mono-channel audio array.
"""
recording = sd.rec(int(duration_sec * fs), samplerate=fs, channels=1, dtype=np.float32)
sd.wait()
sf.write(str(out_path), recording, fs)