harshdhane's picture
Update templates/index.html
c686e60 verified
Raw
History Blame Contribute Delete
6.49 kB
<!DOCTYPE html>
<html lang="{{ language_dict['lang'] }}">
<head>
<meta charset="UTF-8">
<title>{{ language_dict['excuse_header'] }} ๐ŸŽ™๏ธ</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<div class="container">
<h1>{{ language_dict['excuse_header'] }}</h1>
<p>{{ language_dict['excuse_intro'] }}</p>
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label>{{ language_dict['choose_scenario'] }}</label>
<select name="scenario">
<option value="Work" {% if request.form.get('scenario') == 'Work' %}selected{% endif %}>{{ language_dict['work'] }}</option>
<option value="School" {% if request.form.get('scenario') == 'School' %}selected{% endif %}>{{ language_dict['school'] }}</option>
<option value="Social" {% if request.form.get('scenario') == 'Social' %}selected{% endif %}>{{ language_dict['social'] }}</option>
<option value="Family" {% if request.form.get('scenario') == 'Family' %}selected{% endif %}>{{ language_dict['family'] }}</option>
</select>
</div>
<div class="form-group">
<label>{{ language_dict['urgency'] }}:</label>
<div class="radio-group">
<label class="radio-option">
<input type="radio" name="urgency" value="Low" {% if request.form.get('urgency') == 'Low' %}checked{% endif %}>
<span>Low</span>
</label>
<label class="radio-option">
<input type="radio" name="urgency" value="Medium" {% if request.form.get('urgency') == 'Medium' %}checked{% endif %}>
<span>Medium</span>
</label>
<label class="radio-option">
<input type="radio" name="urgency" value="High" {% if request.form.get('urgency') == 'High' %}checked{% endif %}>
<span>High</span>
</label>
</div>
</div>
<div class="form-group">
<label>Upload Proof Image (optional):</label>
<input type="file" name="proof_image" accept="image/*">
</div>
<div class="form-group">
<label>Select Language for Voice Output:</label>
<select name="language" id="language">
<option value="en-US" {% if selected_language == 'en-US' %}selected{% endif %}>English ๐Ÿ‡บ๐Ÿ‡ธ</option>
<option value="hi-IN" {% if selected_language == 'hi-IN' %}selected{% endif %}>Hindi ๐Ÿ‡ฎ๐Ÿ‡ณ</option>
<option value="te-IN" {% if selected_language == 'te-IN' %}selected{% endif %}>Telugu ๐Ÿ‡ฎ๐Ÿ‡ณ</option>
<option value="es-ES" {% if selected_language == 'es-ES' %}selected{% endif %}>Spanish ๐Ÿ‡ช๐Ÿ‡ธ</option>
<option value="fr-FR" {% if selected_language == 'fr-FR' %}selected{% endif %}>French ๐Ÿ‡ซ๐Ÿ‡ท</option>
</select>
</div>
<input type="submit" value="{{ language_dict['generate_excuse'] }}">
</form>
{% if excuse %}
<div class="result-section">
<h2>{{ language_dict['your_excuse'] }}</h2>
<p id="excuseText">{{ excuse }}</p>
<button class="play-button" onclick="speakExcuse()">{{ language_dict['play_excuse'] }}</button>
</div>
<script>
function speakExcuse() {
const text = document.getElementById('excuseText').innerText;
const language = document.getElementById('language').value;
const utterance = new SpeechSynthesisUtterance(text);
utterance.lang = language;
function loadAndSpeak() {
const voices = window.speechSynthesis.getVoices();
let matchedVoice = voices.find(voice => voice.lang === language);
if (language === 'te-IN' && !matchedVoice) {
matchedVoice = voices.find(voice => voice.lang.startsWith('en'));
utterance.lang = 'en-US';
alert("โš ๏ธ Telugu voice not supported on your browser. Using English voice instead.");
}
if (matchedVoice) {
utterance.voice = matchedVoice;
}
window.speechSynthesis.speak(utterance);
}
if (window.speechSynthesis.getVoices().length === 0) {
window.speechSynthesis.onvoiceschanged = loadAndSpeak;
} else {
loadAndSpeak();
}
}
</script>
{% endif %}
{% if proof %}
<div class="result-section">
<h3>{{ language_dict['fake_proof'] }}</h3>
<img src="{{ proof }}" alt="Fake image detected" class="proof-img">
{% if proof_label %}
<p>{{ proof_label }}</p>
{% endif %}
</div>
{% endif %}
{% if top_excuses %}
<div class="result-section">
<h2>{{ language_dict['top_excuses'] }}</h2>
<ol>
{% for excuse in top_excuses %}
<li>
{% if loop.index == 1 %}๐Ÿฅ‡{% elif loop.index == 2 %}๐Ÿฅˆ{% elif loop.index == 3 %}๐Ÿฅ‰{% endif %}
<strong>{{ excuse }}</strong>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% if predicted_schedule %}
<div class="prediction-box">
๐Ÿ“… <strong>{{ language_dict['prediction'] }}</strong> <strong>{{ predicted_schedule }}</strong>
</div>
{% endif %}
<div class="navigation-links">
<a href="{{ url_for('apology') }}">{{ language_dict['apology_link'] }}</a>
<a href="{{ url_for('history') }}">๐Ÿ•’ {{ language_dict['history'] }} and {{ language_dict['favorites'] }}</a>
</div>
</div>
</body>
</html>