mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Add Integrated Textbox to the docs + spaces (#343)
* Add to docs * Fix requirements
This commit is contained in:
19
demo/integrated_textbox/README.md
Normal file
19
demo/integrated_textbox/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: Integrated Text Box
|
||||
emoji: 📝
|
||||
colorFrom: purple
|
||||
colorTo: red
|
||||
sdk: gradio
|
||||
sdk_version: 5.31.0
|
||||
app_file: app.py
|
||||
pinned: false
|
||||
license: mit
|
||||
short_description: Talk or type to ANY LLM!
|
||||
tags: [webrtc, websocket, gradio, secret|HF_TOKEN]
|
||||
---
|
||||
|
||||
# Integrated Textbox
|
||||
|
||||
Talk or type to ANY LLM!
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# /// script
|
||||
# dependencies = [
|
||||
# "fastrtc[vad, stt]==0.0.26.rc1",
|
||||
# "fastrtc[vad, stt]">=0.0.26",
|
||||
# "openai",
|
||||
# ]
|
||||
# ///
|
||||
@@ -14,8 +14,10 @@ from fastrtc import (
|
||||
WebRTC,
|
||||
WebRTCData,
|
||||
WebRTCError,
|
||||
get_hf_turn_credentials,
|
||||
get_stt_model,
|
||||
)
|
||||
from gradio.utils import get_space
|
||||
from openai import OpenAI
|
||||
|
||||
stt_model = get_stt_model()
|
||||
@@ -118,9 +120,17 @@ with gr.Blocks(css=css) as demo:
|
||||
)
|
||||
provider.change(hide_token, inputs=[provider], outputs=[token])
|
||||
cb = gr.Chatbot(type="messages", height=600)
|
||||
webrtc = WebRTC(modality="audio", mode="send", variant="textbox")
|
||||
webrtc = WebRTC(
|
||||
modality="audio",
|
||||
mode="send",
|
||||
variant="textbox",
|
||||
rtc_configuration=get_hf_turn_credentials if get_space() else None,
|
||||
server_rtc_configuration=get_hf_turn_credentials(ttl=3_600 * 24 * 30)
|
||||
if get_space()
|
||||
else None,
|
||||
)
|
||||
webrtc.stream(
|
||||
ReplyOnPause(response),
|
||||
ReplyOnPause(response), # type: ignore
|
||||
inputs=[webrtc, cb, token, model, provider],
|
||||
outputs=[cb],
|
||||
concurrency_limit=100,
|
||||
@@ -130,4 +140,4 @@ with gr.Blocks(css=css) as demo:
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch(server_port=6980)
|
||||
demo.launch(server_port=7860)
|
||||
2
demo/integrated_textbox/requirements.txt
Normal file
2
demo/integrated_textbox/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
fastrtc[vad, stt]
|
||||
openai
|
||||
Reference in New Issue
Block a user