Go to file
mcb2003 729ece9a07 FFI: Make all functions with unsafe blocks completely unsafe.
This is better than using unsafe blocks inside the functions, as that
tells the compiler that the unsafeness won't leak out of the block,
which isn't true in this case as we're dealing with another unsafe
language.
2020-12-31 13:54:15 +00:00
.github/workflows Call rustup manually, since the action doesn't seem to work. 2020-12-30 14:50:36 -06:00
examples Make script executable. 2020-12-30 12:51:55 -06:00
src FFI: Make all functions with unsafe blocks completely unsafe. 2020-12-31 13:54:15 +00:00
winrt_bindings Remove unnecessary dependencies and bump versions. 2020-12-07 22:39:30 -06:00
.gitignore Add .gitignore. 2019-09-10 10:41:08 -05:00
Cargo.toml FFI: Create ffi Cargo feature and include ffi module. 2020-12-31 13:54:15 +00:00
Makefile.toml Build Android example as part of CI. 2020-12-30 12:28:07 -06:00
README.md README/packaging tweaks for Android. 2020-12-30 12:41:28 -06:00
build.rs Fix cargo fmt CI failure. 2020-11-17 16:36:33 -06:00
cbindgen.toml FFI: Add cbindgen config for generation of C/C++ headers. 2020-12-31 13:54:15 +00:00

README.md

TTS-RS

This library provides a high-level Text-To-Speech (TTS) interface supporting various backends. Currently supported backends are:

  • Windows
    • Screen readers/SAPI via Tolk (requires use_tolk Cargo feature)
    • WinRT
  • Linux via Speech Dispatcher
  • MacOS/iOS
    • AppKit on MacOS 10.13 and below
    • AVFoundation on MacOS 10.14 and above, and iOS
  • Android
  • WebAssembly

Android Setup

On most platforms, this library is plug-and-play. Because of JNI's complexity, Android setup is a bit more involved. In general, look to the Android example for guidance. Here are some rough steps to get going:

  • Set up Cargo.toml as the example does. Be sure to depend on ndk-glue.
  • Place Bridge.java appropriately in your app. This is needed to support various Android TTS callbacks.
  • Create a main activity similar to MainActivity.kt. In particular, you need to derive android.app.NativeActivity, and you need a System.loadLibrary(...) call appropriate for your app. System.loadLibrary(...) is needed to trigger JNI_OnLoad.
    • Even though you've loaded the library in your main activity, add a metadata tag to your activity in AndroidManifest.xml referencing it. Yes, this is redundant but necessary.
  • Set if your various build.gradle scripts to reference the plugins, dependencies, etc. from the example. In particular, you'll want to set up cargo-ndk-android-gradle and either depend on androidx.annotation or otherwise configure your app to keep the class rs.tts.Bridge.

And I think that should about do it. Good luck!