tryspeakeasy
v1.0.0
Published
Official Node.js/TypeScript SDK for the SpeakEasy API — affordable speech-to-text and text-to-speech for developers.
Maintainers
Readme
SpeakEasy Node.js SDK
Official Node.js/TypeScript client for the SpeakEasy API — affordable speech-to-text and text-to-speech for developers.
Installation
npm install tryspeakeasyQuick Start
import { SpeakEasy } from 'tryspeakeasy'
const se = new SpeakEasy('sk-se-your_api_key')
// Transcribe audio
const { text } = await se.transcribe({
url: 'https://example.com/audio.mp3',
})
console.log(text)
// Generate speech
const audio = await se.speech({
input: 'Hello world!',
voice: 'nova',
})Get your API key from the SpeakEasy dashboard.
Usage
Speech-to-Text
Transcribe audio files or URLs. Supports mp3, wav, flac, aac, opus, ogg, m4a, mp4, and webm (max 100 MB).
// From URL
const result = await se.transcribe({
url: 'https://example.com/podcast.mp3',
})
console.log(result.text)
// From file (Node.js)
import { readFileSync } from 'fs'
const file = new Blob([readFileSync('recording.mp3')])
const result = await se.transcribe({ file })
// With options
const result = await se.transcribe({
url: 'https://example.com/audio.mp3',
language: 'en',
speakerLabels: true,
wordTimestamps: true,
responseFormat: 'verbose_json',
})
console.log(result.segments) // timestamped segmentsResponse Formats
// JSON (default) — { text: string }
const json = await se.transcribe({ url, responseFormat: 'json' })
// Verbose JSON — includes segments with timestamps
const verbose = await se.transcribe({ url, responseFormat: 'verbose_json' })
// Plain text
const text = await se.transcribe({ url, responseFormat: 'text' })
// Subtitles
const srt = await se.transcribe({ url, responseFormat: 'srt' })
const vtt = await se.transcribe({ url, responseFormat: 'vtt' })Async with Webhook
For long audio files, provide a callbackUrl to get results asynchronously:
await se.transcribe({
url: 'https://example.com/long-podcast.mp3',
callbackUrl: 'https://your-server.com/webhook',
})
// Your server receives the result via POST when doneText-to-Speech
Convert text to audio with 40+ voices across 10 languages.
// Generate speech (returns ArrayBuffer)
const audio = await se.speech({
input: 'Welcome to SpeakEasy!',
voice: 'nova',
})
// Save to file (Node.js)
import { writeFileSync } from 'fs'
writeFileSync('output.mp3', Buffer.from(audio))
// With options
const audio = await se.speech({
input: 'Bonjour le monde!',
voice: 'amelie',
language: 'fr',
responseFormat: 'wav',
speed: 1.2,
})
// With word timestamps (returns JSON instead of audio)
const result = await se.speech({
input: 'Hello world',
wordTimestamps: true,
})
console.log(result.word_timestamps)
// [{ word: 'Hello', start: 0.0, end: 0.4 }, { word: 'world', start: 0.5, end: 0.9 }]Available Voices
| Language | Voices | |----------|--------| | English (US) | heart, bella, michael, alloy, aoede, kore, jessica, nicole, nova, river, sarah, sky, echo, eric, fenrir, liam, onyx, puck, adam, santa | | English (UK) | alice, emma, isabella, lily, daniel, fable, george, lewis | | Japanese | haruto, yuki | | Chinese | xiaobei, yunjian | | Spanish | carlos, maria | | French | pierre, amelie | | Hindi | arjun, priya | | Italian | luca, giulia | | Portuguese (BR) | pedro, ana |
Error Handling
import { SpeakEasy, SpeakEasyError } from 'tryspeakeasy'
try {
await se.transcribe({ url: 'https://example.com/audio.mp3' })
} catch (err) {
if (err instanceof SpeakEasyError) {
console.log(err.status) // 402, 429, etc.
console.log(err.message) // 'No active subscription'
}
}| Status | Meaning | |--------|---------| | 401 | Missing or invalid API key | | 403 | No active subscription | | 429 | Too many concurrent requests (max 10) |
Configuration
const se = new SpeakEasy('sk-se-your_api_key', {
// Override the base URL
baseUrl: 'https://staging.tryspeakeasy.io',
// Provide a custom fetch implementation
fetch: myCustomFetch,
})API Reference
| Method | Description |
|--------|-------------|
| transcribe(options) | Speech-to-text — transcribe audio files or URLs |
| speech(options) | Text-to-speech — generate audio from text |
Requirements
- Node.js 18+ (uses native
fetch) - A SpeakEasy account with an active subscription
Links
- SpeakEasy — Affordable Speech-to-Text & Text-to-Speech API
- Dashboard — API key management and usage monitoring
- Documentation — Full API reference
- Pricing — Usage-based pricing starting at $9/month
License
Built by SIÁN Agency
