Skip to content

Commit

Permalink
Add text to indicate recording
Browse files Browse the repository at this point in the history
  • Loading branch information
dougollerenshaw committed Oct 8, 2024
1 parent c1b7c83 commit 540b8d9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion codeaide/ui/chat_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 540b8d9

Please sign in to comment.