update
#1
by deleted - opened
README.md
CHANGED
|
@@ -1,73 +1,44 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
```markdown
|
| 7 |
-
# Mood Parser AI: Moodly
|
| 8 |
-
|
| 9 |
-
**Moodly** is an AI-powered Mood Parser that detects emotions in text using a fine-tuned transformer-based model, such as BERT or RoBERTa. Deployed on Hugging Face, it offers real-time mood analysis and emotion classification across multiple languages.
|
| 10 |
-
|
| 11 |
-
## Demo
|
| 12 |
-
|
| 13 |
-
You can try **Moodly** directly on Hugging Face:
|
| 14 |
-
|
| 15 |
-
[Try Moodly](https://huggingface.co/spaces/RummyAx/Mood-Parser)
|
| 16 |
-
|
| 17 |
-
## How it Works
|
| 18 |
-
|
| 19 |
-
Moodly detects a variety of emotions from text input. The model is trained on sentiment and emotion classification tasks to provide accurate results. It supports multiple languages for global usage.
|
| 20 |
-
|
| 21 |
-
### Supported Emotions
|
| 22 |
-
|
| 23 |
-
- Happiness
|
| 24 |
-
- Sadness
|
| 25 |
-
- Anger
|
| 26 |
-
- Fear
|
| 27 |
-
- Surprise
|
| 28 |
-
- Disgust
|
| 29 |
-
|
| 30 |
-
## Example
|
| 31 |
-
|
| 32 |
-
### Input:
|
| 33 |
-
```text
|
| 34 |
-
I am feeling really happy today!
|
| 35 |
-
```
|
| 36 |
-
|
| 37 |
-
### Output:
|
| 38 |
-
```json
|
| 39 |
-
{
|
| 40 |
-
"emotion": "happiness",
|
| 41 |
-
"confidence": 0.97
|
| 42 |
-
}
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
## API Usage
|
| 46 |
-
|
| 47 |
-
You can integrate the model into your applications using Hugging Face's API.
|
| 48 |
-
|
| 49 |
-
### API Endpoint
|
| 50 |
-
|
| 51 |
-
- **URL**: `https://api-inference.huggingface.co/models/RummyAx/Mood-Parser`
|
| 52 |
-
- **Method**: POST
|
| 53 |
-
- **Body**: Send a POST request with the input text.
|
| 54 |
-
|
| 55 |
-
### Example API Request:
|
| 56 |
-
|
| 57 |
-
```bash
|
| 58 |
-
curl -X POST "https://api-inference.huggingface.co/models/RummyAx/Mood-Parser" \
|
| 59 |
-
-H "Authorization: Bearer YOUR_HUGGINGFACE_API_KEY" \
|
| 60 |
-
-H "Content-Type: application/json" \
|
| 61 |
-
-d '{"inputs": "I am feeling very sad!"}'
|
| 62 |
-
```
|
| 63 |
-
|
| 64 |
-
### Example API Response:
|
| 65 |
-
|
| 66 |
-
```json
|
| 67 |
-
{
|
| 68 |
-
"emotion": "sadness",
|
| 69 |
-
"confidence": 0.95
|
| 70 |
-
}
|
| 71 |
```
|
| 72 |
|
| 73 |
## Installation (Local)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
+
from gtts import gTTS
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# Load Mistral 7B Chat Model
|
| 7 |
+
model_name = "mistralai/Mistral-7B-Instruct"
|
| 8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 10 |
+
|
| 11 |
+
# Function to generate AI response
|
| 12 |
+
def chatbot_response(user_input):
|
| 13 |
+
inputs = tokenizer(user_input, return_tensors="pt")
|
| 14 |
+
outputs = model.generate(**inputs, max_length=200)
|
| 15 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 16 |
+
return response
|
| 17 |
+
|
| 18 |
+
# Function to convert AI response to speech
|
| 19 |
+
def text_to_speech(text):
|
| 20 |
+
tts = gTTS(text=text, lang="en")
|
| 21 |
+
filename = "response.mp3"
|
| 22 |
+
tts.save(filename)
|
| 23 |
+
return filename
|
| 24 |
+
|
| 25 |
+
# Gradio Interface
|
| 26 |
+
def chat_interface(user_input):
|
| 27 |
+
ai_response = chatbot_response(user_input)
|
| 28 |
+
audio_file = text_to_speech(ai_response)
|
| 29 |
+
return ai_response, audio_file
|
| 30 |
+
|
| 31 |
+
# Launch Gradio UI
|
| 32 |
+
demo = gr.Interface(
|
| 33 |
+
fn=chat_interface,
|
| 34 |
+
inputs=gr.Textbox(label="Ask ZEAL.AI"),
|
| 35 |
+
outputs=[gr.Textbox(label="AI Response"), gr.Audio(label="Text-to-Speech Output")],
|
| 36 |
+
title="ZEAL.AI - Bible AI Chatbot",
|
| 37 |
+
description="Ask anything and get a spoken response!"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
demo.launch()
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
## Installation (Local)
|