@todoforai/voiceloop 0.1.24 → 0.1.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/voiceloop",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "Fast, interruptible browser voice agent: VAD → STT → LLM → TTS with real barge-in, echo filtering, streaming first-sentence TTS and tap-to-seek. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.d.ts CHANGED
@@ -380,7 +380,7 @@ export class StreamingTTS implements VoiceTTS {
380
380
  * talks to ElevenLabs directly and is dev-only. `headers` authenticate proxy requests
381
381
  * (e.g. { 'X-API-Key': ... }) and are never sent on a direct ElevenLabs call. */
382
382
  export class ElevenLabsTTS extends StreamingTTS {
383
- constructor(options?: { ttsUrl?: string; apiKey?: string; voiceId?: string; modelId?: string; format?: string; headers?: Record<string, string> });
383
+ constructor(options?: { ttsUrl?: string; apiKey?: string; voiceId?: string; modelId?: string; format?: string; headers?: Record<string, string>; languageCode?: string });
384
384
  warm(): Promise<void>;
385
385
  }
386
386
 
@@ -19,10 +19,13 @@ const EL_API = 'https://api.elevenlabs.io/v1/text-to-speech';
19
19
 
20
20
  export class ElevenLabsTTS extends StreamingTTS {
21
21
  constructor({ ttsUrl, apiKey, voiceId = 'JBFqnCBsd6RMkjVDRZzb' /* George */,
22
- modelId = 'eleven_flash_v2_5', format = 'mp3_44100_64', headers = {} } = {}) {
22
+ modelId = 'eleven_flash_v2_5', format = 'mp3_44100_64', headers = {}, languageCode = '' } = {}) {
23
23
  super(voiceId);
24
24
  if (!ttsUrl && !apiKey) throw new Error('ElevenLabsTTS needs ttsUrl (backend proxy) or apiKey (direct, dev only)');
25
25
  this.ttsUrl = ttsUrl; this.apiKey = apiKey; this.modelId = modelId; this.format = format;
26
+ // ISO 639-1 ('hu'). Without it Flash auto-detects per SENTENCE — short clips get misread as
27
+ // English and spoken with English phonetics. Base code only; '' = let the model guess.
28
+ this.languageCode = String(languageCode || '').split(/[-_]/)[0].toLowerCase();
26
29
  this.headers = headers; // proxy-path auth (X-API-Key etc.) — never sent to ElevenLabs directly
27
30
  }
28
31
 
@@ -58,8 +61,11 @@ export class ElevenLabsTTS extends StreamingTTS {
58
61
  method: 'POST',
59
62
  headers: { 'Content-Type': 'application/json', ...(direct ? { 'xi-api-key': this.apiKey } : this.headers) },
60
63
  // The proxy form carries voice/model/format in the body so one backend route serves any voice.
61
- body: JSON.stringify(direct ? { text, model_id: this.modelId }
62
- : { text, voice_id: this.voiceId, model_id: this.modelId, output_format: this.format }),
64
+ body: JSON.stringify({
65
+ text, model_id: this.modelId,
66
+ ...(this.languageCode ? { language_code: this.languageCode } : {}),
67
+ ...(direct ? {} : { voice_id: this.voiceId, output_format: this.format }),
68
+ }),
63
69
  signal,
64
70
  });
65
71
  if (!res.ok) throw new Error(`ElevenLabs TTS ${res.status}: ${(await res.text().catch(() => '')).slice(0, 200)}`);