CoolFace
Apppublic

Hudda/sentimentanalysis_hudda

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
app.py38 linesDownload Raw Back to root
1from fastapi import FastAPI2import nest_asyncio3from pyngrok import ngrok4import uvicorn5import gradio as gr6 7app = FastAPI()8 9url = "https://sentiment-analysis9.p.rapidapi.com/sentiment"10 11def call_sentiment_api(user_input):12    payload = [{13        "id": "1",14        "language": "en",15        "text": user_input16    }]17    headers = {18        "content-type": "application/json",19        "Accept": "application/json",20        "X-RapidAPI-Key": "5cf8fcaf61msh613f010a34f3576p1953e5jsn110a1e6c667d",21        "X-RapidAPI-Host": "sentiment-analysis9.p.rapidapi.com"22    }23 24    response = requests.post(url, json=payload, headers=headers)25 26    return response.json()27 28 29 30 31 32 33 34 35 36iface7 = gr.Interface(get_sentiment, inputs= "text", outputs= "text", title="Sentiment Analysis")37 38iface7.launch(inline=False)