JACOBBBB commited on
Commit
f617e67
1 Parent(s): 7fb0b21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -30,21 +30,26 @@ if st.button("Analyze and Respond"):
30
  # Check user's guess against the analysis
31
  guess_is_correct = (user_guess.upper() == label)
32
  guess_feedback = "Right" if guess_is_correct else "Wrong"
33
- feedback_text = f"Your guess was {guess_feedback}. The actual sentiment of the review is {label}."
 
 
 
34
 
 
35
  # Generate audio feedback for the guess
36
  feedback_audio = text_to_audio(feedback_text)
37
  st.audio(feedback_audio['audio'], format='audio/wav', sample_rate=feedback_audio['sampling_rate'])
38
 
39
- # Generate audio of the review
40
- review_audio = text_to_audio(f"Audio of the review for practice your listening: {review}")
41
- st.audio(review_audio['audio'], format='audio/wav', sample_rate=review_audio['sampling_rate'])
42
-
43
  # Display the sentiment analysis result and feedback
44
  st.write("Predicted Sentiment:", label)
45
  st.write("Confidence Score:", f"{score * 100:.2f}%")
46
  st.write(feedback_text)
47
 
 
 
 
 
 
48
  # Generate a professional response based on the review and its sentiment
49
  if label == "POSITIVE":
50
  prompt = "Thank you for sharing your experience and choosing our hotel. We are glad that you had a wonderful stay with us."
@@ -54,4 +59,13 @@ if st.button("Analyze and Respond"):
54
  professional_response = response_generator(prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
55
 
56
  # Display the generated professional response
57
- st.write("Generated Professional Response:", professional_response)
 
 
 
 
 
 
 
 
 
 
30
  # Check user's guess against the analysis
31
  guess_is_correct = (user_guess.upper() == label)
32
  guess_feedback = "Right" if guess_is_correct else "Wrong"
33
+ if guess_feedback = "Right"
34
+ feedback_text = f"Congratulations! Your guess was {guess_feedback}! The actual sentiment of the review is {label}."
35
+ else:
36
+ feedback_text = f"Sorry! Your guess was {guess_feedback}! The actual sentiment of the review is {label}."
37
 
38
+
39
  # Generate audio feedback for the guess
40
  feedback_audio = text_to_audio(feedback_text)
41
  st.audio(feedback_audio['audio'], format='audio/wav', sample_rate=feedback_audio['sampling_rate'])
42
 
 
 
 
 
43
  # Display the sentiment analysis result and feedback
44
  st.write("Predicted Sentiment:", label)
45
  st.write("Confidence Score:", f"{score * 100:.2f}%")
46
  st.write(feedback_text)
47
 
48
+ # Generate audio of the review
49
+ st.write("Audio of the review for practice your listening")
50
+ review_audio = text_to_audio(f"Audio of the review for practice your listening: {review}")
51
+ st.audio(review_audio['audio'], format='audio/wav', sample_rate=review_audio['sampling_rate'])
52
+
53
  # Generate a professional response based on the review and its sentiment
54
  if label == "POSITIVE":
55
  prompt = "Thank you for sharing your experience and choosing our hotel. We are glad that you had a wonderful stay with us."
 
59
  professional_response = response_generator(prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
60
 
61
  # Display the generated professional response
62
+ st.write("Generated Professional Response:", professional_response)
63
+
64
+ # Text input for user to enter their own response
65
+ user_response = st.text_area("Enter your response to the review", "")
66
+
67
+ # Button to submit response
68
+ if st.button("Submit Response"):
69
+ if user_response:
70
+ st.session_state['responses'].append(user_response)
71
+ st.success("Your response has been recorded for the competition!")