protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.activity_tts_offline_mode); this.FindViewById(Resource.Id.btn_speak).SetOnClickListener(this); this.FindViewById(Resource.Id.btn_stop_speak).SetOnClickListener(this); this.FindViewById(Resource.Id.btn_download_model).SetOnClickListener(this); this.FindViewById(Resource.Id.close).SetOnClickListener(this); mEditText = (EditText)this.FindViewById(Resource.Id.edit_input); mTextView = (TextView)this.FindViewById(Resource.Id.textView); tv_download_progress = (TextView)this.FindViewById(Resource.Id.tv_download_progress); // Use customized parameter settings to create a offline TTS engine. mlTtsConfigs = new MLTtsConfig() // Setting the language for synthesis. .SetLanguage(MLTtsConstants.TtsEnUs) // Set the timbre. .SetPerson(MLTtsConstants.TtsSpeakerOfflineEnUsMaleEagle) // Set the speech speed. Range: 0.2–2.0 1.0 indicates 1x speed. .SetSpeed(1.0f) // Set the volume. Range: 0.2–2.0 1.0 indicates 1x volume. .SetVolume(1.0f) // set the synthesis mode. .SetSynthesizeMode(MLTtsConstants.TtsOfflineMode); mlTtsEngine = new MLTtsEngine(mlTtsConfigs); // Pass the TTS callback to the TTS engine. mlTtsEngine.SetTtsCallback(this); manager = MLLocalModelManager.Instance; this.SetOnResultCallback(this); handler = new Handler(new TtsOfflineHandlerCallBack(this)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_tts_online_mode); FindViewById(Resource.Id.btn_speak).SetOnClickListener(this); FindViewById(Resource.Id.btn_stop_speak).SetOnClickListener(this); FindViewById(Resource.Id.close).SetOnClickListener(this); mEditText = (EditText)FindViewById(Resource.Id.edit_input); mTextView = (TextView)FindViewById(Resource.Id.textView); // Method 1: Use the default parameter settings to create a TTS engine. // In the default settings, the source language is Chinese, the Chinese female voice is used, // the voice speed is 1.0 (1x), and the volume is 1.0 (1x). // MLTtsConfig mlConfigs = new MLTtsConfig(); // Method 2: Use customized parameter settings to create a TTS engine. mlConfigs = new MLTtsConfig() // Setting the language for synthesis. .SetLanguage(MLTtsConstants.TtsEnUs) // Set the timbre. .SetPerson(MLTtsConstants.TtsSpeakerFemaleEn) // Set the speech speed. Range: 0.2–4.0 1.0 indicates 1x speed. .SetSpeed(1.0f) // Set the volume. Range: 0.2–4.0 1.0 indicates 1x volume. .SetVolume(1.0f) // set the synthesis mode. .SetSynthesizeMode(MLTtsConstants.TtsOnlineMode); mlTtsEngine = new MLTtsEngine(mlConfigs); // Pass the TTS callback to the TTS engine. mlTtsEngine.SetTtsCallback(this); handler = new Handler(new TtsOnlineHandlerCallBack(this)); }