87 releases

0.26.3 Jul 6, 2024
0.26.1 Apr 19, 2024
0.26.0 Feb 9, 2024
0.25.6 Sep 9, 2023
0.1.0 Dec 30, 2018

#118 in Audio

Download history 237/week @ 2025-01-19 222/week @ 2025-01-26 551/week @ 2025-02-02 413/week @ 2025-02-09 261/week @ 2025-02-16 358/week @ 2025-02-23 306/week @ 2025-03-02 397/week @ 2025-03-09 403/week @ 2025-03-16 312/week @ 2025-03-23 282/week @ 2025-03-30 350/week @ 2025-04-06 393/week @ 2025-04-13 355/week @ 2025-04-20 453/week @ 2025-04-27 384/week @ 2025-05-04

1,623 downloads per month
Used in 15 crates (14 directly)

MIT license

89KB
2.5K SLoC

Contains (JAR file, 55KB) gradle-wrapper.jar

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 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!

Dependencies

~0.3–43MB
~565K SLoC

OSZAR »