From 540b8d9aeb07b66cdf6183303cc6f24339e4a129 Mon Sep 17 00:00:00 2001 From: dougollerenshaw Date: Tue, 8 Oct 2024 12:17:07 -0700 Subject: [PATCH] Add text to indicate recording --- codeaide/ui/chat_window.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/codeaide/ui/chat_window.py b/codeaide/ui/chat_window.py index 67ed1a4..447208a 100644 --- a/codeaide/ui/chat_window.py +++ b/codeaide/ui/chat_window.py @@ -597,6 +597,15 @@ def start_recording(self): for widget in self.widgets_to_disable_when_recording: widget.setEnabled(False) + # Add "Recording" text to the input box + current_text = self.input_text.toPlainText() + if current_text: + new_text = current_text + " Recording... " + else: + new_text = "Recording... " + self.input_text.setPlainText(new_text) + self.input_text.setReadOnly(True) + filename = os.path.expanduser("~/recorded_audio.wav") self.recorder = AudioRecorder(filename) self.recorder.finished.connect(self.on_recording_finished) @@ -609,6 +618,11 @@ def stop_recording(self): self.is_recording = False self.set_record_button_style(False) + # Remove "Recording" text and add "Transcribing..." + current_text = self.input_text.toPlainText() + new_text = current_text.replace("Recording... ", "Transcribing... ") + self.input_text.setPlainText(new_text) + # Re-enable widgets for widget in self.widgets_to_disable_when_recording: widget.setEnabled(True) @@ -645,13 +659,17 @@ def transcribe_audio(self, filename): self.transcription_thread.start() def on_transcription_finished(self, transcribed_text): - # Insert transcribed text into the input text field + # Remove "Transcribing..." text current_text = self.input_text.toPlainText() + current_text = current_text.replace("Transcribing...", "").strip() + + # Insert transcribed text into the input text field if current_text: new_text = current_text + " " + transcribed_text else: new_text = transcribed_text self.input_text.setPlainText(new_text) + self.input_text.setReadOnly(False) # Move cursor to the end of the text cursor = self.input_text.textCursor()