-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
63 lines (54 loc) · 1.89 KB
/
preload.js
File metadata and controls
63 lines (54 loc) · 1.89 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
58
59
60
61
62
63
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
// API Key management
setApiKey: (key) => ipcRenderer.invoke('set-api-key', key),
getApiKey: () => ipcRenderer.invoke('get-api-key'),
// ElevenLabs API wrapper
elevenLabsRequest: (options) => ipcRenderer.invoke('elevenlabs-request', options),
// Convenience methods for ElevenLabs
async getVoices() {
return this.elevenLabsRequest({
endpoint: '/v1/voices',
method: 'GET'
});
},
async cloneVoice(name, description, audioFiles) {
const formData = new FormData();
formData.append('name', name);
formData.append('description', description);
audioFiles.forEach((file, index) => {
formData.append('files', file, `recording_${index}.wav`);
});
return this.elevenLabsRequest({
endpoint: '/v1/voices/add',
method: 'POST',
body: formData,
isFormData: true
});
},
async speechToSpeech(voiceId, audioBlob, modelId = 'eleven_english_sts_v2') {
const formData = new FormData();
formData.append('audio', audioBlob, 'input.wav');
formData.append('model_id', modelId);
return this.elevenLabsRequest({
endpoint: `/v1/speech-to-speech/${voiceId}`,
method: 'POST',
body: formData,
isFormData: true
});
},
async textToSpeech(voiceId, text, modelId = 'eleven_multilingual_v2') {
return this.elevenLabsRequest({
endpoint: `/v1/text-to-speech/${voiceId}`,
method: 'POST',
body: {
text,
model_id: modelId,
voice_settings: {
stability: 0.5,
similarity_boost: 0.75
}
}
});
}
});