-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_sensevoice_frontend.js
More file actions
57 lines (48 loc) · 1.8 KB
/
test_sensevoice_frontend.js
File metadata and controls
57 lines (48 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Test script to verify SenseVoice download functionality
// This would typically be run in browser console
async function testSenseVoiceDownload() {
try {
// Test the downloadAdvancedModelStream function from backend-api.js
const response = await fetch('/api/download-sensevoice', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
console.log('Starting SenseVoice download test...');
while (true) {
const { value, done } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
try {
const data = JSON.parse(line.slice(6));
console.log('Progress:', data);
if (data.done) {
console.log('Download completed successfully!');
console.log('Model path:', data.path);
return data;
}
} catch (e) {
console.log('Raw data:', line);
}
}
}
}
} catch (error) {
console.error('Download test failed:', error);
throw error;
}
}
// Export for testing
if (typeof module !== 'undefined' && module.exports) {
module.exports = { testSenseVoiceDownload };
}