Commit
·
5aaa692
1
Parent(s):
af4ca4c
Modified the example sentences and add utils and pkl file for organised and clean code
Browse files- __pycache__/utils.cpython-310.pyc +0 -0
- app.py +49 -323
- tts_data.pickle +3 -0
- utils.py +124 -0
__pycache__/utils.cpython-310.pyc
ADDED
|
Binary file (4.6 kB). View file
|
|
|
app.py
CHANGED
|
@@ -17,323 +17,43 @@ import time
|
|
| 17 |
import io
|
| 18 |
from dotenv import load_dotenv
|
| 19 |
from S3_bucket import AWS
|
|
|
|
|
|
|
| 20 |
|
|
|
|
|
|
|
| 21 |
load_dotenv()
|
|
|
|
| 22 |
TTS_secret_key=os.getenv("TTS_SECRET_KEY")
|
| 23 |
TTS_URL=os.getenv('TTS_URL')
|
|
|
|
|
|
|
| 24 |
aws=AWS()
|
| 25 |
|
| 26 |
-
js = """
|
| 27 |
-
function createGradioAnimation() {
|
| 28 |
-
// Create animation container
|
| 29 |
-
var container = document.createElement('div');
|
| 30 |
-
container.id = 'gradio-animation';
|
| 31 |
-
container.style.fontSize = '2em';
|
| 32 |
-
container.style.fontWeight = 'bold';
|
| 33 |
-
container.style.textAlign = 'center';
|
| 34 |
-
container.style.marginBottom = '20px';
|
| 35 |
-
container.style.color = '#ffffff';
|
| 36 |
-
|
| 37 |
-
// Animated text creation
|
| 38 |
-
var text = '🗣️ ORI Text-to-Speech (TTS) Showcase 🎙️';
|
| 39 |
-
for (var i = 0; i < text.length; i++) {
|
| 40 |
-
(function(i){
|
| 41 |
-
setTimeout(function(){
|
| 42 |
-
var letter = document.createElement('span');
|
| 43 |
-
letter.style.opacity = '0';
|
| 44 |
-
letter.style.transition = 'opacity 0.3s';
|
| 45 |
-
letter.innerText = text[i];
|
| 46 |
-
|
| 47 |
-
container.appendChild(letter);
|
| 48 |
-
|
| 49 |
-
setTimeout(function() {
|
| 50 |
-
letter.style.opacity = '1';
|
| 51 |
-
}, 25);
|
| 52 |
-
}, i * 100);
|
| 53 |
-
})(i);
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
// Add container to gradio
|
| 57 |
-
var gradioContainer = document.querySelector('.gradio-container');
|
| 58 |
-
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
| 59 |
-
|
| 60 |
-
// Background styling
|
| 61 |
-
document.body.style.backgroundColor = '#1a1a1a';
|
| 62 |
-
gradioContainer.style.backgroundColor = '#1a1a1a';
|
| 63 |
-
|
| 64 |
-
// Input containers styling
|
| 65 |
-
var inputContainers = document.querySelectorAll('.input-container');
|
| 66 |
-
inputContainers.forEach(function(container) {
|
| 67 |
-
container.style.backgroundColor = '#2a2a2a';
|
| 68 |
-
container.style.border = '1px solid #333';
|
| 69 |
-
container.style.borderRadius = '8px';
|
| 70 |
-
container.style.padding = '20px';
|
| 71 |
-
container.style.marginBottom = '20px';
|
| 72 |
-
});
|
| 73 |
-
|
| 74 |
-
// Generate button styling
|
| 75 |
-
var generateButton = document.querySelector('.b');
|
| 76 |
-
if (generateButton) {
|
| 77 |
-
generateButton.style.backgroundColor = '#ea580c';
|
| 78 |
-
generateButton.style.color = 'white';
|
| 79 |
-
generateButton.style.border = 'none';
|
| 80 |
-
generateButton.style.borderRadius = '4px';
|
| 81 |
-
generateButton.style.padding = '10px 20px';
|
| 82 |
-
generateButton.style.width = '100%';
|
| 83 |
-
generateButton.style.cursor = 'pointer';
|
| 84 |
-
generateButton.style.transition = 'background-color 0.3s';
|
| 85 |
-
|
| 86 |
-
generateButton.addEventListener('mouseenter', function () {
|
| 87 |
-
generateButton.style.backgroundColor = '#f9923c';
|
| 88 |
-
});
|
| 89 |
-
generateButton.addEventListener('mouseleave', function () {
|
| 90 |
-
generateButton.style.backgroundColor = '#ea580c';
|
| 91 |
-
});
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
// Dropdowns styling
|
| 95 |
-
var dropdowns = document.querySelectorAll('select');
|
| 96 |
-
dropdowns.forEach(function(dropdown) {
|
| 97 |
-
dropdown.style.backgroundColor = '#2a2a2a';
|
| 98 |
-
dropdown.style.color = 'white';
|
| 99 |
-
dropdown.style.border = '1px solid #333';
|
| 100 |
-
});
|
| 101 |
-
|
| 102 |
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
// Style individual radio options
|
| 110 |
-
var radioOptions = ratingContainer.querySelectorAll('label');
|
| 111 |
-
radioOptions.forEach(function(option) {
|
| 112 |
-
option.style.color = '#ffffff';
|
| 113 |
-
option.style.cursor = 'pointer';
|
| 114 |
-
option.style.transition = 'transform 0.2s';
|
| 115 |
-
option.style.flex = '1'; // Make each option take equal space
|
| 116 |
-
option.style.textAlign = 'center'; // Center the content
|
| 117 |
-
option.style.display = 'flex';
|
| 118 |
-
option.style.justifyContent = 'center';
|
| 119 |
-
option.style.alignItems = 'center';
|
| 120 |
-
option.style.padding = '10px';
|
| 121 |
-
|
| 122 |
-
// Add hover effect
|
| 123 |
-
option.addEventListener('mouseenter', function() {
|
| 124 |
-
this.style.transform = 'scale(1.1)';
|
| 125 |
-
});
|
| 126 |
-
|
| 127 |
-
option.addEventListener('mouseleave', function() {
|
| 128 |
-
this.style.transform = 'scale(1)';
|
| 129 |
-
});
|
| 130 |
-
});
|
| 131 |
-
|
| 132 |
-
// Style the radio inputs
|
| 133 |
-
var radioInputs = ratingContainer.querySelectorAll('input[type="radio"]');
|
| 134 |
-
radioInputs.forEach(function(input) {
|
| 135 |
-
input.style.margin = '0 8px 0 0'; // Add some space between radio button and stars
|
| 136 |
-
});
|
| 137 |
-
}
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
""
|
| 142 |
-
|
| 143 |
-
js_reload = """
|
| 144 |
-
function reloadPage() {
|
| 145 |
-
setTimeout(function() {
|
| 146 |
-
window.location.reload();
|
| 147 |
-
}, 5000); // Reload after 5 seconds
|
| 148 |
-
}
|
| 149 |
-
"""
|
| 150 |
-
|
| 151 |
-
# language_codes = {
|
| 152 |
-
# "English": "en",
|
| 153 |
-
# "Hindi": "hi",
|
| 154 |
-
# "Tamil": "ta",
|
| 155 |
-
# "Telugu": "te",
|
| 156 |
-
# "Marathi": "mr",
|
| 157 |
-
# "Malayalam": "ml",
|
| 158 |
-
# "Punjabi": "pa",
|
| 159 |
-
# "Odia": "or",
|
| 160 |
-
# "Bengali": "bn"
|
| 161 |
-
# }
|
| 162 |
-
|
| 163 |
-
language_codes = {
|
| 164 |
-
"English": "hi",
|
| 165 |
-
"Hindi": "hi",
|
| 166 |
-
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
language_sentences = {
|
| 171 |
-
"English": [
|
| 172 |
-
"The best time to plant a tree was 20 years ago. The second best time is now.",
|
| 173 |
-
"Strive not to be a success, but rather to be of value.",
|
| 174 |
-
"Two roads diverged in a wood, and I took the one less traveled by, and that has made all the difference.",
|
| 175 |
-
"The only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle.",
|
| 176 |
-
"In three words I can sum up everything I've learned about life: it goes on.",
|
| 177 |
-
"The future belongs to those who believe in the beauty of their dreams.",
|
| 178 |
-
"It is during our darkest moments that we must focus to see the light.",
|
| 179 |
-
"Whatever you are, be a good one.",
|
| 180 |
-
"The journey of a thousand miles begins with a single step.",
|
| 181 |
-
"You miss 100% of the shots you don't take.",
|
| 182 |
-
"Change your thoughts and you change your world.",
|
| 183 |
-
"If you want to live a happy life, tie it to a goal, not to people or things.",
|
| 184 |
-
"The greatest glory in living lies not in never falling, but in rising every time we fall.",
|
| 185 |
-
"Life is really simple, but we insist on making it complicated.",
|
| 186 |
-
"The best revenge is massive success.",
|
| 187 |
-
"The journey of a thousand miles begins with a single step.",
|
| 188 |
-
"In three words I can sum up everything I've learned about life: it goes on.",
|
| 189 |
-
"The future belongs to those who believe in the beauty of their dreams.",
|
| 190 |
-
"It is during our darkest moments that we must focus to see the light.",
|
| 191 |
-
"If you want to live a happy life, tie it to a goal, not to people or things.",
|
| 192 |
-
"Believe you can and you're halfway there.",
|
| 193 |
-
"When one door of happiness closes, another opens.",
|
| 194 |
-
"The purpose of our lives is to be happy.",
|
| 195 |
-
"Life isn't about finding yourself, it's about creating yourself.",
|
| 196 |
-
"Success is not final, failure is not fatal: it is the courage to continue that counts.",
|
| 197 |
-
"Our greatest fear should not be of failure but of succeeding at things in life that don't really matter. When you realize there is nothing lacking, the whole world belongs to you. It's important to remember that we all have magic inside us, and it's important to remember that we all have magic inside us.",
|
| 198 |
-
"Life is not measured by the number of breaths we take, but by the moments that take our breath away. The purpose of life is not to be happy. It is to be useful, to be honorable, to be compassionate, to have it make some difference that you have lived and lived well.",
|
| 199 |
-
"The most difficult thing is the decision to act, the rest is merely tenacity. The fears we don't face become our limits. Happiness is not something ready-made. It comes from your own actions. You have within you right now, everything you need to deal with whatever the world can throw at you.",
|
| 200 |
-
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood.",
|
| 201 |
-
"Your time is limited, don't waste it living someone else's life. Don't be trapped by dogma - which is living with the results of other people's thinking. Don't let the noise of other's opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition.",
|
| 202 |
-
"There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle. For every minute you are angry you lose sixty seconds of happiness. The two most important days in your life are the day you are born and the day you find out why.",
|
| 203 |
-
"Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate: only love can do that. We must accept finite disappointment, but never lose infinite hope. In the end, we will remember not the words of our enemies, but the silence of our friends.",
|
| 204 |
-
"Education is the most powerful weapon which you can use to change the world. A good head and a good heart are always a formidable combination. It always seems impossible until it's done. For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others."
|
| 205 |
-
],
|
| 206 |
-
"Hindi": [
|
| 207 |
-
"कल किसने देखा है, तो आज क्यों खोएं?",
|
| 208 |
-
"खुशी एक मनोदशा है, कोई गंतव्य नहीं।",
|
| 209 |
-
"सफलता अंतिम नहीं है, असफलता घातक नहीं है: यह जारी रखने का साहस है जो मायने रखता है।",
|
| 210 |
-
"जीवन एक दर्पण है: यह आप पर तभी मुस्कुराएगा जब ���प उस पर मुस्कुराएंगे।",
|
| 211 |
-
"यदि आप चाहते हैं कि आपके सपने सच हों, तो पहली बात आपको जागना है।",
|
| 212 |
-
"आप जो कुछ भी हैं, एक अच्छे बनो।",
|
| 213 |
-
"कल से सीखें, आज के लिए जिएं, कल के लिए आशा करें।",
|
| 214 |
-
"एक हजार मील की यात्रा एक कदम से शुरू होती है।",
|
| 215 |
-
"आप उन 100% शॉट्स को याद करते हैं जिन्हें आप नहीं लेते हैं।",
|
| 216 |
-
"अपने विचारों को बदलें और आप अपनी दुनिया बदल दें।",
|
| 217 |
-
"यदि आप एक खुशहाल जीवन जीना चाहते हैं, तो इसे एक लक्ष्य से बांधें, लोगों या चीजों से नहीं।",
|
| 218 |
-
"जीने में सबसे बड़ी महिमा कभी न गिरने में नहीं है, बल्कि हर बार गिरने पर उठने में है।",
|
| 219 |
-
"जीवन वास्तव में सरल है, लेकिन हम इसे जटिल बनाने पर जोर देते हैं।",
|
| 220 |
-
"सबसे अच्छा बदला भारी सफलता है।",
|
| 221 |
-
"जो होता है अच्छे के लिए होता है।",
|
| 222 |
-
"सफलता अंतिम नहीं है, असफलता घातक नहीं है: यह जारी रखने का साहस है जो मायने रखता है। इसलिए कभी भी हार न मानें, कभी भी निराश न हों। जीवन एक संघर्ष है जिसमें हर कदम पर नई चुनौतियां आती हैं, लेकिन इन्हीं चुनौतियों से हम मजबूत होते हैं और अपने लक्ष्य की ओर बढ़ते हैं। असफलता सिर्फ एक अनुभव है जो हमें बेहतर बनाता है।",
|
| 223 |
-
"जीवन एक दर्पण है: यह आप पर तभी मुस्कुराएगा जब आप उस पर मुस्कुराएंगे। हर सुबह एक नई शुरुआत है, एक नया अवसर है कुछ नया करने का, कुछ बेहतर करने का। जीवन की खूबसूरती इसके उतार-चढ़ाव में है। दुख के बाद सुख और अंधेरे के बाद उजाला जीवन का नियम है। इसलिए हमेशा आशावादी रहें और अपने सपनों को जीवित रखें।",
|
| 224 |
-
"यदि आप चाहते हैं कि आपके सपने सच हों, तो पहली बात आपको जागना है। सपने देखना ही काफी नहीं है, उन्हें पूरा करने के लिए कड़ी मेहनत और दृढ़ संकल्प की आवश्यकता होती है। कोई भी महान कार्य एक दिन में नहीं होता, यह धीरे-धीरे छोटे-छोटे प्रयासों से बनता है। इसलिए धैर्य रखें और अपने लक्ष्य की ओर निरंतर बढ़ते रहें।",
|
| 225 |
-
"यदि आप एक खुशहाल जीवन जीना चाहते हैं, तो इसे एक लक्ष्य से बांधें, लोगों या चीजों से नहीं। वास्तविक खुशी अंदर से आती है, बाहरी चीजों से नहीं। धन, प्रसिद्धि या भौतिक वस्तुएं क्षणिक संतुष्टि दे सकती हैं, लेकिन स्थायी खुशी आत्म-संतुष्टि और दूसरों की सेवा से आती है। जीवन का मूल्य इसमें है कि आपने कितना कमाया नहीं, बल्कि आपने कितने लोगों के जीवन को प्रभावित किया।",
|
| 226 |
-
"जीने में सबसे बड़ी महिमा कभी न गिरन��� में नहीं है, बल्कि हर बार गिरने पर उठने में है। हर असफलता एक सीख है, हर गलती एक अनुभव। जो व्यक्ति अपनी गलतियों से सीखता है, वह जीवन में आगे बढ़ता है। जबकि वह जो अपनी गलतियों को दोहराता है, वहीं का वहीं रह जाता है। इसलिए कभी भी गिरने से न डरें, बल्कि गिरकर न उठने से डरें।",
|
| 227 |
-
"मनुष्य के जीवन का उद्देश्य केवल अपने स्वार्थ की पूर्ति नहीं होना चाहिए, बल्कि समाज और राष्ट्र के प्रति भी उसका कर्तव्य होना चाहिए। जीवन का सच्चा आनंद दूसरों की सेवा में है, क्योंकि जब हम दूसरों को खुशी देते हैं तो हमारी आत्मा को भी शांति मिलती है। यह संसार एक बड़ा परिवार है जिसमें हर व्यक्ति का अपना महत्व है और हर किसी को सम्मान का अधिकार है।",
|
| 228 |
-
"प्रकृति हमारी माँ है और हमें उसकी रक्षा करनी चाहिए। हमारा पर्यावरण हमारा जीवन है, और इसे संरक्षित करना हमारा कर्तव्य है। प्रकृति ने हमें हवा, पानी, भोजन और जीवन दिया है, और बदले में हमें उसकी देखभाल करनी चाहिए। पेड़-पौधे लगाएं, पानी बचाएं, प्रदूषण कम करें और पृथ्वी को एक स्वस्थ और सुरक्षित स्थान बनाएं। आने वाली पीढ़ियों के लिए एक बेहतर विश्व छोड़ना हमारा उत्तरदायित्व है।"
|
| 229 |
-
],
|
| 230 |
-
"Tamil": [
|
| 231 |
-
"வாழ்க்கை ஒரு பயணம்.",
|
| 232 |
-
"நேரம் பொன் போன்றது.",
|
| 233 |
-
"கற்றது கைமண் அளவு, கல்லாதது உலகளவு.",
|
| 234 |
-
"தொடர்ந்து முயற்சி செய்.",
|
| 235 |
-
"வெற்றி பெற வேண்டும்."
|
| 236 |
-
],
|
| 237 |
-
"Telugu": [
|
| 238 |
-
"జీవితం ఒక ప్రయాణం.",
|
| 239 |
-
"సమయం విలువైనది.",
|
| 240 |
-
"విజయానికి కష్టపడాలి.",
|
| 241 |
-
"నేటి పని నేడే చేయాలి.",
|
| 242 |
-
"ప్రతి సమస్యకు పరిష్కారం ఉంటుంది."
|
| 243 |
-
],
|
| 244 |
-
"Marathi": [
|
| 245 |
-
"जीवन हे एक प्रवास आहे.",
|
| 246 |
-
"वेळ हाच खरा धन आहे.",
|
| 247 |
-
"प्रयत्ने वाळूचे कण रत्न होतात.",
|
| 248 |
-
"आजचे काम उद्यावर टाकू नका.",
|
| 249 |
-
"शिक्षणाशिवाय जीवन अपूर्ण आहे."
|
| 250 |
-
],
|
| 251 |
-
"Malayalam": [
|
| 252 |
-
"ജീവിതം ഒരു യാത്രയാണ്.",
|
| 253 |
-
"സമയം വിലപ്പെട്ടതാണ്.",
|
| 254 |
-
"വിജയത്തിന് കഠിനാധ്വാനം ആവശ്യമാണ്.",
|
| 255 |
-
"ഇന്നത്തെ ജോലി നാളത്തേക്ക് മാറ്റരുത്.",
|
| 256 |
-
"എല്ലാ പ്രശ്നങ്ങൾക്കും പരിഹാരമുണ്ട്."
|
| 257 |
-
],
|
| 258 |
-
"Punjabi": [
|
| 259 |
-
"ਜਿੰਦਗੀ ਇੱਕ ਸਫ਼ਰ ਹੈ।",
|
| 260 |
-
"ਸਮਾਂ ਬਹੁਤ ਕੀਮਤੀ ਹੈ।",
|
| 261 |
-
"ਮਿਹਨਤ ਸਫਲਤਾ ਦੀ ਕੁੰਜੀ ਹੈ।",
|
| 262 |
-
"ਅੱਜ ਦਾ ਕੰਮ ਕੱਲ੍ਹ ਤੇ ਨਾ ਛੱਡੋ।",
|
| 263 |
-
"ਹਰ ਮੁਸ਼ਕਿਲ ਦਾ ਹੱਲ ਹੈ।"
|
| 264 |
-
],
|
| 265 |
-
"Odia": [
|
| 266 |
-
"ଜୀବନ ଏକ ଯାତ୍ରା।",
|
| 267 |
-
"ସମୟ ବହୁତ ମୂଲ୍ୟବାନ।",
|
| 268 |
-
"ପରିଶ୍ରମ ସଫଳତାର ଚାବିକାଠି।",
|
| 269 |
-
"ଆଜିର କାମ କାଲିକୁ ଛାଡନ୍ତୁ ନାହିଁ।",
|
| 270 |
-
"ପ୍ରତ୍ୟେକ ସମସ୍ୟାର ସମାଧାନ ଅଛି।"
|
| 271 |
-
],
|
| 272 |
-
"Bengali": [
|
| 273 |
-
"জীবন একট�� যাত্রা।",
|
| 274 |
-
"সময় খুব মূল্যবান।",
|
| 275 |
-
"পরিশ্রম সফলতার চাবিকাঠি।",
|
| 276 |
-
"আজকের কাজ আজকেই করুন।",
|
| 277 |
-
"প্রতিটি সমস্যার সমাধান আছে।"
|
| 278 |
-
]
|
| 279 |
-
}
|
| 280 |
-
|
| 281 |
-
languages = list(language_codes.keys())
|
| 282 |
-
languages.sort()
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
agents = {
|
| 287 |
-
# 'Amy': 'Amy',
|
| 288 |
-
# 'Morgan': 'Morgan',
|
| 289 |
-
# 'Amit': 'Amit',
|
| 290 |
-
'Ankur': 'Ankur',
|
| 291 |
-
'Salima': 'Salima',
|
| 292 |
-
'Sufi': 'Sufi',
|
| 293 |
-
'Aliyah': 'Aliyah',
|
| 294 |
-
'Jasmine': 'Jasmine',
|
| 295 |
-
'Fatima': 'Fatima',
|
| 296 |
-
'Harry': 'Harry',
|
| 297 |
-
'Sally': 'Sally',
|
| 298 |
-
'Neha': 'Neha',
|
| 299 |
-
'Soniya': 'Soniya_1',
|
| 300 |
-
'Dev': 'Modi',
|
| 301 |
-
# 'Alisha': 'Alisha',
|
| 302 |
-
'Sara': 'Sara',
|
| 303 |
-
'Susan': 'Susan',
|
| 304 |
-
# 'Carol': 'Carol',
|
| 305 |
-
# 'Arjun': 'Arjun',
|
| 306 |
-
'Aditi': 'Amy_neutral_1',
|
| 307 |
-
'Anshika': 'Amy_neutral_2',
|
| 308 |
-
# 'Anika': 'Amy_negative_1',
|
| 309 |
-
'Ishita': 'Amy_negative_2',
|
| 310 |
-
# 'Riya': 'Amy_positive_1',
|
| 311 |
-
# 'Priya': 'Priya',
|
| 312 |
-
'Meera': 'Amy_positive_3',
|
| 313 |
-
'Nisha': 'Amy_neutral_3',
|
| 314 |
-
'Shruti': 'Amy_negative_3',
|
| 315 |
-
# 'Pooja': 'Pooja',
|
| 316 |
-
'Amrita': 'Amy_comforting_1',
|
| 317 |
-
'Prachi': 'Amy_excited_1',
|
| 318 |
-
# 'Maria': 'Maria',
|
| 319 |
-
# 'Rashmi': 'Rashmi',
|
| 320 |
-
# 'Kavita': 'Kavita',
|
| 321 |
-
# 'Jyoti': 'Jyoti',
|
| 322 |
-
# 'Kavya': 'Kavya',
|
| 323 |
-
}
|
| 324 |
agents_name=agents.keys()
|
| 325 |
|
|
|
|
| 326 |
def generate_session_id():
|
| 327 |
sd=str(uuid.uuid4())
|
| 328 |
print(f"New session started with session IDs: {sd}")
|
| 329 |
return sd
|
| 330 |
|
| 331 |
-
session_id=None
|
| 332 |
-
|
| 333 |
|
| 334 |
def get_random_sentence(language):
|
| 335 |
return random.choice(language_sentences[language])
|
| 336 |
|
|
|
|
| 337 |
def toggle_generate_button_state(choice, text_input, recording_data=None):
|
| 338 |
if not text_input.strip():
|
| 339 |
return gr.update(interactive=False)
|
|
@@ -354,7 +74,24 @@ def show_rating():
|
|
| 354 |
return gr.Slider(visible=True)
|
| 355 |
|
| 356 |
|
| 357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
|
| 359 |
def ensure_csv_exists(sep='|'):
|
| 360 |
s3_csv_file_key = "TTS_gradio/gradio_tts_feedback.csv"
|
|
@@ -386,6 +123,7 @@ def ensure_csv_exists(sep='|'):
|
|
| 386 |
print(f"TTS_feedback CSV already exists at {s3_csv_file_key}")
|
| 387 |
return s3_csv_file_key
|
| 388 |
|
|
|
|
| 389 |
def ensure_error_logs_csv_exists(sep='|'):
|
| 390 |
s3_csv_file_key = "TTS_gradio/gradio_tts_error_logs.csv"
|
| 391 |
exists = aws.check_if_exists(object_key=s3_csv_file_key)
|
|
@@ -415,6 +153,7 @@ def ensure_error_logs_csv_exists(sep='|'):
|
|
| 415 |
print(f"TTS_error_log CSV already exists at {s3_csv_file_key}")
|
| 416 |
return s3_csv_file_key
|
| 417 |
|
|
|
|
| 418 |
def log_initial_submission(code:int, session_id, language, input_method, agent_used, voice_path, text_input,
|
| 419 |
expressiveness=1.0, stability=100, clarity=1.0, speech_rate=1.0,
|
| 420 |
loudness=1.0, refine_generation=False, err_code=None, err_msg=None, sep='|'):
|
|
@@ -503,6 +242,7 @@ def log_initial_submission(code:int, session_id, language, input_method, agent_u
|
|
| 503 |
except Exception as e:
|
| 504 |
print(f"Error saving Error logging: {e}")
|
| 505 |
return f"Error: Could not save error data - {str(e)}"
|
|
|
|
| 506 |
|
| 507 |
def update_rating(session_id, rating, sep='|'):
|
| 508 |
try:
|
|
@@ -527,7 +267,7 @@ def update_rating(session_id, rating, sep='|'):
|
|
| 527 |
aws.s3.put_object(Key=s3_csv_file, Bucket=aws.bucket_name, Body=csv_buffer.getvalue())
|
| 528 |
|
| 529 |
print(f"Updated rating for session {session_id} to {star_dict[rating]}")
|
| 530 |
-
return f"Your rating of {star_dict[rating]} submitted successfully!!"
|
| 531 |
else:
|
| 532 |
print(f"Session {session_id} not found in the CSV file")
|
| 533 |
return "Error: Session not found"
|
|
@@ -538,20 +278,6 @@ def update_rating(session_id, rating, sep='|'):
|
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
-
|
| 542 |
-
def save_generated_audio(audio_data,session_id):
|
| 543 |
-
s3_folder = "TTS_gradio/generated_audios"
|
| 544 |
-
s3_key = f"{s3_folder}/{session_id}_{uuid.uuid4()}.wav"
|
| 545 |
-
|
| 546 |
-
try:
|
| 547 |
-
audio_byte_obj=audio_data.tobytes()
|
| 548 |
-
audio_file = io.BytesIO(audio_byte_obj)
|
| 549 |
-
aws.s3_upload_wav(obj=audio_file,s3_key=s3_key)
|
| 550 |
-
print(f"Saved generated audio to: {s3_key}")
|
| 551 |
-
return s3_key
|
| 552 |
-
except Exception as e:
|
| 553 |
-
print(f"Error saving generated audio: {e}")
|
| 554 |
-
return None
|
| 555 |
|
| 556 |
def increase_volume(audio_array, factor=10):
|
| 557 |
"""
|
|
@@ -1016,12 +742,12 @@ def tts_tab():
|
|
| 1016 |
visible=False,
|
| 1017 |
interactive=True,
|
| 1018 |
container=True,
|
| 1019 |
-
elem_id="rating-stars"
|
| 1020 |
)
|
| 1021 |
with gr.Column():
|
| 1022 |
submit_button = gr.Button("📤 Submit Rating", elem_classes='button', visible=False, variant='primary')
|
| 1023 |
|
| 1024 |
-
rating_message = gr.Textbox(label="", visible=False)
|
| 1025 |
|
| 1026 |
|
| 1027 |
# Function to validate text length and update character count
|
|
@@ -1101,10 +827,9 @@ def tts_tab():
|
|
| 1101 |
outputs=rating_message,
|
| 1102 |
show_progress='full'
|
| 1103 |
).then(
|
| 1104 |
-
fn=lambda: gr.Textbox(visible=True, lines=
|
| 1105 |
-
outputs=rating_message
|
| 1106 |
-
|
| 1107 |
-
fn=None,
|
| 1108 |
|
| 1109 |
)
|
| 1110 |
|
|
@@ -1117,13 +842,14 @@ def tts_tab():
|
|
| 1117 |
|
| 1118 |
def about_tab():
|
| 1119 |
with gr.Column(elem_classes="container"):
|
|
|
|
|
|
|
| 1120 |
return gr.Markdown("""
|
| 1121 |
-
# 🚀 Welcome to ORI Text-to-Speech
|
| 1122 |
|
| 1123 |
-
## 🌟 About Our Technology
|
| 1124 |
Welcome to the next generation of Text-to-Speech technology! Our cutting-edge system combines advanced AI with neural voice synthesis to deliver unprecedented quality and naturalness in speech generation.
|
| 1125 |
|
| 1126 |
-
|
| 1127 |
|
| 1128 |
#### 🎯 Core Capabilities
|
| 1129 |
* Enterprise-grade voice models
|
|
|
|
| 17 |
import io
|
| 18 |
from dotenv import load_dotenv
|
| 19 |
from S3_bucket import AWS
|
| 20 |
+
from utils import js, js_reload
|
| 21 |
+
import pickle
|
| 22 |
|
| 23 |
+
js=str(js)
|
| 24 |
+
js_reload=str(js_reload)
|
| 25 |
load_dotenv()
|
| 26 |
+
|
| 27 |
TTS_secret_key=os.getenv("TTS_SECRET_KEY")
|
| 28 |
TTS_URL=os.getenv('TTS_URL')
|
| 29 |
+
|
| 30 |
+
|
| 31 |
aws=AWS()
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
sep='|'
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
with open('tts_data.pickle', 'rb') as f:
|
| 38 |
+
loaded_data = pickle.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
language_sentences = loaded_data["language_sentences"]
|
| 41 |
+
languages = loaded_data["languages"]
|
| 42 |
+
agents = loaded_data["agents"]
|
| 43 |
+
language_codes=loaded_data['language_codes']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
agents_name=agents.keys()
|
| 45 |
|
| 46 |
+
|
| 47 |
def generate_session_id():
|
| 48 |
sd=str(uuid.uuid4())
|
| 49 |
print(f"New session started with session IDs: {sd}")
|
| 50 |
return sd
|
| 51 |
|
|
|
|
|
|
|
| 52 |
|
| 53 |
def get_random_sentence(language):
|
| 54 |
return random.choice(language_sentences[language])
|
| 55 |
|
| 56 |
+
|
| 57 |
def toggle_generate_button_state(choice, text_input, recording_data=None):
|
| 58 |
if not text_input.strip():
|
| 59 |
return gr.update(interactive=False)
|
|
|
|
| 74 |
return gr.Slider(visible=True)
|
| 75 |
|
| 76 |
|
| 77 |
+
|
| 78 |
+
def save_generated_audio(audio_data,session_id):
|
| 79 |
+
s3_folder = "TTS_gradio/generated_audios"
|
| 80 |
+
s3_key = f"{s3_folder}/{session_id}_{uuid.uuid4()}.wav"
|
| 81 |
+
|
| 82 |
+
try:
|
| 83 |
+
audio_byte_obj=audio_data.tobytes()
|
| 84 |
+
audio_file = io.BytesIO(audio_byte_obj)
|
| 85 |
+
aws.s3_upload_wav(obj=audio_file,s3_key=s3_key)
|
| 86 |
+
print(f"Saved generated audio to: {s3_key}")
|
| 87 |
+
return s3_key
|
| 88 |
+
except Exception as e:
|
| 89 |
+
print(f"Error saving generated audio: {e}")
|
| 90 |
+
return None
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
|
| 96 |
def ensure_csv_exists(sep='|'):
|
| 97 |
s3_csv_file_key = "TTS_gradio/gradio_tts_feedback.csv"
|
|
|
|
| 123 |
print(f"TTS_feedback CSV already exists at {s3_csv_file_key}")
|
| 124 |
return s3_csv_file_key
|
| 125 |
|
| 126 |
+
|
| 127 |
def ensure_error_logs_csv_exists(sep='|'):
|
| 128 |
s3_csv_file_key = "TTS_gradio/gradio_tts_error_logs.csv"
|
| 129 |
exists = aws.check_if_exists(object_key=s3_csv_file_key)
|
|
|
|
| 153 |
print(f"TTS_error_log CSV already exists at {s3_csv_file_key}")
|
| 154 |
return s3_csv_file_key
|
| 155 |
|
| 156 |
+
|
| 157 |
def log_initial_submission(code:int, session_id, language, input_method, agent_used, voice_path, text_input,
|
| 158 |
expressiveness=1.0, stability=100, clarity=1.0, speech_rate=1.0,
|
| 159 |
loudness=1.0, refine_generation=False, err_code=None, err_msg=None, sep='|'):
|
|
|
|
| 242 |
except Exception as e:
|
| 243 |
print(f"Error saving Error logging: {e}")
|
| 244 |
return f"Error: Could not save error data - {str(e)}"
|
| 245 |
+
|
| 246 |
|
| 247 |
def update_rating(session_id, rating, sep='|'):
|
| 248 |
try:
|
|
|
|
| 267 |
aws.s3.put_object(Key=s3_csv_file, Bucket=aws.bucket_name, Body=csv_buffer.getvalue())
|
| 268 |
|
| 269 |
print(f"Updated rating for session {session_id} to {star_dict[rating]}")
|
| 270 |
+
return f"Your rating of {star_dict[rating]} submitted successfully!!\nThank you for your feedback!!"
|
| 271 |
else:
|
| 272 |
print(f"Session {session_id} not found in the CSV file")
|
| 273 |
return "Error: Session not found"
|
|
|
|
| 278 |
|
| 279 |
|
| 280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
def increase_volume(audio_array, factor=10):
|
| 283 |
"""
|
|
|
|
| 742 |
visible=False,
|
| 743 |
interactive=True,
|
| 744 |
container=True,
|
| 745 |
+
elem_id="rating-stars",
|
| 746 |
)
|
| 747 |
with gr.Column():
|
| 748 |
submit_button = gr.Button("📤 Submit Rating", elem_classes='button', visible=False, variant='primary')
|
| 749 |
|
| 750 |
+
rating_message = gr.Textbox(label="", visible=False,lines=2)
|
| 751 |
|
| 752 |
|
| 753 |
# Function to validate text length and update character count
|
|
|
|
| 827 |
outputs=rating_message,
|
| 828 |
show_progress='full'
|
| 829 |
).then(
|
| 830 |
+
fn=lambda: gr.Textbox(visible=True, lines=2),
|
| 831 |
+
outputs=rating_message,
|
| 832 |
+
show_progress='full'
|
|
|
|
| 833 |
|
| 834 |
)
|
| 835 |
|
|
|
|
| 842 |
|
| 843 |
def about_tab():
|
| 844 |
with gr.Column(elem_classes="container"):
|
| 845 |
+
gr.Markdown('<div style="text-align: center; font-size: 2.4em;"> 🚀 Welcome to ORI Text-to-Speech </div>')
|
| 846 |
+
|
| 847 |
return gr.Markdown("""
|
|
|
|
| 848 |
|
| 849 |
+
## 🌟 About Our Technology :
|
| 850 |
Welcome to the next generation of Text-to-Speech technology! Our cutting-edge system combines advanced AI with neural voice synthesis to deliver unprecedented quality and naturalness in speech generation.
|
| 851 |
|
| 852 |
+
## ✨ Key Features :
|
| 853 |
|
| 854 |
#### 🎯 Core Capabilities
|
| 855 |
* Enterprise-grade voice models
|
tts_data.pickle
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a54cb2ee276e0adf0e4a8a7eaa7a368998c8d3969d766f3c8b9ce86ab4df716
|
| 3 |
+
size 16738
|
utils.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
js = """
|
| 2 |
+
function createGradioAnimation() {
|
| 3 |
+
// Create animation container
|
| 4 |
+
var container = document.createElement('div');
|
| 5 |
+
container.id = 'gradio-animation';
|
| 6 |
+
container.style.fontSize = '2em';
|
| 7 |
+
container.style.fontWeight = 'bold';
|
| 8 |
+
container.style.textAlign = 'center';
|
| 9 |
+
container.style.marginBottom = '20px';
|
| 10 |
+
container.style.color = '#ffffff';
|
| 11 |
+
|
| 12 |
+
// Animated text creation
|
| 13 |
+
var text = '🗣️ ORI Text-to-Speech (TTS) Showcase 🎙️';
|
| 14 |
+
for (var i = 0; i < text.length; i++) {
|
| 15 |
+
(function(i){
|
| 16 |
+
setTimeout(function(){
|
| 17 |
+
var letter = document.createElement('span');
|
| 18 |
+
letter.style.opacity = '0';
|
| 19 |
+
letter.style.transition = 'opacity 0.3s';
|
| 20 |
+
letter.innerText = text[i];
|
| 21 |
+
|
| 22 |
+
container.appendChild(letter);
|
| 23 |
+
|
| 24 |
+
setTimeout(function() {
|
| 25 |
+
letter.style.opacity = '1';
|
| 26 |
+
}, 25);
|
| 27 |
+
}, i * 100);
|
| 28 |
+
})(i);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
// Add container to gradio
|
| 32 |
+
var gradioContainer = document.querySelector('.gradio-container');
|
| 33 |
+
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
| 34 |
+
|
| 35 |
+
// Background styling
|
| 36 |
+
document.body.style.backgroundColor = '#1a1a1a';
|
| 37 |
+
gradioContainer.style.backgroundColor = '#1a1a1a';
|
| 38 |
+
|
| 39 |
+
// Input containers styling
|
| 40 |
+
var inputContainers = document.querySelectorAll('.input-container');
|
| 41 |
+
inputContainers.forEach(function(container) {
|
| 42 |
+
container.style.backgroundColor = '#2a2a2a';
|
| 43 |
+
container.style.border = '1px solid #333';
|
| 44 |
+
container.style.borderRadius = '8px';
|
| 45 |
+
container.style.padding = '20px';
|
| 46 |
+
container.style.marginBottom = '20px';
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
// Generate button styling
|
| 50 |
+
var generateButton = document.querySelector('.b');
|
| 51 |
+
if (generateButton) {
|
| 52 |
+
generateButton.style.backgroundColor = '#ea580c';
|
| 53 |
+
generateButton.style.color = 'white';
|
| 54 |
+
generateButton.style.border = 'none';
|
| 55 |
+
generateButton.style.borderRadius = '4px';
|
| 56 |
+
generateButton.style.padding = '10px 20px';
|
| 57 |
+
generateButton.style.width = '100%';
|
| 58 |
+
generateButton.style.cursor = 'pointer';
|
| 59 |
+
generateButton.style.transition = 'background-color 0.3s';
|
| 60 |
+
|
| 61 |
+
generateButton.addEventListener('mouseenter', function () {
|
| 62 |
+
generateButton.style.backgroundColor = '#f9923c';
|
| 63 |
+
});
|
| 64 |
+
generateButton.addEventListener('mouseleave', function () {
|
| 65 |
+
generateButton.style.backgroundColor = '#ea580c';
|
| 66 |
+
});
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// Dropdowns styling
|
| 70 |
+
var dropdowns = document.querySelectorAll('select');
|
| 71 |
+
dropdowns.forEach(function(dropdown) {
|
| 72 |
+
dropdown.style.backgroundColor = '#2a2a2a';
|
| 73 |
+
dropdown.style.color = 'white';
|
| 74 |
+
dropdown.style.border = '1px solid #333';
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
// Rating component styling
|
| 80 |
+
var ratingContainer = document.getElementById('rating-stars');
|
| 81 |
+
if (ratingContainer) {
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
// Style individual radio options
|
| 85 |
+
var radioOptions = ratingContainer.querySelectorAll('label');
|
| 86 |
+
radioOptions.forEach(function(option) {
|
| 87 |
+
option.style.color = '#ffffff';
|
| 88 |
+
option.style.cursor = 'pointer';
|
| 89 |
+
option.style.transition = 'transform 0.2s';
|
| 90 |
+
option.style.flex = '1'; // Make each option take equal space
|
| 91 |
+
option.style.textAlign = 'center'; // Center the content
|
| 92 |
+
option.style.display = 'flex';
|
| 93 |
+
option.style.justifyContent = 'center';
|
| 94 |
+
option.style.alignItems = 'center';
|
| 95 |
+
option.style.padding = '10px';
|
| 96 |
+
|
| 97 |
+
// Add hover effect
|
| 98 |
+
option.addEventListener('mouseenter', function() {
|
| 99 |
+
this.style.transform = 'scale(1.1)';
|
| 100 |
+
});
|
| 101 |
+
|
| 102 |
+
option.addEventListener('mouseleave', function() {
|
| 103 |
+
this.style.transform = 'scale(1)';
|
| 104 |
+
});
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
// Style the radio inputs
|
| 108 |
+
var radioInputs = ratingContainer.querySelectorAll('input[type="radio"]');
|
| 109 |
+
radioInputs.forEach(function(input) {
|
| 110 |
+
input.style.margin = '0 8px 0 0'; // Add some space between radio button and stars
|
| 111 |
+
});
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
return 'Animation created';
|
| 115 |
+
}
|
| 116 |
+
"""
|
| 117 |
+
|
| 118 |
+
js_reload = """
|
| 119 |
+
function reloadPage() {
|
| 120 |
+
setTimeout(function() {
|
| 121 |
+
window.location.reload();
|
| 122 |
+
}, 5000); // Reload after 5 seconds
|
| 123 |
+
}
|
| 124 |
+
"""
|