Simple capacitor plugin for text-to-speech functionality on Android based on native text to speech capabilities. Based on the capacitor community text to speech plugin (which didn't work for me).
Register the plugin in your main activity:
import com.corvoanalytics.TTSPlugin;
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(TTSPlugin.class);
}
}
);
}
}
import { Plugins } from "@capacitor/core";
...
await Plugins.TTSPlugin.createTSS();
await Plugins.TTSPlugin.speak({ message: TEXT_TO_BE_SPOKEN });