@t3lnet/sceneforge 1.0.7 → 1.0.8
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/README.md +27 -0
- package/dist/index.cjs +419 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -0
- package/dist/index.d.ts +137 -0
- package/dist/index.js +419 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -457,6 +457,128 @@ declare function demoType(page: Page, selector: string, text: string, options?:
|
|
|
457
457
|
delayBetweenChars?: number;
|
|
458
458
|
}): Promise<void>;
|
|
459
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Voice settings that affect the generated audio output
|
|
462
|
+
*/
|
|
463
|
+
interface VoiceCacheSettings {
|
|
464
|
+
stability: number;
|
|
465
|
+
similarityBoost: number;
|
|
466
|
+
style: number;
|
|
467
|
+
useSpeakerBoost: boolean;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* A single entry in the voice cache
|
|
471
|
+
*/
|
|
472
|
+
interface VoiceCacheEntry {
|
|
473
|
+
key: string;
|
|
474
|
+
voiceId: string;
|
|
475
|
+
modelId: string;
|
|
476
|
+
text: string;
|
|
477
|
+
voiceSettings: VoiceCacheSettings;
|
|
478
|
+
audioFileName: string;
|
|
479
|
+
durationMs: number;
|
|
480
|
+
fileSizeBytes: number;
|
|
481
|
+
createdAt: string;
|
|
482
|
+
lastUsedAt: string;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Configuration for the voice cache
|
|
486
|
+
*/
|
|
487
|
+
interface VoiceCacheConfig {
|
|
488
|
+
/** Directory where cache files are stored */
|
|
489
|
+
cacheDir: string;
|
|
490
|
+
/** Whether caching is enabled (default: true) */
|
|
491
|
+
enabled?: boolean;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Statistics about the voice cache
|
|
495
|
+
*/
|
|
496
|
+
interface VoiceCacheStats {
|
|
497
|
+
totalEntries: number;
|
|
498
|
+
totalSizeBytes: number;
|
|
499
|
+
oldestEntry: string | null;
|
|
500
|
+
newestEntry: string | null;
|
|
501
|
+
hitCount: number;
|
|
502
|
+
missCount: number;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Voice cache manager for storing and retrieving synthesized audio.
|
|
506
|
+
* This helps avoid duplicate API calls to ElevenLabs for the same text/voice combinations.
|
|
507
|
+
*/
|
|
508
|
+
declare class VoiceCache {
|
|
509
|
+
private config;
|
|
510
|
+
private index;
|
|
511
|
+
private stats;
|
|
512
|
+
private indexDirty;
|
|
513
|
+
constructor(config: VoiceCacheConfig);
|
|
514
|
+
/**
|
|
515
|
+
* Gets the path to the cache index file
|
|
516
|
+
*/
|
|
517
|
+
private get indexPath();
|
|
518
|
+
/**
|
|
519
|
+
* Gets the path to the audio cache directory
|
|
520
|
+
*/
|
|
521
|
+
private get audioDir();
|
|
522
|
+
/**
|
|
523
|
+
* Whether caching is enabled
|
|
524
|
+
*/
|
|
525
|
+
get enabled(): boolean;
|
|
526
|
+
/**
|
|
527
|
+
* Initializes the cache directory and loads the index
|
|
528
|
+
*/
|
|
529
|
+
initialize(): Promise<void>;
|
|
530
|
+
/**
|
|
531
|
+
* Loads the cache index from disk
|
|
532
|
+
*/
|
|
533
|
+
private loadIndex;
|
|
534
|
+
/**
|
|
535
|
+
* Saves the cache index to disk
|
|
536
|
+
*/
|
|
537
|
+
saveIndex(): Promise<void>;
|
|
538
|
+
/**
|
|
539
|
+
* Looks up a cached audio file by its synthesis parameters.
|
|
540
|
+
* Returns the cache entry if found, null otherwise.
|
|
541
|
+
*/
|
|
542
|
+
get(voiceId: string, modelId: string, text: string, voiceSettings: VoiceCacheSettings): Promise<VoiceCacheEntry | null>;
|
|
543
|
+
/**
|
|
544
|
+
* Gets the full path to a cached audio file
|
|
545
|
+
*/
|
|
546
|
+
getAudioPath(entry: VoiceCacheEntry): string;
|
|
547
|
+
/**
|
|
548
|
+
* Stores a synthesized audio file in the cache.
|
|
549
|
+
* The audio data should be provided as a Buffer.
|
|
550
|
+
*/
|
|
551
|
+
put(voiceId: string, modelId: string, text: string, voiceSettings: VoiceCacheSettings, audioData: Buffer, durationMs: number): Promise<VoiceCacheEntry>;
|
|
552
|
+
/**
|
|
553
|
+
* Removes a specific entry from the cache
|
|
554
|
+
*/
|
|
555
|
+
remove(key: string): Promise<boolean>;
|
|
556
|
+
/**
|
|
557
|
+
* Clears all entries from the cache
|
|
558
|
+
*/
|
|
559
|
+
clear(): Promise<number>;
|
|
560
|
+
/**
|
|
561
|
+
* Lists all entries in the cache
|
|
562
|
+
*/
|
|
563
|
+
list(): Promise<VoiceCacheEntry[]>;
|
|
564
|
+
/**
|
|
565
|
+
* Gets statistics about the cache
|
|
566
|
+
*/
|
|
567
|
+
getStats(): Promise<VoiceCacheStats>;
|
|
568
|
+
/**
|
|
569
|
+
* Prunes entries older than the specified age (in days)
|
|
570
|
+
*/
|
|
571
|
+
pruneOlderThan(days: number): Promise<number>;
|
|
572
|
+
/**
|
|
573
|
+
* Validates the cache by checking that all indexed files exist
|
|
574
|
+
* and removing orphaned entries
|
|
575
|
+
*/
|
|
576
|
+
validate(): Promise<{
|
|
577
|
+
valid: number;
|
|
578
|
+
removed: number;
|
|
579
|
+
}>;
|
|
580
|
+
}
|
|
581
|
+
|
|
460
582
|
interface RetryOptions {
|
|
461
583
|
retries?: number;
|
|
462
584
|
minDelayMs?: number;
|
|
@@ -470,6 +592,8 @@ interface VoiceSynthesisConfig {
|
|
|
470
592
|
voiceId: string;
|
|
471
593
|
modelId?: string;
|
|
472
594
|
outputFormat?: "mp3_44100_128" | "mp3_44100_192" | "pcm_16000" | "pcm_22050" | "pcm_24000";
|
|
595
|
+
/** Voice cache configuration. Set to false to disable caching entirely. */
|
|
596
|
+
cache?: VoiceCacheConfig | false;
|
|
473
597
|
}
|
|
474
598
|
/**
|
|
475
599
|
* Script segment from the generated JSON
|
|
@@ -518,7 +642,17 @@ interface VoiceSynthesisResult {
|
|
|
518
642
|
declare class VoiceSynthesizer {
|
|
519
643
|
private client;
|
|
520
644
|
private config;
|
|
645
|
+
private cache;
|
|
646
|
+
private cacheInitialized;
|
|
521
647
|
constructor(config: VoiceSynthesisConfig);
|
|
648
|
+
/**
|
|
649
|
+
* Ensures the cache is initialized before use
|
|
650
|
+
*/
|
|
651
|
+
private ensureCacheInitialized;
|
|
652
|
+
/**
|
|
653
|
+
* Gets the voice cache instance (if enabled)
|
|
654
|
+
*/
|
|
655
|
+
getCache(): VoiceCache | null;
|
|
522
656
|
/**
|
|
523
657
|
* List available voices (useful for finding voice IDs)
|
|
524
658
|
*/
|
|
@@ -535,8 +669,11 @@ declare class VoiceSynthesizer {
|
|
|
535
669
|
similarityBoost?: number;
|
|
536
670
|
style?: number;
|
|
537
671
|
useSpeakerBoost?: boolean;
|
|
672
|
+
/** Skip cache lookup (still stores result in cache) */
|
|
673
|
+
skipCache?: boolean;
|
|
538
674
|
}): Promise<{
|
|
539
675
|
durationMs: number;
|
|
676
|
+
fromCache: boolean;
|
|
540
677
|
}>;
|
|
541
678
|
/**
|
|
542
679
|
* Generate a sound effect from text description
|
package/dist/index.d.ts
CHANGED
|
@@ -457,6 +457,128 @@ declare function demoType(page: Page, selector: string, text: string, options?:
|
|
|
457
457
|
delayBetweenChars?: number;
|
|
458
458
|
}): Promise<void>;
|
|
459
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Voice settings that affect the generated audio output
|
|
462
|
+
*/
|
|
463
|
+
interface VoiceCacheSettings {
|
|
464
|
+
stability: number;
|
|
465
|
+
similarityBoost: number;
|
|
466
|
+
style: number;
|
|
467
|
+
useSpeakerBoost: boolean;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* A single entry in the voice cache
|
|
471
|
+
*/
|
|
472
|
+
interface VoiceCacheEntry {
|
|
473
|
+
key: string;
|
|
474
|
+
voiceId: string;
|
|
475
|
+
modelId: string;
|
|
476
|
+
text: string;
|
|
477
|
+
voiceSettings: VoiceCacheSettings;
|
|
478
|
+
audioFileName: string;
|
|
479
|
+
durationMs: number;
|
|
480
|
+
fileSizeBytes: number;
|
|
481
|
+
createdAt: string;
|
|
482
|
+
lastUsedAt: string;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Configuration for the voice cache
|
|
486
|
+
*/
|
|
487
|
+
interface VoiceCacheConfig {
|
|
488
|
+
/** Directory where cache files are stored */
|
|
489
|
+
cacheDir: string;
|
|
490
|
+
/** Whether caching is enabled (default: true) */
|
|
491
|
+
enabled?: boolean;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Statistics about the voice cache
|
|
495
|
+
*/
|
|
496
|
+
interface VoiceCacheStats {
|
|
497
|
+
totalEntries: number;
|
|
498
|
+
totalSizeBytes: number;
|
|
499
|
+
oldestEntry: string | null;
|
|
500
|
+
newestEntry: string | null;
|
|
501
|
+
hitCount: number;
|
|
502
|
+
missCount: number;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Voice cache manager for storing and retrieving synthesized audio.
|
|
506
|
+
* This helps avoid duplicate API calls to ElevenLabs for the same text/voice combinations.
|
|
507
|
+
*/
|
|
508
|
+
declare class VoiceCache {
|
|
509
|
+
private config;
|
|
510
|
+
private index;
|
|
511
|
+
private stats;
|
|
512
|
+
private indexDirty;
|
|
513
|
+
constructor(config: VoiceCacheConfig);
|
|
514
|
+
/**
|
|
515
|
+
* Gets the path to the cache index file
|
|
516
|
+
*/
|
|
517
|
+
private get indexPath();
|
|
518
|
+
/**
|
|
519
|
+
* Gets the path to the audio cache directory
|
|
520
|
+
*/
|
|
521
|
+
private get audioDir();
|
|
522
|
+
/**
|
|
523
|
+
* Whether caching is enabled
|
|
524
|
+
*/
|
|
525
|
+
get enabled(): boolean;
|
|
526
|
+
/**
|
|
527
|
+
* Initializes the cache directory and loads the index
|
|
528
|
+
*/
|
|
529
|
+
initialize(): Promise<void>;
|
|
530
|
+
/**
|
|
531
|
+
* Loads the cache index from disk
|
|
532
|
+
*/
|
|
533
|
+
private loadIndex;
|
|
534
|
+
/**
|
|
535
|
+
* Saves the cache index to disk
|
|
536
|
+
*/
|
|
537
|
+
saveIndex(): Promise<void>;
|
|
538
|
+
/**
|
|
539
|
+
* Looks up a cached audio file by its synthesis parameters.
|
|
540
|
+
* Returns the cache entry if found, null otherwise.
|
|
541
|
+
*/
|
|
542
|
+
get(voiceId: string, modelId: string, text: string, voiceSettings: VoiceCacheSettings): Promise<VoiceCacheEntry | null>;
|
|
543
|
+
/**
|
|
544
|
+
* Gets the full path to a cached audio file
|
|
545
|
+
*/
|
|
546
|
+
getAudioPath(entry: VoiceCacheEntry): string;
|
|
547
|
+
/**
|
|
548
|
+
* Stores a synthesized audio file in the cache.
|
|
549
|
+
* The audio data should be provided as a Buffer.
|
|
550
|
+
*/
|
|
551
|
+
put(voiceId: string, modelId: string, text: string, voiceSettings: VoiceCacheSettings, audioData: Buffer, durationMs: number): Promise<VoiceCacheEntry>;
|
|
552
|
+
/**
|
|
553
|
+
* Removes a specific entry from the cache
|
|
554
|
+
*/
|
|
555
|
+
remove(key: string): Promise<boolean>;
|
|
556
|
+
/**
|
|
557
|
+
* Clears all entries from the cache
|
|
558
|
+
*/
|
|
559
|
+
clear(): Promise<number>;
|
|
560
|
+
/**
|
|
561
|
+
* Lists all entries in the cache
|
|
562
|
+
*/
|
|
563
|
+
list(): Promise<VoiceCacheEntry[]>;
|
|
564
|
+
/**
|
|
565
|
+
* Gets statistics about the cache
|
|
566
|
+
*/
|
|
567
|
+
getStats(): Promise<VoiceCacheStats>;
|
|
568
|
+
/**
|
|
569
|
+
* Prunes entries older than the specified age (in days)
|
|
570
|
+
*/
|
|
571
|
+
pruneOlderThan(days: number): Promise<number>;
|
|
572
|
+
/**
|
|
573
|
+
* Validates the cache by checking that all indexed files exist
|
|
574
|
+
* and removing orphaned entries
|
|
575
|
+
*/
|
|
576
|
+
validate(): Promise<{
|
|
577
|
+
valid: number;
|
|
578
|
+
removed: number;
|
|
579
|
+
}>;
|
|
580
|
+
}
|
|
581
|
+
|
|
460
582
|
interface RetryOptions {
|
|
461
583
|
retries?: number;
|
|
462
584
|
minDelayMs?: number;
|
|
@@ -470,6 +592,8 @@ interface VoiceSynthesisConfig {
|
|
|
470
592
|
voiceId: string;
|
|
471
593
|
modelId?: string;
|
|
472
594
|
outputFormat?: "mp3_44100_128" | "mp3_44100_192" | "pcm_16000" | "pcm_22050" | "pcm_24000";
|
|
595
|
+
/** Voice cache configuration. Set to false to disable caching entirely. */
|
|
596
|
+
cache?: VoiceCacheConfig | false;
|
|
473
597
|
}
|
|
474
598
|
/**
|
|
475
599
|
* Script segment from the generated JSON
|
|
@@ -518,7 +642,17 @@ interface VoiceSynthesisResult {
|
|
|
518
642
|
declare class VoiceSynthesizer {
|
|
519
643
|
private client;
|
|
520
644
|
private config;
|
|
645
|
+
private cache;
|
|
646
|
+
private cacheInitialized;
|
|
521
647
|
constructor(config: VoiceSynthesisConfig);
|
|
648
|
+
/**
|
|
649
|
+
* Ensures the cache is initialized before use
|
|
650
|
+
*/
|
|
651
|
+
private ensureCacheInitialized;
|
|
652
|
+
/**
|
|
653
|
+
* Gets the voice cache instance (if enabled)
|
|
654
|
+
*/
|
|
655
|
+
getCache(): VoiceCache | null;
|
|
522
656
|
/**
|
|
523
657
|
* List available voices (useful for finding voice IDs)
|
|
524
658
|
*/
|
|
@@ -535,8 +669,11 @@ declare class VoiceSynthesizer {
|
|
|
535
669
|
similarityBoost?: number;
|
|
536
670
|
style?: number;
|
|
537
671
|
useSpeakerBoost?: boolean;
|
|
672
|
+
/** Skip cache lookup (still stores result in cache) */
|
|
673
|
+
skipCache?: boolean;
|
|
538
674
|
}): Promise<{
|
|
539
675
|
durationMs: number;
|
|
676
|
+
fromCache: boolean;
|
|
540
677
|
}>;
|
|
541
678
|
/**
|
|
542
679
|
* Generate a sound effect from text description
|