sohailsyed commited on
Commit
aa2308d
·
verified ·
1 Parent(s): 7744beb

please add function in this that it will create same voice speech for my text using cloning my voice

Browse files
Files changed (1) hide show
  1. index.html +76 -8
index.html CHANGED
@@ -86,16 +86,23 @@
86
  </select>
87
  </div>
88
  </div>
89
- <button class="w-full bg-purple-600 hover:bg-purple-700 text-white py-3 px-6 rounded-lg flex items-center justify-center gap-2 transition">
90
  <i data-feather="copy"></i> Clone Voice
91
  </button>
92
- </div>
 
 
 
 
 
 
 
93
  </div>
94
  </div>
95
  </main>
96
 
97
  <section class="mt-16 max-w-4xl mx-auto">
98
- <h2 class="text-2xl font-semibold mb-6 text-center">Your Voice Library</h2>
99
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
100
  <div class="bg-white/10 backdrop-blur-md rounded-lg p-4 hover:bg-white/20 transition cursor-pointer">
101
  <div class="flex items-center gap-3 mb-3">
@@ -146,10 +153,68 @@
146
  <footer class="py-6 text-center text-sm opacity-80 mt-16">
147
  <p>© 2023 EchoMimic - Clone voices like magic ✨</p>
148
  </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
- <script>
151
  // Initialize Vanta.js waves background
152
- VANTA.WAVES({
153
  el: "#waves-bg",
154
  mouseControls: true,
155
  touchControls: true,
@@ -174,8 +239,8 @@
174
  bar.style.animationDelay = `${i * 0.05}s`;
175
  visualizer.appendChild(bar);
176
  }
177
- // Audio recording functionality
178
- let mediaRecorder;
179
  let audioChunks = [];
180
  const recordBtn = document.getElementById('recordBtn');
181
  const stopBtn = document.getElementById('stopBtn');
@@ -214,7 +279,10 @@
214
  voiceLibrary.prepend(newVoice);
215
  feather.replace();
216
  audioChunks = [];
217
- };
 
 
 
218
 
219
  mediaRecorder.start();
220
  recordBtn.disabled = true;
 
86
  </select>
87
  </div>
88
  </div>
89
+ <button id="cloneBtn" class="w-full bg-purple-600 hover:bg-purple-700 text-white py-3 px-6 rounded-lg flex items-center justify-center gap-2 transition">
90
  <i data-feather="copy"></i> Clone Voice
91
  </button>
92
+ </div>
93
+ </div>
94
+ <div class="mt-8">
95
+ <h2 class="text-2xl font-semibold mb-4">Text to Speech with Your Voice</h2>
96
+ <textarea id="textToSpeech" class="w-full bg-white/20 border border-white/30 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-white mb-4" rows="4" placeholder="Enter text to speak with your cloned voice..."></textarea>
97
+ <button id="speakBtn" class="bg-blue-600 hover:bg-blue-700 text-white py-3 px-6 rounded-lg flex items-center justify-center gap-2 transition">
98
+ <i data-feather="volume-2"></i> Speak Text
99
+ </button>
100
  </div>
101
  </div>
102
  </main>
103
 
104
  <section class="mt-16 max-w-4xl mx-auto">
105
+ <h2 class="text-2xl font-semibold mb-6 text-center">Your Voice Library</h2>
106
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
107
  <div class="bg-white/10 backdrop-blur-md rounded-lg p-4 hover:bg-white/20 transition cursor-pointer">
108
  <div class="flex items-center gap-3 mb-3">
 
153
  <footer class="py-6 text-center text-sm opacity-80 mt-16">
154
  <p>© 2023 EchoMimic - Clone voices like magic ✨</p>
155
  </footer>
156
+ <script>
157
+ // Web Speech API Synthesis
158
+ const textToSpeech = document.getElementById('textToSpeech');
159
+ const speakBtn = document.getElementById('speakBtn');
160
+ const cloneBtn = document.getElementById('cloneBtn');
161
+ let clonedVoice = null;
162
+
163
+ // Clone voice button handler
164
+ cloneBtn.addEventListener('click', async () => {
165
+ // In a real app, this would send the recording to your voice cloning API
166
+ // For demo, we'll just simulate it
167
+ clonedVoice = true;
168
+ alert('Voice cloned successfully! Now you can convert text to speech using your voice.');
169
+ });
170
+
171
+ // Speak text button handler
172
+ speakBtn.addEventListener('click', () => {
173
+ if (!clonedVoice) {
174
+ alert('Please clone your voice first!');
175
+ return;
176
+ }
177
+
178
+ const text = textToSpeech.value.trim();
179
+ if (!text) {
180
+ alert('Please enter some text to speak');
181
+ return;
182
+ }
183
+
184
+ // In a real app, this would call your voice cloning API
185
+ // For demo, we'll use Web Speech API with slight modifications
186
+ const utterance = new SpeechSynthesisUtterance(text);
187
+
188
+ // Modify voice properties to simulate cloning
189
+ utterance.rate = document.querySelector('input[type="range"][min="50"]').value / 100;
190
+ utterance.pitch = document.querySelector('input[type="range"][min="0"]').value / 50;
191
+
192
+ // Get selected emotion and apply appropriate voice style
193
+ const emotion = document.querySelector('select').value;
194
+ switch(emotion) {
195
+ case 'Happy':
196
+ utterance.rate *= 1.2;
197
+ utterance.pitch *= 1.1;
198
+ break;
199
+ case 'Sad':
200
+ utterance.rate *= 0.8;
201
+ utterance.pitch *= 0.9;
202
+ break;
203
+ case 'Angry':
204
+ utterance.rate *= 1.1;
205
+ utterance.pitch *= 0.95;
206
+ break;
207
+ case 'Excited':
208
+ utterance.rate *= 1.3;
209
+ utterance.pitch *= 1.2;
210
+ break;
211
+ }
212
+
213
+ speechSynthesis.speak(utterance);
214
+ });
215
 
 
216
  // Initialize Vanta.js waves background
217
+ VANTA.WAVES({
218
  el: "#waves-bg",
219
  mouseControls: true,
220
  touchControls: true,
 
239
  bar.style.animationDelay = `${i * 0.05}s`;
240
  visualizer.appendChild(bar);
241
  }
242
+ // Audio recording functionality for cloning
243
+ let mediaRecorder;
244
  let audioChunks = [];
245
  const recordBtn = document.getElementById('recordBtn');
246
  const stopBtn = document.getElementById('stopBtn');
 
279
  voiceLibrary.prepend(newVoice);
280
  feather.replace();
281
  audioChunks = [];
282
+
283
+ // Store the recorded voice for cloning
284
+ clonedVoice = audioBlob;
285
+ };
286
 
287
  mediaRecorder.start();
288
  recordBtn.disabled = true;