tauri-plugin-supertonic-api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -0
- package/src/index.ts +70 -0
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tauri-plugin-supertonic-api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript bindings for the Supertonic TTS Tauri plugin",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/TheoSlater/supertonic-rs.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "src/index.ts",
|
|
12
|
+
"types": "src/index.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"src/**/*"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@tauri-apps/api": "^2.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { invoke, Channel } from '@tauri-apps/api/core';
|
|
2
|
+
|
|
3
|
+
export interface SynthesizeResponse {
|
|
4
|
+
wavBase64: string;
|
|
5
|
+
durationSecs: number;
|
|
6
|
+
sampleRate: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ModelProgressEvent {
|
|
10
|
+
file: string;
|
|
11
|
+
bytesDownloaded: number;
|
|
12
|
+
totalBytes: number | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface StatusResponse {
|
|
16
|
+
engineLoaded: boolean;
|
|
17
|
+
currentVoice: string;
|
|
18
|
+
sampleRate: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Synthesize text to audio, returns base64-encoded WAV */
|
|
22
|
+
export async function synthesize(
|
|
23
|
+
text: string,
|
|
24
|
+
lang?: string,
|
|
25
|
+
totalStep?: number,
|
|
26
|
+
speed?: number,
|
|
27
|
+
silenceDuration?: number,
|
|
28
|
+
): Promise<SynthesizeResponse> {
|
|
29
|
+
return await invoke<SynthesizeResponse>('plugin:supertonic|synthesize', {
|
|
30
|
+
text,
|
|
31
|
+
lang: lang ?? 'en',
|
|
32
|
+
totalStep,
|
|
33
|
+
speed,
|
|
34
|
+
silenceDuration,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Download and load a TTS model from HuggingFace */
|
|
39
|
+
export async function loadModel(
|
|
40
|
+
modelId?: string,
|
|
41
|
+
voiceStyle?: string,
|
|
42
|
+
onProgress?: (event: ModelProgressEvent) => void,
|
|
43
|
+
): Promise<void> {
|
|
44
|
+
const channel = new Channel<ModelProgressEvent>();
|
|
45
|
+
if (onProgress) {
|
|
46
|
+
channel.onmessage = onProgress;
|
|
47
|
+
}
|
|
48
|
+
return await invoke('plugin:supertonic|load_model', {
|
|
49
|
+
modelId: modelId ?? 'Supertone/supertonic-3',
|
|
50
|
+
voiceStyle: voiceStyle ?? 'M1',
|
|
51
|
+
onProgress: channel,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** List available voice styles */
|
|
56
|
+
export async function listVoices(): Promise<string[]> {
|
|
57
|
+
return await invoke<string[]>('plugin:supertonic|list_voices');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Select a voice style by name */
|
|
61
|
+
export async function selectVoice(voiceName: string): Promise<void> {
|
|
62
|
+
return await invoke('plugin:supertonic|select_voice', {
|
|
63
|
+
voiceName,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Get engine status */
|
|
68
|
+
export async function getStatus(): Promise<StatusResponse> {
|
|
69
|
+
return await invoke<StatusResponse>('plugin:supertonic|get_status');
|
|
70
|
+
}
|