Geraldine commited on
Commit
a98fbe8
·
verified ·
1 Parent(s): 347d844

Update main.js

Browse files
Files changed (1) hide show
  1. main.js +5 -0
main.js CHANGED
@@ -66,6 +66,7 @@ async function stopRecording() {
66
  }
67
 
68
  async function processAudio(audioBlob) {
 
69
  try {
70
  // Create a URL for the audio blob
71
  const audioUrl = URL.createObjectURL(audioBlob);
@@ -78,17 +79,20 @@ async function processAudio(audioBlob) {
78
  document.body.appendChild(downloadLink);*/
79
  // Pass the Float32Array to the whisperPipeline
80
  const transcription = await whisperPipeline(audioUrl);
 
81
  $('#transcription').val(transcription.text);
82
 
83
  // Clean up the URL object
84
  URL.revokeObjectURL(audioUrl);
85
  } catch (e) {
 
86
  $('#status').text('Error processing audio: ' + e.message);
87
  }
88
  }
89
 
90
  // Function to send the final user prompt to the Ollama model
91
  async function sendPrompt() {
 
92
  const transcription = $('#transcription').val(); // Get transcription
93
  const context = $('#context').text(); // Get context
94
  const userPrompt = `${transcription}\n#Context:${context}`; // Combine both
@@ -108,6 +112,7 @@ async function sendPrompt() {
108
  });
109
 
110
  const data = await response.json();
 
111
  editor.setValue(data.response);
112
  $('#status').text('Ready');
113
  }
 
66
  }
67
 
68
  async function processAudio(audioBlob) {
69
+ $('#loadingSpinner').show();
70
  try {
71
  // Create a URL for the audio blob
72
  const audioUrl = URL.createObjectURL(audioBlob);
 
79
  document.body.appendChild(downloadLink);*/
80
  // Pass the Float32Array to the whisperPipeline
81
  const transcription = await whisperPipeline(audioUrl);
82
+ $('#loadingSpinner').hide();
83
  $('#transcription').val(transcription.text);
84
 
85
  // Clean up the URL object
86
  URL.revokeObjectURL(audioUrl);
87
  } catch (e) {
88
+ $('#loadingSpinner').hide();
89
  $('#status').text('Error processing audio: ' + e.message);
90
  }
91
  }
92
 
93
  // Function to send the final user prompt to the Ollama model
94
  async function sendPrompt() {
95
+ $('#loadingSpinner').show();
96
  const transcription = $('#transcription').val(); // Get transcription
97
  const context = $('#context').text(); // Get context
98
  const userPrompt = `${transcription}\n#Context:${context}`; // Combine both
 
112
  });
113
 
114
  const data = await response.json();
115
+ $('#loadingSpinner').hide();
116
  editor.setValue(data.response);
117
  $('#status').text('Ready');
118
  }