Video chat temp (#1)

* 视觉更新

---------

Co-authored-by: 杍超 <huangbinchao.hbc@alibaba-inc.com>
Co-authored-by: 款冬 <neil.xh@alibaba-inc.com>
This commit is contained in:
bingochaos
2025-02-14 15:53:54 +08:00
committed by GitHub
parent d567721603
commit 2b19ee493e
23 changed files with 1844 additions and 770 deletions

BIN
docs/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

BIN
docs/image2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 KiB

View File

@@ -13,7 +13,8 @@ Typically, you want to run an AI model that generates audio when the user has st
and passing it to the `stream` event of the `WebRTC` component.
=== "Code"
``` py title="ReplyonPause"
````py title="ReplyonPause"
import gradio as gr
from gradio_webrtc import WebRTC, ReplyOnPause
@@ -195,7 +196,6 @@ Here is a complete example of using `AsyncStreamHandler` for using the Google Ge
self.input_queue = asyncio.Queue()
self.output_queue = asyncio.Queue()
self.quit = asyncio.Event()
self.connected = asyncio.Event()
def copy(self) -> "GeminiHandler":
return GeminiHandler(
@@ -215,7 +215,6 @@ Here is a complete example of using `AsyncStreamHandler` for using the Google Ge
async with client.aio.live.connect(
model="gemini-2.0-flash-exp", config=config
) as session:
self.connected.set()
async for audio in session.start_stream(
stream=self.stream(), mime_type="audio/pcm"
):
@@ -237,10 +236,7 @@ Here is a complete example of using `AsyncStreamHandler` for using the Google Ge
async def emit(self):
if not self.args_set.is_set():
await self.wait_for_args()
if not self.connected.is_set():
asyncio.create_task(self.generator())
await self.connected.wait()
asyncio.create_task(self.generator())
array = await self.output_queue.get()
return (self.output_sample_rate, array)
@@ -439,7 +435,7 @@ async def video_receive(self, frame: np.ndarray):
async def video_emit(self) -> VideoEmitType:
"""Return video frames to the client"""
return await self.video_queue.get()
```
````
## Additional Outputs