Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
@capacitor-community/text-to-speech
Advanced tools
Capacitor plugin for synthesizing speech from text.
@capacitor-community/text-to-speech
Capacitor community plugin for synthesizing speech from text.
Maintainer | GitHub | Social |
---|---|---|
Robin Genz | robingenz | @robin_genz |
npm install @capacitor-community/text-to-speech
npx cap sync
npm install @capacitor-community/text-to-speech@0.2.3
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);
// Initializes the Bridge
this.init(
savedInstanceState,
new ArrayList<Class<? extends Plugin>>() {
{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(TextToSpeech.class);
}
}
);
}
}
No configuration required for this plugin.
import { TextToSpeech } from '@capacitor-community/text-to-speech';
const speak = async () => {
await TextToSpeech.speak({
text: 'This is a sample text.',
locale: 'en_US',
speechRate: 1.0,
pitchRate: 1.0,
volume: 1.0,
category: 'ambient',
});
};
const stop = async () => {
await TextToSpeech.stop();
};
const getSupportedLanguages = async () => {
const languages = await TextToSpeech.getSupportedLanguages();
};
const getSupportedVoices = async () => {
const voices = await TextToSpeech.getSupportedVoices();
};
const setPitchRate = async () => {
await TextToSpeech.setPitchRate({
pitchRate: 1.5,
});
};
const setSpeechRate = async () => {
await TextToSpeech.setSpeechRate({
speechRate: 0.5,
});
};
speak(...)
stop()
getSupportedLanguages()
getSupportedVoices()
openInstall()
setPitchRate(...)
setSpeechRate(...)
speak(options: TTSOptions) => Promise<void>
Starts the TTS engine and plays the desired text.
Param | Type |
---|---|
options | TTSOptions |
stop() => Promise<void>
Stops the TTS engine.
getSupportedLanguages() => Promise<{ languages: string[]; }>
Returns a list of supported languages.
Returns: Promise<{ languages: string[]; }>
getSupportedVoices() => Promise<{ voices: SpeechSynthesisVoice[]; }>
Returns a list of supported voices.
Returns: Promise<{ voices: SpeechSynthesisVoice[]; }>
openInstall() => Promise<void>
Verifies proper installation and availability of resource files on the system.
setPitchRate(options: { pitchRate: number; }) => Promise<void>
Changes the pitch rate while the text is being played.
Only available for Android.
Param | Type |
---|---|
options | { pitchRate: number; } |
setSpeechRate(options: { speechRate: number; }) => Promise<void>
Changes the speech rate while the text is being played.
Only available for Android.
Param | Type |
---|---|
options | { speechRate: number; } |
Prop | Type | Description |
---|---|---|
text | string | Text to be spoken. |
locale | string | Language spoken in. Possible languages can be queried using getSupportedLanguages . Default: en-US |
speechRate | number | The speech rate. Default: 1.0 |
pitchRate | number | The pitch rate. Default: 1.0 |
volume | number | The volume. Default: 1.0 |
voice | number | The index of the selected voice. Possible voices can be queried using getSupportedVoices . Only available for Web. |
category | string | Select the iOS Audio session category. Possible values: ambient and playback Use playback to play audio even when the app is in the background. Only available for iOS. Default: ambient |
The SpeechSynthesisVoice interface represents a voice that the system supports.
Prop | Type | Description |
---|---|---|
default | boolean | Specifies whether the voice is the default voice for the current app (true ) or not (false ). |
lang | string | BCP 47 language tag indicating the language of the voice. Example: en-US |
localService | boolean | Specifies whether the voice is supplied by a local (true ) or remote (false ) speech synthesizer service. |
name | string | Human-readable name that represents the voice. Example: Microsoft Zira Desktop - English (United States) |
voiceURI | string | Type of URI and location of the speech synthesis service for this voice. Example: urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US |
See CHANGELOG.md.
See LICENSE.
FAQs
Capacitor plugin for synthesizing speech from text.
The npm package @capacitor-community/text-to-speech receives a total of 2,076 weekly downloads. As such, @capacitor-community/text-to-speech popularity was classified as popular.
We found that @capacitor-community/text-to-speech demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.