sohojoe commited on
Commit
768e92a
1 Parent(s): ad67495

fix use of ray.get inside aync

Browse files
Files changed (2) hide show
  1. charles_actor.py +3 -3
  2. streamlit_av_queue.py +7 -7
charles_actor.py CHANGED
@@ -54,7 +54,7 @@ class CharlesActor:
54
  if len(self._debug_queue) > 0:
55
  prompt = self._debug_queue.pop(0)
56
  await self._chat_pipeline.enqueue(prompt)
57
- audio_frames = self._streamlit_av_queue.get_audio_frames()
58
  if len(audio_frames) > 0:
59
  total_audio_frames += len(audio_frames)
60
  # Concatenate all audio frames into a single buffer
@@ -70,7 +70,7 @@ class CharlesActor:
70
  table_content += "\n".join([f"| {item} |" for item in reversed(system_one_audio_history)])
71
  self._system_one_audio_history_output = table_content
72
  await self._chat_pipeline.enqueue(prompt)
73
- video_frames = self._streamlit_av_queue.get_video_frames()
74
  if len(video_frames) > 0:
75
  total_video_frames += len(video_frames)
76
  # for video_frame in video_frames:
@@ -115,6 +115,6 @@ if __name__ == "__main__":
115
  # The start method is still running. You can poll for debug information here.
116
  time.sleep(1)
117
  state = charles_actor.get_state.remote()
118
- print(f"Charles is in state: {ray.get(state)}")
119
  except KeyboardInterrupt:
120
  print("Script was manually terminated")
 
54
  if len(self._debug_queue) > 0:
55
  prompt = self._debug_queue.pop(0)
56
  await self._chat_pipeline.enqueue(prompt)
57
+ audio_frames = await self._streamlit_av_queue.get_audio_frames_async()
58
  if len(audio_frames) > 0:
59
  total_audio_frames += len(audio_frames)
60
  # Concatenate all audio frames into a single buffer
 
70
  table_content += "\n".join([f"| {item} |" for item in reversed(system_one_audio_history)])
71
  self._system_one_audio_history_output = table_content
72
  await self._chat_pipeline.enqueue(prompt)
73
+ video_frames = await self._streamlit_av_queue.get_video_frames_async()
74
  if len(video_frames) > 0:
75
  total_video_frames += len(video_frames)
76
  # for video_frame in video_frames:
 
115
  # The start method is still running. You can poll for debug information here.
116
  time.sleep(1)
117
  state = charles_actor.get_state.remote()
118
+ # print(f"Charles is in state: {ray.get(state)}")
119
  except KeyboardInterrupt:
120
  print("Script was manually terminated")
streamlit_av_queue.py CHANGED
@@ -65,11 +65,11 @@ class StreamlitAVQueue:
65
  new_frame.sample_rate = frame.sample_rate
66
  new_frames.append(new_frame)
67
  return new_frames
68
-
69
- def get_audio_frames(self) -> List[av.AudioFrame]:
70
- shared_buffers = ray.get(self.queue_actor.get_audio_frames.remote())
71
  return shared_buffers
72
-
73
- def get_video_frames(self) -> List[av.AudioFrame]:
74
- shared_tensors = ray.get(self.queue_actor.get_video_frames.remote())
75
- return shared_tensors
 
65
  new_frame.sample_rate = frame.sample_rate
66
  new_frames.append(new_frame)
67
  return new_frames
68
+
69
+ async def get_audio_frames_async(self) -> List[av.AudioFrame]:
70
+ shared_buffers = await self.queue_actor.get_audio_frames.remote()
71
  return shared_buffers
72
+
73
+ async def get_video_frames_async(self) -> List[av.AudioFrame]:
74
+ shared_tensors = await self.queue_actor.get_video_frames.remote()
75
+ return shared_tensors