Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rachwalk committed Jan 23, 2025
1 parent 928a9ff commit 05219f9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
32 changes: 0 additions & 32 deletions src/rai/rai/agents/voice_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,35 +197,3 @@ def transcription_thread(self, identifier: str):
)
self.transcription_threads[identifier]["transcription"] = transcription
self.transcription_threads[identifier]["event"].set()

# with self.transcription_lock:
# while self.active_thread == identifier:
# with self.sample_buffer_lock:
# if len(self.sample_buffer) == 0:
# continue
# audio_data = self.sample_buffer.copy()
# self.sample_buffer = []
# audio_data = np.concatenate(audio_data)
# with self.transcription_lock:
# self.transcription_model.transcribe(audio_data)

# # transciption of the reminder of the buffer
# with self.sample_buffer_lock:
# if identifier in self.transcription_buffers:
# audio_data = self.transcription_buffers[identifier]
# audio_data = np.concatenate(audio_data)
# with self.transcription_lock:
# self.transcription_model.transcribe(audio_data)
# del self.transcription_buffers[identifier]
# # self.transcription_model.save_wav(f"{identifier}.wav")
# with self.transcription_lock:
# transcription = self.transcription_model.consume_transcription()
# self.logger.info(f"Transcription: {transcription}")
# self.connectors["ros2"].send_message(
# ROS2ARIMessage(
# {"data": transcription}, {"msg_type": "std_msgs/msg/String"}
# ),
# "/from_human",
# )
# self.transcription_threads[identifier]["transcription"] = transcription
# self.transcription_threads[identifier]["event"].set()
19 changes: 0 additions & 19 deletions src/rai_asr/rai_asr/models/local_whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,6 @@ def __init__(self, model_name: str, sample_rate: int, language: str = "en"):
self.whisper = whisper.load_model(self.model_name)

self.logger = logging.getLogger(__name__)
# TODO: remove sample storage before PR is merged, this is just to enable saving wav files for debugging
# self.samples = None

# def save_wav(self, output_filename: str):
# assert self.samples is not None, "No samples to save"
# combined_samples = self.samples
# if combined_samples.dtype.kind == "f":
# combined_samples = np.clip(combined_samples, -1.0, 1.0)
# combined_samples = (combined_samples * 32767).astype(np.int16)
# elif combined_samples.dtype != np.int16:
# combined_samples = combined_samples.astype(np.int16)

# with wave.open(output_filename, "wb") as wav_file:
# n_channels = 1
# sampwidth = 2
# wav_file.setnchannels(n_channels)
# wav_file.setsampwidth(sampwidth)
# wav_file.setframerate(self.sample_rate)
# wav_file.writeframes(combined_samples.tobytes())

def transcribe(self, data: NDArray[np.int16]) -> str:
normalized_data = data.astype(np.float32) / 32768.0
Expand Down

0 comments on commit 05219f9

Please sign in to comment.