Spaces:
Running
Running
Update index.html
Browse files- index.html +9 -2
index.html
CHANGED
@@ -20,10 +20,13 @@
|
|
20 |
<button id="stopButton" disabled>Stop Listening</button>
|
21 |
|
22 |
<script type="module">
|
23 |
-
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
|
24 |
|
25 |
// Set the local directory for caching models
|
26 |
env.localModelPath = './models';
|
|
|
|
|
|
|
27 |
|
28 |
const conversationDiv = document.getElementById('conversation');
|
29 |
const startButton = document.getElementById('startButton');
|
@@ -57,7 +60,11 @@
|
|
57 |
const botResponse = `I heard you say: "${transcription.text}". This is a placeholder response.`;
|
58 |
addMessage('Bot', botResponse);
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
playAudio(speechOutput.audio);
|
62 |
} catch (error) {
|
63 |
console.error('Error processing speech:', error);
|
|
|
20 |
<button id="stopButton" disabled>Stop Listening</button>
|
21 |
|
22 |
<script type="module">
|
23 |
+
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]/+esm';
|
24 |
|
25 |
// Set the local directory for caching models
|
26 |
env.localModelPath = './models';
|
27 |
+
|
28 |
+
// Disable local models to force CDN usage
|
29 |
+
env.allowLocalModels = false;
|
30 |
|
31 |
const conversationDiv = document.getElementById('conversation');
|
32 |
const startButton = document.getElementById('startButton');
|
|
|
60 |
const botResponse = `I heard you say: "${transcription.text}". This is a placeholder response.`;
|
61 |
addMessage('Bot', botResponse);
|
62 |
|
63 |
+
// Use a default speaker embedding
|
64 |
+
const defaultSpeakerEmbedding = new Float32Array(512).fill(0);
|
65 |
+
defaultSpeakerEmbedding[0] = 1; // Set the first element to 1 as a simple default
|
66 |
+
|
67 |
+
const speechOutput = await ttsPipeline(botResponse, { speaker_embeddings: defaultSpeakerEmbedding });
|
68 |
playAudio(speechOutput.audio);
|
69 |
} catch (error) {
|
70 |
console.error('Error processing speech:', error);
|