Spaces:
Sleeping
Sleeping
File size: 714 Bytes
e1577a5 bc3aeb9 e1577a5 89eb395 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
import websockets
import asyncio
async def send_to_websocket(message):
uri = "ws://localhost:8765" # Replace with your WebSocket server URI
async with websockets.connect(uri) as websocket:
await websocket.send(message)
response = await websocket.recv()
return response
def predict(input_text):
# You can replace this with your actual machine learning model prediction logic
# For now, we'll just send the input to the WebSocket server and echo the response
response = asyncio.run(send_to_websocket(input_text))
return response
iface = gr.Interface(
fn=predict,
inputs=gr.Textbox(),
outputs="text",
live=True,
)
iface.launch() |