import gradio as gr def greet(name): return "Hello " + name + "!!" demo = gr.Interface(fn=greet, inputs="text", outputs="text") demo.launch() # import asyncio # from gradio_webrtc import AsyncAudioVideoStreamHandler # class GeminiHandler(AsyncAudioVideoStreamHandler): # def __init__( # self, expected_layout="mono", output_sample_rate=24000, output_frame_size=480 # ) -> None: # super().__init__( # expected_layout, # output_sample_rate, # output_frame_size, # input_sample_rate=16000, # ) # self.audio_queue = asyncio.Queue() # self.video_queue = asyncio.Queue() # self.quit = asyncio.Event() # self.session = None # self.last_frame_time = 0 # def copy(self) -> "GeminiHandler": # """Copy gets called whenever a new user connects to the server. # This ensures that each user has an independent handler. # """ # return GeminiHandler( # expected_layout=self.expected_layout, # output_sample_rate=self.output_sample_rate, # output_frame_size=self.output_frame_size, # ) # async def video_receive(self, frame: np.ndarray): # """Send video frames to the server""" # if self.session: # # send image every 1 second # # otherwise we flood the API # if time.time() - self.last_frame_time > 1: # self.last_frame_time = time.time() # await self.session.send(encode_image(frame)) # if self.latest_args[2] is not None: # await self.session.send(encode_image(self.latest_args[2])) # self.video_queue.put_nowait(frame) # async def video_emit(self) -> VideoEmitType: # """Return video frames to the client""" # return await self.video_queue.get()