Update base_device.py

Remove the temporary directory and its contents to free up disk space
pull/254/head
Keyvan Hardani 1 year ago committed by GitHub
parent 625f02c9ce
commit 2a3701f91c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -169,7 +169,7 @@ class Device:
global RECORDING
# Create a temporary WAV file to store the audio data
temp_dir = tempfile.gettempdir()
temp_dir = tempfile.mkdtemp(prefix="audio_")
wav_path = os.path.join(
temp_dir, f"audio_{datetime.now().strftime('%Y%m%d%H%M%S%f')}.wav"
)
@ -237,9 +237,8 @@ class Device:
"end": True,
}
)
if os.path.exists(wav_path):
os.remove(wav_path)
# Remove the temporary directory and its contents
shutil.rmtree(temp_dir)
def toggle_recording(self, state):
"""Toggle the recording state."""

Loading…
Cancel
Save