Team Ai
Apppublic

Coder19/interview_system

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
audio.py22 linesDownload Raw Back to utils
1import pyaudio2 3class Audio:4    def __init__(self):5        self.is_recording = False6        self.p = pyaudio.PyAudio()7 8    async def start_recording(self):9        10        self.stream = self.p.open(format=pyaudio.paInt16, channels=1, rate=44100, input=True, frames_per_buffer=1024)11        self.stream.start_stream()12        self.is_recording = False13 14    async def stop_recording(self):15     if hasattr(self, 'stream'):16        self.stream.stop_stream()17        self.stream.close()18        self.p.terminate()19        self.is_recording = False20     else:21         print("No stream to stop")22