Update main.js
Browse files
main.js
CHANGED
@@ -70,13 +70,6 @@ async function processAudio(audioBlob) {
|
|
70 |
try {
|
71 |
// Create a URL for the audio blob
|
72 |
const audioUrl = URL.createObjectURL(audioBlob);
|
73 |
-
|
74 |
-
// Create a download link for the audio file (optional)
|
75 |
-
/*const downloadLink = document.createElement('a');
|
76 |
-
downloadLink.href = audioUrl;
|
77 |
-
downloadLink.download = 'recording.wav';
|
78 |
-
downloadLink.textContent = 'Download audio file';
|
79 |
-
document.body.appendChild(downloadLink);*/
|
80 |
// Pass the Float32Array to the whisperPipeline
|
81 |
const transcription = await whisperPipeline(audioUrl);
|
82 |
$('#loadingSpinner').hide();
|
@@ -96,7 +89,6 @@ async function sendPrompt() {
|
|
96 |
const transcription = $('#transcription').val(); // Get transcription
|
97 |
const context = $('#context').text(); // Get context
|
98 |
const userPrompt = `${transcription}\n#Context:${context}`; // Combine both
|
99 |
-
console.log(userPrompt)
|
100 |
|
101 |
// Send transcription to Ollama server for EAD/XML generation
|
102 |
const response = await fetch('http://129.80.86.176:11434/api/generate', {
|
@@ -112,17 +104,16 @@ async function sendPrompt() {
|
|
112 |
});
|
113 |
|
114 |
const data = await response.json();
|
115 |
-
|
116 |
if (context.trim() === '') {
|
117 |
// If context is empty, set the entire editor value
|
118 |
editor.setValue(data.response);
|
119 |
} else {
|
120 |
// Get the current selection range in the editor
|
121 |
-
const
|
122 |
-
|
123 |
-
|
124 |
// Replace only the highlighted text with the model's response
|
125 |
-
editor.
|
126 |
}
|
127 |
$('#status').text('Ready');
|
128 |
$('#loadingSpinner').hide();
|
|
|
70 |
try {
|
71 |
// Create a URL for the audio blob
|
72 |
const audioUrl = URL.createObjectURL(audioBlob);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
// Pass the Float32Array to the whisperPipeline
|
74 |
const transcription = await whisperPipeline(audioUrl);
|
75 |
$('#loadingSpinner').hide();
|
|
|
89 |
const transcription = $('#transcription').val(); // Get transcription
|
90 |
const context = $('#context').text(); // Get context
|
91 |
const userPrompt = `${transcription}\n#Context:${context}`; // Combine both
|
|
|
92 |
|
93 |
// Send transcription to Ollama server for EAD/XML generation
|
94 |
const response = await fetch('http://129.80.86.176:11434/api/generate', {
|
|
|
104 |
});
|
105 |
|
106 |
const data = await response.json();
|
107 |
+
/ Check if context is empty
|
108 |
if (context.trim() === '') {
|
109 |
// If context is empty, set the entire editor value
|
110 |
editor.setValue(data.response);
|
111 |
} else {
|
112 |
// Get the current selection range in the editor
|
113 |
+
const selectionRange = editor.getSelectionRange(); // Get the selection range
|
114 |
+
|
|
|
115 |
// Replace only the highlighted text with the model's response
|
116 |
+
editor.session.replace(selectionRange, data.response);
|
117 |
}
|
118 |
$('#status').text('Ready');
|
119 |
$('#loadingSpinner').hide();
|