Spaces:
Running
Running
Update index.html
Browse files- index.html +2 -9
index.html
CHANGED
|
@@ -20,13 +20,10 @@
|
|
| 20 |
<button id="stopButton" disabled>Stop Listening</button>
|
| 21 |
|
| 22 |
<script type="module">
|
| 23 |
-
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2
|
| 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,11 +57,7 @@
|
|
| 60 |
const botResponse = `I heard you say: "${transcription.text}". This is a placeholder response.`;
|
| 61 |
addMessage('Bot', botResponse);
|
| 62 |
|
| 63 |
-
|
| 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);
|
|
|
|
| 20 |
<button id="stopButton" disabled>Stop Listening</button>
|
| 21 |
|
| 22 |
<script type="module">
|
| 23 |
+
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2';
|
| 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 |
const botResponse = `I heard you say: "${transcription.text}". This is a placeholder response.`;
|
| 58 |
addMessage('Bot', botResponse);
|
| 59 |
|
| 60 |
+
const speechOutput = await ttsPipeline(botResponse, { speaker_id: 0 });
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
playAudio(speechOutput.audio);
|
| 62 |
} catch (error) {
|
| 63 |
console.error('Error processing speech:', error);
|