mirror of https://github.com/ndarilek/tts-rs.git
Add ugly hack to prove that speech works.
This commit is contained in:
parent
32f57d8578
commit
1ac0b91981
|
@ -1,7 +1,10 @@
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
use tts::*;
|
use tts::*;
|
||||||
|
|
||||||
fn run() -> Result<(), Error> {
|
fn run() -> Result<(), Error> {
|
||||||
let mut tts = TTS::default()?;
|
let mut tts = TTS::default()?;
|
||||||
|
thread::sleep(Duration::from_secs(5));
|
||||||
let Features {
|
let Features {
|
||||||
utterance_callbacks,
|
utterance_callbacks,
|
||||||
..
|
..
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use jni::objects::{GlobalRef, JObject};
|
use jni::objects::{GlobalRef, JObject};
|
||||||
use jni::JNIEnv;
|
|
||||||
use jni::JavaVM;
|
use jni::JavaVM;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
@ -27,7 +26,7 @@ impl Android {
|
||||||
*backend_id += 1;
|
*backend_id += 1;
|
||||||
let native_activity = ndk_glue::native_activity();
|
let native_activity = ndk_glue::native_activity();
|
||||||
let vm = Self::vm()?;
|
let vm = Self::vm()?;
|
||||||
let env = vm.attach_current_thread()?;
|
let env = vm.attach_current_thread_permanently()?;
|
||||||
let tts = env.new_object(
|
let tts = env.new_object(
|
||||||
"android/speech/tts/TextToSpeech",
|
"android/speech/tts/TextToSpeech",
|
||||||
"(Landroid/content/Context;Landroid/speech/tts/TextToSpeech$OnInitListener;)V",
|
"(Landroid/content/Context;Landroid/speech/tts/TextToSpeech$OnInitListener;)V",
|
||||||
|
@ -69,7 +68,7 @@ impl Backend for Android {
|
||||||
println!("Speaking {}, {:?}", text, interrupt);
|
println!("Speaking {}, {:?}", text, interrupt);
|
||||||
let vm = Self::vm()?;
|
let vm = Self::vm()?;
|
||||||
println!("Retrieved");
|
println!("Retrieved");
|
||||||
let env = vm.attach_current_thread()?;
|
let env = vm.get_env()?;
|
||||||
println!("attached");
|
println!("attached");
|
||||||
let tts = self.tts.as_obj();
|
let tts = self.tts.as_obj();
|
||||||
let text = env.new_string(text)?;
|
let text = env.new_string(text)?;
|
||||||
|
|
Loading…
Reference in New Issue