This pull request enhances the Text-to-Speech capabilities by integrating the Supertonic TTS model into the existing Java and Kotlin APIs. It provides developers with new tools and clear examples to generate speech from text using this model, expanding the range of available TTS options and simplifying their adoption within Java and Kotlin projects.
This pull request significantly refactors the Java Native Interface (JNI) layer for the `sherpa-onnx` library, primarily enhancing the `OfflineTts` component. The changes introduce more robust error handling in various API constructors by validating native object initialization. Furthermore, the callback mechanism for Text-to-Speech operations has been streamlined, offering more convenient `java.util.function.Consumer` based interfaces in Java while simplifying the underlying C++ JNI implementation.
### Highlights
* **Improved Error Handling in Constructors**: Added `IllegalArgumentException` throws in constructors of several `sherpa-onnx` Java API classes (e.g., `AudioTagging`, `KeywordSpotter`, `OfflineTts`) if the native object creation (`newFromFile`) returns a null pointer (0). This makes the API more robust by failing fast on invalid configurations.
* **Streamlined Offline TTS Callbacks**: The `OfflineTts` class now provides new `generateWithCallback` and `generateWithConfigAndCallback` overloads that accept `java.util.function.Consumer<float[]>` for simpler, more idiomatic Java callback usage. This reduces boilerplate for users who only need to consume audio samples.
* **Simplified JNI Callback Implementation**: The native C++ code (`offline-tts.cc`) has been refactored to remove separate handling for `Consumer` and `Function` interfaces. All callbacks are now handled uniformly through the `OfflineTtsCallback` interface, simplifying the JNI bridge logic.
* **Removed Unused Imports and Code**: The `PocketTts.java` example file was cleaned up by removing unused `Consumer` and `Function` imports and simplifying lambda expressions, reflecting the changes in the `OfflineTts` API.
* **Added `getNumSpeakers()` to `OfflineTts`**: A new method `getNumSpeakers()` was added to the `OfflineTts` class, providing access to the number of speakers supported by the TTS engine.