Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

⚡️ Capacitor plugin for synthesizing speech from text.

License

NotificationsYou must be signed in to change notification settings

capacitor-community/text-to-speech

Repository files navigation


Text to Speech

@capacitor-community/text-to-speech

Capacitor community plugin for synthesizing speech from text.


Maintainers

MaintainerGitHubSocial
Robin Genzrobingenz@robin_genz

Installation

npm install @capacitor-community/text-to-speechnpx cap sync

Configuration

No configuration required for this plugin.

Demo

A working example can be found here:robingenz/capacitor-plugin-demo

Usage

import{TextToSpeech}from'@capacitor-community/text-to-speech';constspeak=async()=>{awaitTextToSpeech.speak({text:'This is a sample text.',lang:'en-US',rate:1.0,pitch:1.0,volume:1.0,category:'ambient',queueStrategy:1});};conststop=async()=>{awaitTextToSpeech.stop();};constgetSupportedLanguages=async()=>{constlanguages=awaitTextToSpeech.getSupportedLanguages();};constgetSupportedVoices=async()=>{constvoices=awaitTextToSpeech.getSupportedVoices();};constisLanguageSupported=async(lang:string)=>{constisSupported=awaitTextToSpeech.isLanguageSupported({ lang});};

API

speak(...)

speak(options:TTSOptions)=>Promise<void>

Starts the TTS engine and plays the desired text.

ParamType
optionsTTSOptions

stop()

stop()=>Promise<void>

Stops the TTS engine.


getSupportedLanguages()

getSupportedLanguages()=>Promise<{languages:string[];}>

Returns a list of supported BCP 47 language tags.

Returns:Promise<{ languages: string[]; }>


getSupportedVoices()

getSupportedVoices()=>Promise<{voices:SpeechSynthesisVoice[];}>

Returns a list of supported voices.

Returns:Promise<{ voices: SpeechSynthesisVoice[]; }>


isLanguageSupported(...)

isLanguageSupported(options:{lang:string;})=>Promise<{supported:boolean;}>

Checks if a specific BCP 47 language tag is supported.

ParamType
options{ lang: string; }

Returns:Promise<{ supported: boolean; }>


openInstall()

openInstall()=>Promise<void>

Verifies proper installation and availability of resource files on the system.

Only available for Android.


addListener('onRangeStart', ...)

addListener(eventName:'onRangeStart',listenerFunc:(info:{start: number;end: number;spokenWord:string;})=>void)=>Promise<PluginListenerHandle>
ParamType
eventName'onRangeStart'
listenerFunc(info: { start: number; end: number; spokenWord: string; }) => void

Returns:Promise<PluginListenerHandle>


Interfaces

TTSOptions

PropTypeDescriptionDefaultSince
textstringThe text that will be synthesised when the utterance is spoken.
langstringThe language of the utterance. Possible languages can be queried usinggetSupportedLanguages."en-US"
ratenumberThe speed at which the utterance will be spoken at.1.0
pitchnumberThe pitch at which the utterance will be spoken at.1.0
volumenumberThe volume that the utterance will be spoken at.1.0
voicenumberThe index of the selected voice that will be used to speak the utterance. Possible voices can be queried usinggetSupportedVoices.
categorystringSelect the iOS Audio session category. Possible values:ambient andplayback. Useplayback to play audio even when the app is in the background. Only available for iOS."ambient"
queueStrategyQueueStrategySelect the strategy to adopt when several requests to speak overlap.QueueStrategy.Flush5.1.0

SpeechSynthesisVoice

TheSpeechSynthesisVoice interface represents a voice that the system supports.

PropTypeDescription
defaultbooleanSpecifies whether the voice is the default voice for the current app (true) or not (false).
langstringBCP 47 language tag indicating the language of the voice.
localServicebooleanSpecifies whether the voice is supplied by a local (true) or remote (false) speech synthesizer service.
namestringHuman-readable name that represents the voice.
voiceURIstringType of URI and location of the speech synthesis service for this voice.

PluginListenerHandle

PropType
remove() => Promise<void>

Enums

QueueStrategy

MembersValueDescription
Flush0UseFlush to stop the current request when a new request is sent.
Add1UseAdd to buffer the speech request. The request will be executed when all previous requests have been completed.

Changelog

SeeCHANGELOG.md.

License

SeeLICENSE.


[8]ページ先頭

©2009-2025 Movatter.jp