-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathindex.html
More file actions
182 lines (172 loc) · 5.36 KB
/
index.html
File metadata and controls
182 lines (172 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
index.html
-------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Translation App</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
}
.container {
max-width: 700px;
margin-top: 50px;
padding: 20px;
background: white;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
textarea {
resize: none;
}
.btn-primary {
width: 48%;
margin-top: 29px;
}
.translated-box {
background: #e9ecef;
padding: 10px;
border-radius: 5px;
margin-top: 20px;
}
.char-count {
text-align: right;
font-size: 14px;
color: gray;
}
.translation-section {
margin-bottom: 20px;
}
.side-by-side {
display: flex;
justify-content: space-between;
}
.box {
width: 48%;
}
.translation-box {
background: #ffffff;
padding: 10px;
border-radius: 5px;
margin-top: 20px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}
.form-label-left {
text-align: left;
}
.form-label-right {
text-align: right;
}
.labels-container {
display: flex;
justify-content: space-between;
}
.dropdown-container {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
}
.dropdown {
width: 48%;
}
.dropdown-container {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: -10px;
}
</style>
</head>
<body>
<div class="container">
<h2>Article Translator And Narrator</h2>
<form method="POST" enctype="multipart/form-data" onsubmit="return validateForm()">
<div class="mb-3">
<div class="labels-container">
<label for="text" class="form-label-left">Enter English Text (max 3000 characters)</label>
<label for="text" class="form-label-right"><b>OpenAI-based</b></label>
</div>
<textarea name="text" id="text" class="form-control" rows="5" placeholder="Type or paste your article here..." oninput="updateCharCount()"></textarea>
<div class="char-count" id="charCount">0 / 3000 characters</div>
<div class="dropdown-container">
<div class="dropdown">
<label for="optionList" class="form-label">Select your voice option</label>
<select id="optionList" name="optionList" class="form-select">
<option value="alloy">Alloy</option>
<option value="ash">Ash</option>
<option value="coral">Coral</option>
<option value="echo">Echo</option>
<option value="fable">Fable</option>
<option value="onyx">Onyx</option>
<option value="nova">Nova</option>
<option value="sage">Sage</option>
<option value="shimmer">Shimmer</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Translate & Narrat</button>
</div>
<div class="char-count" id="charCount">Translate to Hindi,Tamil,Telugu and Spanish</div>
</div>
</form>
{% if translations %}
<div class="side-by-side">
<div class="box">
<h2>Original Text:</h2>
<div class="translation-box">
<p>{{ original_text }}</p>
<audio controls preload="none">
<source src="{{ url_for('download_file', filename=audio_files['Original'].split('/')[-1]) }}" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
</div>
<div class="box">
<h2>Translations:</h2>
{% for lang, translation in translations.items() %}
<div class="translation-box">
<h3>{{ lang }}:</h3>
<p>{{ translation }}</p>
<audio controls preload="none">
<source src="{{ url_for('download_file', filename=audio_files[lang].split('/')[-1]) }}" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
<script>
function validateForm() {
var textArea = document.getElementsByName('text')[0].value;
if (textArea.length > 3000) {
textArea = textArea.substring(0, 3000);
document.getElementsByName('text')[0].value = textArea;
alert("Input text is too long. Only the first 3000 characters will be used.");
}
if (textArea.trim() === "") {
alert("Please provide an article text or file.");
return false;
}
return true;
}
function updateCharCount() {
let textArea = document.getElementById("text");
let charCount = document.getElementById("charCount");
if (textArea.value.length > 3000) {
textArea.value = textArea.value.substring(0, 3000);
}
charCount.innerText = textArea.value.length + " / 3000 characters";
}
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>