How andresayac/edge-tts works
Main Components
a. CLI Layer
• Entry Point (src/index.ts)
• Command Modules (src/commands/SynthesizeCommand.ts, src/commands/VoiceListCommand.ts)
• CLI Adapters (src/cli/edge-tts.ts)
b. Core Service Layer
• EdgeTTS Service (src/services/EdgeTTS.ts)
c. Configuration & Constants
• Config (src/config/constants.ts)
d. Build & Packaging
• Build Script (scripts/build.ts)
• Package Metadata (package.json, bun.lockb, .npmignore)
e. External Dependencies
• Microsoft Edge TTS Endpoint (cloud API or local Edge process)
• Node/Bun Runtime
Relationships & Data Flow
• CLI Entry → Dispatch to Command Modules
• Commands → Invoke EdgeTTS Service API
• EdgeTTS Service → HTTP/WebSocket call to Microsoft Edge TTS → Returns audio stream
• Service → Applies export methods (toBase64(), toFile(), toRaw()) → Returns to CLI
• CLI → Writes output to filesystem or stdout
Architectural Patterns & Principles
• Separation of Concerns:
• CLI parsing (src/cli)
• Command definitions (src/commands)
• Core business logic (src/services)
• Modularity & Extensibility: Each command is a plugin-like class extending a common interface
• Single Responsibility: Export functions (toFile/… ) isolated in service layer
• Build Pipeline: TypeScript → Bun bundler → npm package
Putting It All Together
CLI entrypoint → Command Handler → EdgeTTS Service → Microsoft Edge TTS → back to Service → Export Module → CLI output