From ac871b7a4505f8759bd66aeedfdd2ff7bbf6e98b Mon Sep 17 00:00:00 2001 From: dougollerenshaw Date: Tue, 8 Oct 2024 16:08:13 -0700 Subject: [PATCH] Saving wav as temp file --- codeaide/ui/chat_window.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codeaide/ui/chat_window.py b/codeaide/ui/chat_window.py index 925be51..6a10798 100644 --- a/codeaide/ui/chat_window.py +++ b/codeaide/ui/chat_window.py @@ -40,12 +40,12 @@ ) from codeaide.utils.logging_config import get_logger from codeaide.ui.traceback_dialog import TracebackDialog -import os import time import sounddevice as sd import numpy as np from scipy.io import wavfile import whisper +import tempfile class AudioRecorder(QThread): @@ -646,7 +646,8 @@ def start_recording(self): self.logger.info(f"Final HTML after setting: {self.input_text.toHtml()}") - filename = os.path.expanduser("~/recorded_audio.wav") + with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file: + filename = temp_file.name self.recorder = AudioRecorder(filename, self.logger) self.recorder.finished.connect(self.on_recording_finished) self.recorder.start()