Skip to main content
Back to plugins
@capgo/capacitor-speech-synthesis
Tutorial
by github.com/Cap-go

Speech Synthesis

Synthesize speech from text with full control over language, voice, pitch, rate, and volume.

Guide

Tutorial on Speech Synthesis

Using @capgo/capacitor-speech-synthesis

Speech Synthesis Plugin for synthesizing speech from text.

Install

bun add @capgo/capacitor-speech-synthesis
bunx cap sync

What This Plugin Exposes

  • speak - Speaks the given text with specified options. The utterance is added to the speech queue.
  • synthesizeToFile - Synthesizes speech to an audio file (Android/iOS only). Returns the file path where the audio was saved.
  • cancel - Cancels all queued utterances and stops current speech.
  • pause - Pauses speech immediately.

Example Usage

speak

Speaks the given text with specified options. The utterance is added to the speech queue.

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';

const result = await SpeechSynthesis.speak({
  text: 'Hello, world!',
  language: 'en-US',
  rate: 1.0,
  pitch: 1.0,
  volume: 1.0,
  queueStrategy: 'Add'
});
console.log('Utterance ID:', result.utteranceId);

synthesizeToFile

Synthesizes speech to an audio file (Android/iOS only). Returns the file path where the audio was saved.

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';

const result = await SpeechSynthesis.synthesizeToFile({
  text: 'Hello, world!',
  language: 'en-US'
});
console.log('Audio file saved at:', result.filePath);

cancel

Cancels all queued utterances and stops current speech.

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';

await SpeechSynthesis.cancel();

pause

Pauses speech immediately.

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';

await SpeechSynthesis.pause();

Full Reference

Keep going from Using @capgo/capacitor-speech-synthesis

If you are using Using @capgo/capacitor-speech-synthesis to plan native plugin work, connect it with @capgo/capacitor-speech-synthesis for the implementation detail in @capgo/capacitor-speech-synthesis, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.