Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Azure Viva-vocal Project #86

Merged
merged 7 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions Natural Language Processing/Azure_Review_analyzer/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# 🌟 ViveVocal: Azure Customer Review Analysis 🌟

[![GitHub issues](https://img.shields.io/github/issues/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-)](https://github.com/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-/issues)
[![GitHub forks](https://img.shields.io/github/forks/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-)](https://github.com/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-/network)
[![GitHub stars](https://img.shields.io/github/stars/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-)](https://github.com/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-/stargazers)
[![GitHub license](https://img.shields.io/github/license/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-)](https://github.com/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-/blob/main/LICENSE)

## 🚀 Project Overview
**ViveVocal** is an AI-driven platform that transforms customer feedback into valuable insights using **Azure Speech Services** for speech-to-text conversion and **Azure Language Services** for sentiment analysis, language detection, key phrase extraction, and entity recognition. This project aims to help businesses better understand and act on customer feedback by providing real-time insights from reviews submitted through voice, file uploads, or text.

---

### 🌟 Key Features
- 🗣️ **Speech Input**: Converts spoken feedback into text using Azure Speech Services.
- 📁 **File Upload**: Analyzes audio or text file uploads.
- ⌨️ **Text Input**: Direct text review analysis.

- 🎭 **Sentiment Analysis**: Detects the emotional tone (positive, negative, neutral).

- 🌍 **Language Detection**: Automatically detects the language of the review.

- 🔑 **Key Phrase Extraction**: Extracts important topics and key phrases.

- 🏷️ **Entity Recognition**: Identifies and links key entities like products, services, locations, and competitors to relevant sources.

---

### 🔑 Why It's a Game Changer
By analyzing **key phrases** and **entities**, businesses can:
- 🎯 **Address specific customer concerns**.
- 📊 **Spot emerging trends**.
- 🚀 **Respond proactively** based on real-time feedback.

Understanding not only the **emotional tone** but also **how entities (products, brands, services) impact customer opinions** provides businesses with a unique edge in improving customer satisfaction and making data-driven decisions.

---

## ⚙️ How It Works
1. **Speech-to-Text**: Converts audio feedback into text using **Azure Speech Services**.
2. **Text Processing**: Processes the text using **Azure Language Services** for:
- Sentiment analysis.
- Language detection.
- Key phrase extraction.
- Entity detection.
3. **Output**: Provides the sentiment, key phrases, detected language, and links to relevant entities.

---

## 🛠️ Installation
'''
### 1. Clone the Repository
```bash
git clone https://github.com/priyans877/VIvaVocal-Azure-Customer-Review-Analysis-.git
cd VIvaVocal-Azure-Customer-Review-Analysis-
```
---

### 2. Install Dependencies
--bash
pip install -r requirements.txt

---

### 3. Set Up Azure Services
Create an Azure Speech Services resource for speech-to-text conversion.
Set up Azure Language Services for sentiment analysis, language detection, key phrase extraction, and entity recognition.
Update your configuration files with the Azure API keys.
🚀 Usage

### Run the Application:

```bash

streamlit run app.py
```

### Provide Reviews in One of Three Ways:

- 🗣️ Speak into the microphone.
- 📁 Upload a file (audio or text).
- ⌨️ Type your review.

---


### Analyze the Output:

- View the sentiment (positive, neutral, negative).
- Key phrases and entities are displayed for further insights.
- Get language detection results and entity links for additional context.

---
### 💻 Technology Stack

- **Azure Speech Services**: Converts speech to text.
- **Azure Language Services**: Provides sentiment analysis, key phrase extraction, and entity detection.
- **Python**: Main programming language.
- **Streamlit**: Front-end for the web interface.

---

### 🤝 Contributing

We welcome contributions! To get started:

### Fork the repository.
- Create a new branch for your feature.
- Submit a pull request.
- Feel free to open issues for suggestions or bug reports.

### 📄 License
This project is licensed under the MIT License. See the LICENSE file for more details.

### 🎓 Acknowledgements
Special thanks to ICT Academy and Infosys for providing the training that made this project possible.

### 🌐 Connect
If you have any questions or feedback, feel free to contact us or open an issue in the GitHub repository!
88 changes: 88 additions & 0 deletions Natural Language Processing/Azure_Review_analyzer/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import streamlit as st
import os
from speech_recognition import main
from text_sentimet import text_analysis
# Main layout

# Set the page configuration
st.set_page_config(page_title="Priyanshu-Choubey", layout="wide")
st.markdown(
"""
<style>
[data-testid="stSidebar"][aria-expanded="true"] > div:first-child{
width: 400px;
}
[data-testid="stSidebar"][aria-expanded="false"] > div:first-child{
width: 400px;
margin-left: -400px;
}

""",
unsafe_allow_html=True,
)



# Page header
st.title("ViveVocal : Analyzing emotional Tone in Real-Time Speech")


st.header("""Choose how you'd like to proceed furthur:""", divider='rainbow')

# Option to select input method
input_method = st.radio("How would you like to provide input?",
('None','Voice Input', 'Select Pre-stored File','By entering text'),index=0)

# If user selects 'Voice Input'
if input_method == 'Voice Input':
main()



# If user selects 'Select Pre-stored File'
elif input_method == 'Select Pre-stored File':
st.info("You chose to use a pre-stored text file.")

#provide your directory which contain a reviews folder
file_directory = 'speech_text/'
if not os.path.exists(file_directory):
st.warning(f"The directory `{file_directory}` does not exist. Please ensure the folder is created.")
else:
files = [f for f in os.listdir(file_directory) if f.endswith('.txt')]
if len(files) > 0:
selected_file = st.selectbox("Choose a file", files)

# Display the content of the selected file
if selected_file:
file_path = os.path.join(file_directory, selected_file)
with open(file_path, 'r') as file:
content = file.read()
st.text_area("File Content", content, height=200)
if st.button(" Summarize Review"):
text_analysis(1,content)
else:
st.warning(f"No .txt files found in the `{file_directory}` directory.")

elif input_method=="By entering text":
st.info("You chose to input text manually.")

# Text input box
user_input = st.text_input("Enter your text here:")

if user_input:
# Display the manually entered text in a beautiful box
st.markdown(f"""
<div style="
background-color: #f0f0f5;
padding: 15px;
border-radius: 10px;
box-shadow: 2px 2px 12px rgba(0,0,0,0.1);
font-size: 16px;
font-family: Arial, sans-serif;
color: #333;
text-align: center;
">
{user_input}
</div>
""", unsafe_allow_html=True)
text_analysis(2,user_input)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip install azure-ai-textanalytics==5.3.0
pip install python-dotenv
pip install playsound==1.2.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
from datetime import datetime
import os
from text_sentimet import text_analysis
import streamlit as st


# Import namespaces
import azure.cognitiveservices.speech as speech_sdk
from playsound import playsound


def main():
try:
global command1
global speech_config

# Get Configuration Settings

ai_key = "b32f134094a2432fa1293380952bfa61"
ai_region = "eastus"

# Configure speech service
speech_config = speech_sdk.SpeechConfig(ai_key, ai_region)
st.subheader(f'Ready to use speech service in: {speech_config.region}',divider='rainbow')
#print('Ready to use speech service in ', speech_config.region)
st.divider()

if st.button(" Start by giving voice input Text"):
command1 = TranscribeCommand()

drictory="speech_text"
#maintatinig the file count in directory
fileslist=os.listdir("speech_text")
lenfl=len(fileslist)
# print(fileslist)
# print(lenfl)

if command1 != '':
with open(f"speech_text/review_{lenfl+1}.txt","x") as f:
#print("int the open funtion")
f.write(f"{command1}")
st.subheader(f"Your speaked text is saved in File name : {f"reveiw_{lenfl+1}.txt"}")
f.close()
text_analysis()
else:
st.warning("I cant hear any specific command kindly speak Again by Using button")

except Exception as ex:
st.warning(ex)

def TranscribeCommand():
command = ''


# Configure speech recognition
audio_config = speech_sdk.AudioConfig(use_default_microphone=True)
speech_recognizer = speech_sdk.SpeechRecognizer(speech_config, audio_config)
st.subheader('Speak now...' ,divider='rainbow')


# Process speech input
speech = speech_recognizer.recognize_once_async().get()
if speech.reason == speech_sdk.ResultReason.RecognizedSpeech:
command = speech.text
spoken_text = st.text_area("Simulated Voice Ouput",placeholder=f"{command}")
if spoken_text:
st.markdown(f"""
<div style="
background-color: #f0f0f5;
padding: 8px;
border-radius: 13px;
box-shadow: 2px 2px 12px rgba(0,0,0,0.1);
font-size: 30px;
font-family: Arial, sans-serif;
color: #80ff00;
text-align: center;
">
{spoken_text}
</div>
""", unsafe_allow_html=True)






else:
print(speech.reason)
if speech.reason == speech_sdk.ResultReason.Canceled:
cancellation = speech.cancellation_details
print(cancellation.reason)
print(cancellation.error_details)

# Return the command
return command



if __name__ == "__main__":
main()

# def TellTime():
# now = datetime.now()
# response_text = 'The time is {}:{:02d}'.format(now.hour,now.minute)


# # Configure speech synthesis
# speech_config.speech_synthesis_voice_name = "en-GB-RyanNeural"
# speech_synthesizer = speech_sdk.SpeechSynthesizer(speech_config)


# # Synthesize spoken output
# speak = speech_synthesizer.speak_text_async(response_text).get()
# if speak.reason != speech_sdk.ResultReason.SynthesizingAudioCompleted:
# print(speak.reason)


# # Print the response
# print(response_text)

Loading
Loading