apirrone commited on
Commit
8a09e0f
·
1 Parent(s): 9501819

remove useless condition

Browse files
src/reachy_mini_conversation_app/openai_realtime.py CHANGED
@@ -83,7 +83,7 @@ class OpenaiRealtimeHandler(AsyncStreamHandler):
83
  async def start_up(self) -> None:
84
  """Start the handler with minimal retries on unexpected websocket closure."""
85
  openai_api_key = config.OPENAI_API_KEY
86
- if self.gradio_mode and not openai_api_key or not openai_api_key.strip():
87
  # api key was not found in .env or in the environment variables
88
  await self.wait_for_args() # type: ignore[no-untyped-call]
89
  args = list(self.latest_args)
@@ -364,7 +364,7 @@ class OpenaiRealtimeHandler(AsyncStreamHandler):
364
  return
365
  input_sample_rate, audio_frame = frame
366
 
367
- #Reshape if needed
368
  if audio_frame.ndim == 2:
369
  # Scipy channels last convention
370
  if audio_frame.shape[1] > audio_frame.shape[0]:
@@ -375,10 +375,7 @@ class OpenaiRealtimeHandler(AsyncStreamHandler):
375
 
376
  # Resample if needed
377
  if self.input_sample_rate != input_sample_rate:
378
- audio_frame = resample(
379
- audio_frame,
380
- int(len(audio_frame) * self.input_sample_rate / input_sample_rate)
381
- )
382
 
383
  # Cast if needed
384
  audio_frame = audio_to_int16(audio_frame)
 
83
  async def start_up(self) -> None:
84
  """Start the handler with minimal retries on unexpected websocket closure."""
85
  openai_api_key = config.OPENAI_API_KEY
86
+ if self.gradio_mode and not openai_api_key:
87
  # api key was not found in .env or in the environment variables
88
  await self.wait_for_args() # type: ignore[no-untyped-call]
89
  args = list(self.latest_args)
 
364
  return
365
  input_sample_rate, audio_frame = frame
366
 
367
+ # Reshape if needed
368
  if audio_frame.ndim == 2:
369
  # Scipy channels last convention
370
  if audio_frame.shape[1] > audio_frame.shape[0]:
 
375
 
376
  # Resample if needed
377
  if self.input_sample_rate != input_sample_rate:
378
+ audio_frame = resample(audio_frame, int(len(audio_frame) * self.input_sample_rate / input_sample_rate))
 
 
 
379
 
380
  # Cast if needed
381
  audio_frame = audio_to_int16(audio_frame)