
Text to Speech
@capacitor-community/text-to-speech
Capacitor community plugin for native Firebase Crashlytics.
Maintainers
Mainteinance Status: Actively Maintained
Installation
To use npm
npm install @capacitor/text-to-speech
To use yarn
yarn add @capacitor/text-to-speech
Sync native files
npx cap sync
On iOS, no further steps are needed.
On Android, register the plugin in your main activity:
import com.getcapacitor.community.tts.TextToSpeech;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.init(
savedInstanceState,
new ArrayList<Class<? extends Plugin>>() {
{
add(TextToSpeech.class);
}
}
);
}
}
Configuration
No configuration required for this plugin.
Supported methods
Name | Android | iOS | Web |
---|
speak | ✅ | ✅ | ✅ |
stop | ✅ | ✅ | ✅ |
getSupportedLanguages | ✅ | ✅ | ✅ |
openInstall | ✅ | ✅ | ❌ |
setPitchRate | ✅ | ✅ | ❌ |
setSpeechRate | ✅ | ✅ | ❌ |
Usage
import "@capacitor-community/text-to-speech";
import { Plugins } from "@capacitor/core";
const { TextToSpeech } = Plugins;
TextToSpeech.speak({
text: "This is a sample text.",
locale: "en_US",
speechRate: 1.0,
pitchRate: 1,
volume: 1.0,
voice: 10,
category: "ambient",
});
TextToSpeech.stop();
TextToSpeech.getSupportedLanguages();
TextToSpeech.getSupportedVoices();
TextToSpeech.openInstall();
TextToSpeech.setPitchRate({
pitchRate: 1.5,
});
TextToSpeech.setSpeechRate({
speechRate: 0.5,
});