subformer 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Subformer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,301 @@
1
+ # 🎬 Subformer JavaScript/TypeScript SDK
2
+
3
+ [![npm version](https://badge.fury.io/js/subformer.svg)](https://www.npmjs.com/package/subformer)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **Official JavaScript/TypeScript SDK for [Subformer](https://subformer.com)** — AI-powered video dubbing, voice cloning, and text-to-speech API.
8
+
9
+ 🌍 Dub videos into 50+ languages | 🎙️ Clone any voice | 🔊 Generate natural speech
10
+
11
+ ---
12
+
13
+ ## ✨ Features
14
+
15
+ - 🎥 **Video Dubbing** — Automatically translate and dub YouTube, TikTok, Instagram, Facebook, X (Twitter), and any video URL
16
+ - 🗣️ **Voice Cloning** — Transform audio to match any target voice
17
+ - 📝 **Text-to-Speech** — Generate natural-sounding speech from text
18
+ - 🎵 **Voice Library** — Save and manage custom voices
19
+ - 📘 **Full TypeScript Support** — Complete type definitions included
20
+ - 🌐 **Works Everywhere** — Node.js, Deno, Bun, and modern browsers
21
+
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ # npm
26
+ npm install subformer
27
+
28
+ # yarn
29
+ yarn add subformer
30
+
31
+ # pnpm
32
+ pnpm add subformer
33
+
34
+ # bun
35
+ bun add subformer
36
+ ```
37
+
38
+ ## 🚀 Quick Start
39
+
40
+ ### Video Dubbing
41
+
42
+ Dub any video into 50+ languages with one API call:
43
+
44
+ ```typescript
45
+ import { Subformer } from 'subformer';
46
+
47
+ const client = new Subformer({ apiKey: 'sk_subformer_...' });
48
+
49
+ // Dub a YouTube video to Spanish
50
+ const job = await client.dub({
51
+ source: 'youtube',
52
+ url: 'https://youtube.com/watch?v=VIDEO_ID',
53
+ language: 'es-ES'
54
+ });
55
+
56
+ // Wait for completion
57
+ const result = await client.waitForJob(job.id);
58
+
59
+ // Get the dubbed video URL
60
+ console.log('Dubbed video:', result.output?.videoUrl);
61
+ ```
62
+
63
+ ### Voice Cloning
64
+
65
+ Clone any voice and apply it to audio:
66
+
67
+ ```typescript
68
+ import { Subformer, type PresetVoice } from 'subformer';
69
+
70
+ const client = new Subformer({ apiKey: 'sk_subformer_...' });
71
+
72
+ // Clone voice using a preset
73
+ const job = await client.cloneVoice({
74
+ sourceAudioUrl: 'https://example.com/speech.mp3',
75
+ targetVoice: {
76
+ mode: 'preset',
77
+ presetVoiceId: 'morgan-freeman'
78
+ } as PresetVoice
79
+ });
80
+
81
+ const result = await client.waitForJob(job.id);
82
+ console.log('Cloned audio:', result.output?.audioUrl);
83
+ ```
84
+
85
+ ### Text-to-Speech
86
+
87
+ Generate natural speech from text:
88
+
89
+ ```typescript
90
+ import { Subformer, type UploadedVoice } from 'subformer';
91
+
92
+ const client = new Subformer({ apiKey: 'sk_subformer_...' });
93
+
94
+ // Synthesize speech with a custom voice
95
+ const job = await client.synthesizeVoice({
96
+ text: 'Hello, welcome to Subformer!',
97
+ targetVoice: {
98
+ mode: 'upload',
99
+ targetAudioUrl: 'https://example.com/my-voice.mp3'
100
+ } as UploadedVoice
101
+ });
102
+
103
+ const result = await client.waitForJob(job.id);
104
+ console.log('Generated audio:', result.output?.audioUrl);
105
+ ```
106
+
107
+ ## 📚 API Reference
108
+
109
+ ### Client Initialization
110
+
111
+ ```typescript
112
+ import { Subformer } from 'subformer';
113
+
114
+ const client = new Subformer({
115
+ apiKey: 'sk_subformer_...',
116
+ baseUrl: 'https://api.subformer.com/v1', // optional
117
+ timeout: 30000 // optional, in milliseconds
118
+ });
119
+ ```
120
+
121
+ ### Dubbing
122
+
123
+ | Method | Description |
124
+ |--------|-------------|
125
+ | `dub(options)` | Create a video dubbing job |
126
+ | `getLanguages()` | Get list of supported languages |
127
+
128
+ **Supported Sources:** `youtube`, `tiktok`, `instagram`, `facebook`, `x`, `url`
129
+
130
+ ```typescript
131
+ // Dub options
132
+ interface DubOptions {
133
+ source: 'youtube' | 'tiktok' | 'instagram' | 'facebook' | 'x' | 'url';
134
+ url: string;
135
+ language: string; // e.g., 'es-ES', 'fr-FR'
136
+ disableWatermark?: boolean;
137
+ }
138
+ ```
139
+
140
+ ### Jobs
141
+
142
+ | Method | Description |
143
+ |--------|-------------|
144
+ | `getJob(jobId)` | Get job by ID |
145
+ | `listJobs(options?)` | List all jobs |
146
+ | `deleteJobs(jobIds)` | Delete jobs |
147
+ | `waitForJob(jobId, options?)` | Wait for job completion |
148
+
149
+ ```typescript
150
+ // List jobs with pagination
151
+ const { data, total } = await client.listJobs({
152
+ offset: 0,
153
+ limit: 10,
154
+ type: 'video-dubbing'
155
+ });
156
+
157
+ // Wait for job with timeout
158
+ const job = await client.waitForJob(jobId, {
159
+ pollInterval: 2, // seconds
160
+ timeout: 300 // seconds
161
+ });
162
+ ```
163
+
164
+ ### Voice Cloning & Synthesis
165
+
166
+ | Method | Description |
167
+ |--------|-------------|
168
+ | `cloneVoice(options)` | Clone a voice |
169
+ | `synthesizeVoice(options)` | Text-to-speech |
170
+
171
+ ### Voice Library
172
+
173
+ | Method | Description |
174
+ |--------|-------------|
175
+ | `listVoices()` | List saved voices |
176
+ | `getVoice(voiceId)` | Get voice by ID |
177
+ | `createVoice(options)` | Create a voice |
178
+ | `updateVoice(options)` | Update a voice |
179
+ | `deleteVoice(voiceId)` | Delete a voice |
180
+
181
+ ## 🌍 Supported Languages
182
+
183
+ Subformer supports 70+ languages for video dubbing:
184
+
185
+ | Language | Code | Language | Code |
186
+ |----------|------|----------|------|
187
+ | Afrikaans | `af-ZA` | Albanian | `sq-AL` |
188
+ | Arabic | `ar-SA` | Armenian | `hy-AM` |
189
+ | Azerbaijani | `az-AZ` | Belarusian | `be-BY` |
190
+ | Bengali | `bn-IN` | Bosnian | `bs-BA` |
191
+ | Bulgarian | `bg-BG` | Burmese | `my-MM` |
192
+ | Catalan | `ca-ES` | Chinese (Simplified) | `zh-CN` |
193
+ | Chinese (Traditional) | `zh-TW` | Croatian | `hr-HR` |
194
+ | Czech | `cs-CZ` | Danish | `da-DK` |
195
+ | Dutch | `nl-NL` | English | `en-US` |
196
+ | Estonian | `et-EE` | Filipino | `fil-PH` |
197
+ | Finnish | `fi-FI` | French | `fr-FR` |
198
+ | Galician | `gl-ES` | Georgian | `ka-GE` |
199
+ | German | `de-DE` | Greek | `el-GR` |
200
+ | Gujarati | `gu-IN` | Hebrew | `he-IL` |
201
+ | Hindi | `hi-IN` | Hungarian | `hu-HU` |
202
+ | Icelandic | `is-IS` | Indonesian | `id-ID` |
203
+ | Italian | `it-IT` | Japanese | `ja-JP` |
204
+ | Javanese | `jv-ID` | Kannada | `kn-IN` |
205
+ | Kazakh | `kk-KZ` | Khmer | `km-KH` |
206
+ | Korean | `ko-KR` | Latin | `la-VA` |
207
+ | Latvian | `lv-LV` | Lithuanian | `lt-LT` |
208
+ | Macedonian | `mk-MK` | Malay | `ms-MY` |
209
+ | Malayalam | `ml-IN` | Maltese | `mt-MT` |
210
+ | Marathi | `mr-IN` | Mongolian | `mn-MN` |
211
+ | Norwegian | `no-NO` | Persian | `fa-IR` |
212
+ | Polish | `pl-PL` | Portuguese (Brazil) | `pt-BR` |
213
+ | Punjabi | `pa-IN` | Romanian | `ro-RO` |
214
+ | Russian | `ru-RU` | Serbian | `sr-RS` |
215
+ | Slovak | `sk-SK` | Slovenian | `sl-SI` |
216
+ | Spanish | `es-ES` | Swahili | `sw-KE` |
217
+ | Swedish | `sv-SE` | Tagalog | `tl-PH` |
218
+ | Tamil | `ta-IN` | Telugu | `te-IN` |
219
+ | Thai | `th-TH` | Turkish | `tr-TR` |
220
+ | Ukrainian | `uk-UA` | Urdu | `ur-PK` |
221
+ | Uzbek | `uz-UZ` | Vietnamese | `vi-VN` |
222
+ | Welsh | `cy-GB` | | |
223
+
224
+ ## ⚠️ Error Handling
225
+
226
+ ```typescript
227
+ import {
228
+ Subformer,
229
+ SubformerError,
230
+ AuthenticationError,
231
+ RateLimitError,
232
+ NotFoundError,
233
+ ValidationError
234
+ } from 'subformer';
235
+
236
+ const client = new Subformer({ apiKey: 'sk_subformer_...' });
237
+
238
+ try {
239
+ const job = await client.dub({
240
+ source: 'youtube',
241
+ url: 'https://youtube.com/watch?v=VIDEO_ID',
242
+ language: 'es-ES'
243
+ });
244
+ } catch (error) {
245
+ if (error instanceof AuthenticationError) {
246
+ console.error('Invalid API key');
247
+ } else if (error instanceof RateLimitError) {
248
+ console.error('Too many requests, please slow down');
249
+ } else if (error instanceof NotFoundError) {
250
+ console.error('Resource not found');
251
+ } else if (error instanceof ValidationError) {
252
+ console.error('Invalid input:', error.message);
253
+ } else if (error instanceof SubformerError) {
254
+ console.error('API error:', error.message, error.code);
255
+ }
256
+ }
257
+ ```
258
+
259
+ ## 🔑 Getting Your API Key
260
+
261
+ 1. Sign up at [subformer.com](https://subformer.com)
262
+ 2. Go to [API Keys](https://subformer.com/dashboard/api-keys)
263
+ 3. Create a new API key
264
+
265
+ ## 📘 TypeScript Support
266
+
267
+ This SDK is written in TypeScript and includes complete type definitions:
268
+
269
+ ```typescript
270
+ import type {
271
+ Job,
272
+ JobState,
273
+ JobType,
274
+ Voice,
275
+ Language,
276
+ DubSource,
277
+ TargetVoice,
278
+ PresetVoice,
279
+ UploadedVoice
280
+ } from 'subformer';
281
+ ```
282
+
283
+ ## 📖 Documentation
284
+
285
+ - [API Documentation](https://subformer.com/docs/api)
286
+ - [Interactive API Reference](https://api.subformer.com/v1/docs)
287
+ - [OpenAPI Spec](https://api.subformer.com/v1/openapi.json)
288
+
289
+ ## 🤝 Contributing
290
+
291
+ Contributions are welcome! Please feel free to submit a Pull Request.
292
+
293
+ ## 📄 License
294
+
295
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
296
+
297
+ ---
298
+
299
+ <p align="center">
300
+ Made with ❤️ by <a href="https://subformer.com">Subformer</a>
301
+ </p>