
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@pie-players/tts-server-core
Advanced tools
Core types, interfaces, and utilities for server-side Text-to-Speech (TTS) providers.
For the cross-package TTS architecture and browser/server flow, see TTS Architecture. This README focuses on the shared server-provider contracts.
This package provides the foundation for building server-side TTS providers that return audio with precise word-level timing metadata (speech marks) for synchronized highlighting.
npm install @pie-players/tts-server-core
import { BaseTTSProvider, type SynthesizeRequest, type SynthesizeResponse } from '@pie-players/tts-server-core';
export class MyTTSProvider extends BaseTTSProvider {
readonly providerId = 'my-tts';
readonly providerName = 'My TTS Service';
readonly version = '1.0.0';
async initialize(config: TTSServerConfig): Promise<void> {
this.config = config;
this.initialized = true;
}
async synthesize(request: SynthesizeRequest): Promise<SynthesizeResponse> {
this.ensureInitialized();
// Your synthesis logic here
const audio = await this.callTTSAPI(request.text);
const speechMarks = await this.getSpeechMarks(request.text);
return {
audio,
contentType: 'audio/mpeg',
speechMarks,
metadata: {
providerId: this.providerId,
voice: request.voice || 'default',
duration: 0,
charCount: request.text.length,
cached: false,
},
};
}
// ... implement other required methods
}
import { estimateSpeechMarks, adjustSpeechMarksForRate } from '@pie-players/tts-server-core';
// Generate estimated marks when provider doesn't support them
const marks = estimateSpeechMarks('Hello world');
// Adjust timing for different speech rates
const fasterMarks = adjustSpeechMarksForRate(marks, 1.5);
import { MemoryCache, generateHashedCacheKey } from '@pie-players/tts-server-core';
const cache = new MemoryCache();
// Generate cache key
const cacheKey = await generateHashedCacheKey({
providerId: 'my-tts',
text: 'Hello world',
voice: 'default',
});
// Check cache
const cached = await cache.get(cacheKey);
if (cached) {
return cached;
}
// Store in cache (24 hour TTL)
await cache.set(cacheKey, result, 86400);
SpeechMark - Word timing informationSynthesizeRequest - Synthesis request parametersSynthesizeResponse - Synthesis result with audio and marksVoice - Voice definitionServerProviderCapabilities - Provider feature flagsITTSServerProvider - Provider interfaceITTSCache - Cache interfaceBaseTTSProvider - Abstract base class for providersMemoryCache - In-memory cache implementationTTSError - Structured error classestimateSpeechMarks() - Generate estimated timingadjustSpeechMarksForRate() - Adjust for speech ratevalidateSpeechMarks() - Validate marksgenerateCacheKey() - Create cache keyhashText() - SHA-256 hash for cache keysAll providers return speech marks in this unified format:
interface SpeechMark {
time: number; // Milliseconds from audio start
type: 'word' | 'sentence' | 'ssml';
start: number; // Character index (inclusive)
end: number; // Character index (exclusive)
value: string; // The word text
}
Example:
[
{ "time": 0, "type": "word", "start": 0, "end": 5, "value": "Hello" },
{ "time": 340, "type": "word", "start": 6, "end": 11, "value": "world" }
]
MIT
FAQs
Core interfaces and types for server-side TTS providers
We found that @pie-players/tts-server-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.