import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer from gtts import gTTS import os # Load Mistral 7B Chat Model model_name = "mistralai/Mistral-7B-Instruct" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name) # Function to generate AI response def chatbot_response(user_input): inputs = tokenizer(user_input, return_tensors="pt") outputs = model.generate(**inputs, max_length=200) response = tokenizer.decode(outputs[0], skip_special_tokens=True) return response # Function to convert AI response to speech def text_to_speech(text): tts = gTTS(text=text, lang="en") filename = "response.mp3" tts.save(filename) return filename # Gradio Interface def chat_interface(user_input): ai_response = chatbot_response(user_input) audio_file = text_to_speech(ai_response) return ai_response, audio_file # Launch Gradio UI demo = gr.Interface( fn=chat_interface, inputs=gr.Textbox(label="Ask ZEAL.AI"), outputs=[gr.Textbox(label="AI Response"), gr.Audio(label="Text-to-Speech Output")], title="ZEAL.AI - Bible AI Chatbot", description="Ask anything and get a spoken response!" ) demo.launch() ``` ## Installation (Local) To run **Moodly** locally, follow these steps: 1. Clone the repository: ```bash git clone https://github.com/RummyAx/Mood-Parser.git ``` 2. Install required libraries: ```bash pip install -r requirements.txt ``` 3. Run the model: ```bash python app.py ``` This will allow you to use the model on your local machine. ## Contributing We welcome contributions to this project! To contribute: 1. Fork the repository 2. Create a new branch (`git checkout -b feature-branch`) 3. Commit your changes (`git commit -am 'Add new feature'`) 4. Push to the branch (`git push origin feature-branch`) 5. Create a Pull Request ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## Acknowledgments - Hugging Face for providing the platform and hosting the model. - The authors of BERT and RoBERTa for their powerful transformer models. - The open-source community for their contributions to NLP. ``` This updated README reflects the correct repository name `RummyAx/Mood-Parser` and includes links and API usage instructions for your Hugging Face project. Make sure to replace the `YOUR_HUGGINGFACE_API_KEY` placeholder with your actual Hugging Face API key.