NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import tkinter as tk
import speech_recognition as sr
from keras.models import load_model
import numpy as np
import joblib

# Create tkinter window
root = tk.Tk()
root.title("Emoji Feedback")

# Load the scaler
scaler = joblib.load('your_scaler.pkl')

# Load the trained model
model = joblib.load('your_model.pkl')

# Define emotion labels
emotion_labels = {
0: 'neutral',
1: 'calm',
2: 'happy',
3: 'sad',
4: 'angry',
5: 'fear',
6: 'disgust',
7: 'surprise'
}

# Define emojis
emojis = {
'neutral': "😐",
'calm': "😌",
'happy': "😄",
'sad': "😢",
'angry': "😡",
'fear': "😨",
'disgust': "🤢",
'surprise': "😯"
}

# Function to handle button click event
def predict_emotion():
user_input = input_entry.get()
if user_input.strip() == "":
predict_emotion_from_voice()
else:
features = preprocess_input(user_input)
make_prediction(features)

# Function to handle voice input
def predict_emotion_from_voice():
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
audio = recognizer.listen(source)
print("Processing...")
try:
user_input = recognizer.recognize_google(audio)
input_entry.delete(0, tk.END)
input_entry.insert(0, user_input)
features = preprocess_input(user_input)
make_prediction(features)
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))

# Function to preprocess input
def preprocess_input(input_text):
# Here, you should perform your feature extraction process
# Ensure that the features have the correct shape and format

# Example: Dummy feature extraction for demonstration
features = [[len(input_text)]] # Replace this with your actual feature extraction process

return features

# Function to make prediction
def make_prediction(features):
# Scale the features using the scaler
scaled_features = scaler.transform(features)

# Make prediction using the model
prediction = model.predict(scaled_features)

# Get the predicted emotion label
predicted_emotion = np.argmax(prediction)
predicted_emotion_label = emotion_labels[predicted_emotion]

# Update the emoji label with the corresponding emoji
emoji_label.configure(text=emojis[predicted_emotion_label])

# Create and place input elements
input_label = tk.Label(root, text="Enter text (or press button for voice input):")
input_label.pack()

input_entry = tk.Entry(root)
input_entry.pack()

# Create and place predict button
predict_button = tk.Button(root, text="Predict", command=predict_emotion)
predict_button.pack()

# Create and place emoji label
emoji_label = tk.Label(root, font=("Segoe UI Emoji", 50))
emoji_label.pack()

# Run the tkinter event loop
root.mainloop()
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.