public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Success) { if (_spokenWord != null) { if (_spokenWord.IsSpeaking) { _spokenWord.Stop(); } if (Locale.Default.ISO3Language.ToLower() == "eng") { Locale english = new Locale("en", "gbr"); _spokenWord.SetLanguage(english); } if (Locale.Default.ISO3Language.ToLower() == "spa") { Locale spanish = new Locale("es", "ESP"); _spokenWord.SetLanguage(spanish); } if (Locale.Default.ISO3Language.ToLower() == "fra") { Locale french = new Locale("fr", "FRA"); _spokenWord.SetLanguage(french); } } } }
public void Speak(string text, bool force = false) { m_text = text; m_textToSpeech.Stop(); m_force = force; if (!Sound && !force) { return; } Console.WriteLine("Speak TTS {0} {1} {2} --> {3}. Available: {4}", m_language, SpeechRate, m_textToSpeech.Language, text, m_textToSpeech.IsLanguageAvailable(m_language)); m_textToSpeech.SetLanguage(m_language); m_textToSpeech.SetSpeechRate(SpeechRate); m_textToSpeech.SetPitch(PitchMultiplier); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { // 5.0, API 21 string utteranceId = m_text.GetHashCode() + ""; m_textToSpeech.Speak(m_text, QueueMode.Flush, null, utteranceId); } else { m_textToSpeech.Speak(m_text, QueueMode.Flush, null); } }
// Interface method required for IOnInitListener void TextToSpeech.IOnInitListener.OnInit(OperationResult status) { // if we get an error, default to the default language if (status == OperationResult.Error) { textToSpeech.SetLanguage(Java.Util.Locale.Default); } // if the listener is ok, set the lang if (status == OperationResult.Success) { textToSpeech.SetLanguage(lang); } if ((current_dir != -1) && (current_file != -1)) { string a = string.Format("Continuing the book from folder {0}, chapter {1}", current_dir, current_file + 1); textToSpeech.Speak(a, QueueMode.Flush, null); Task.Delay(3500).Wait(); StopPlayer(); filePath = files[current_file].FullName; AddTxt(filePath); StartPlayerAsync(); } }
private void BtnSpeak_Click(object sender, EventArgs e) { //ttsClient.Speak("김프로님 준비하십시요",QueueMode.Add,null); //ttsClient.Speak("전방에 과속 방지턱이 있습니다", QueueMode.Add, null); //ttsClient.Speak("영원히 당신만을 사랑합니다", QueueMode.Add, null); //ttsClient.Speak("How are you", QueueMode.Add, null); //ttsClient.Speak("I love you forever", QueueMode.Add, null); ttsClient.Speak("아이 러브 유 포에버", QueueMode.Add, null); //Thread.Sleep(8000); ttsClient.SetLanguage(Java.Util.Locale.English); ttsClient.Speak("How are you", QueueMode.Add, null); ttsClient.Speak("I love you forever", QueueMode.Add, null); //Thread.Sleep(5000); ttsClient.SetLanguage(Java.Util.Locale.China); ttsClient.Speak("我永远只爱你一个人.", QueueMode.Add, null); //Thread.Sleep(3000); ttsClient.SetLanguage(Java.Util.Locale.Germany); ttsClient.Speak("Ich liebe dich nur für immer.", QueueMode.Add, null); }
public void OnInit([GeneratedEnum] OperationResult status) { if (status.Equals(OperationResult.Success)) { var p = new Dictionary <string, string> (); speaker.SetLanguage(Locale.French); speaker.Speak(toSpeak, QueueMode.Flush, p); } }
void TextToSpeech.IOnInitListener.OnInit(OperationResult status) { if (status == OperationResult.Error) { textToSpeech.SetLanguage(Java.Util.Locale.Default); } if (status == OperationResult.Success) { textToSpeech.SetLanguage(lang); } }
public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Success) { _textToSpeech.SetLanguage(_lang); } else { _textToSpeech.SetLanguage(Locale.Default); } }
public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Error) { textToSpeech.SetLanguage(Java.Util.Locale.Default); } if (status == OperationResult.Success) { textToSpeech.SetLanguage(locale); } }
public void OnInit(OperationResult status) { if (status.Equals(OperationResult.Success)) { textToSpeech.SetLanguage(Java.Util.Locale.Default); Console.WriteLine("textToSpeech init: Language {0}", Java.Util.Locale.Default.DisplayLanguage); } else { System.Diagnostics.Debug.WriteLine("was quiet"); } }
public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Error) { textToSpeech.SetLanguage(Java.Util.Locale.Default); } // if the listener is ok, set the lang if (status == OperationResult.Success) { textToSpeech.SetLanguage(lang); } }
public void OnInit(OperationResult status) { if (status.Equals(OperationResult.Success)) { speaker.SetLanguage(Locale.ForLanguageTag("sv-SE")); if ((int)speaker.IsLanguageAvailable(Locale.ForLanguageTag(language)) > 0) { speaker.SetLanguage(Locale.ForLanguageTag(language)); } speaker.Speak(toSpeak, QueueMode.Flush, null, null); } }
void TextToSpeech.IOnInitListener.OnInit(OperationResult status) { // if we get an error, default to the default language if (status == OperationResult.Error) { textToSpeech.SetLanguage(Java.Util.Locale.Default); } // if the listener is ok, set the lang if (status == OperationResult.Success) { textToSpeech.SetLanguage(lang); } }
// Tts Engine method called when Tts is initialized. public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Error) { tts.SetLanguage(Locale.Default); } else if (status == OperationResult.Success) { tts.SetLanguage(Locale.English); } TtsInitialized(this, new EventArgs()); }
public void OnInit([GeneratedEnum] OperationResult status) { // if we get an error, default to the default language if (status == OperationResult.Error) { tts.SetLanguage(Java.Util.Locale.Default); } // if the listener is ok, set the lang if (status == OperationResult.Success) { tts.SetLanguage(lang); } }
private void DoSpeak(string text) { _speaker.SetLanguage(new Locale("es", "ES")); var p = new Dictionary <string, string>(); _speaker.Speak(text, QueueMode.Flush, p); }
public void OnInit([GeneratedEnum] OperationResult status) { if (status.Equals(OperationResult.Success)) { textToSpeech.SetLanguage(Java.Util.Locale.Default); } }
public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Success) { _tts.SetLanguage(Locale.Us); } }
public void OnInit(OperationResult status) { if (status == OperationResult.Error) { mTts.SetLanguage(Java.Util.Locale.Default); } }
/// <summary> /// 实现 TextToSpeech.IOnInitListener 接口方法 /// 初始化TTS /// </summary> /// <param name="status"></param> public void OnInit([GeneratedEnum] OperationResult status) { // if (status != TextToSpeech.SUCCESS) --> 安卓源码 if (status.ToString() != "Success") { // 返回并非成功结果, 继续弹出TTS语音选择界面 InitTextToSpeech(); return; } if (mTextToSpeech.IsLanguageAvailable(Java.Util.Locale.Uk) >= 0) { mTextToSpeech.SetLanguage(Java.Util.Locale.Uk); } mTextToSpeech.SetPitch(1f); mTextToSpeech.SetSpeechRate(1f); mTTS_Init_Success = true; System.Threading.Tasks.Task.Run(() => { Looper.Prepare(); Toast.MakeText(((Activity)Xamarin.Forms.Forms.Context), "TTS启动成功", ToastLength.Long).Show(); Looper.Loop(); }); }
/// <summary> /// Process results from started activities. /// </summary> protected override void OnActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RECOGNIZER_RESULT && resultCode == RESULT_OK) { var matches = data.GetStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); var speechText = FindViewById <TextView>(R.Ids.speechText); recognizedText = matches.Get(0); speechText.SetText(recognizedText); var checkIntent = new Intent(); checkIntent.SetAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); StartActivityForResult(checkIntent, SPEECH_RESULT); } if (requestCode == SPEECH_RESULT) { if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { textToSpeech = new TextToSpeech(this, this); textToSpeech.SetLanguage(Locale.US); } else { // TTS data not yet loaded, try to install it var ttsLoadIntent = new Intent(); ttsLoadIntent.SetAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); StartActivity(ttsLoadIntent); } } base.OnActivityResult(requestCode, resultCode, data); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.speak); var btnSayIt = FindViewById <Button>(Resource.Id.btnSpeak); var editWhatToSay = FindViewById <EditText>(Resource.Id.editSpeech); context = btnSayIt.Context; textToSpeech = new TextToSpeech(this, null, "com.google.android.tts"); lang = Java.Util.Locale.Default; textToSpeech.SetLanguage(lang); // set the speed and pitch textToSpeech.SetPitch(1.00f); textToSpeech.SetSpeechRate(.8f); // connect up the events btnSayIt.Click += delegate { // if there is nothing to say, don't say it if (!string.IsNullOrEmpty(editWhatToSay.Text)) { textToSpeech.Speak(editWhatToSay.Text, QueueMode.Flush, null); } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); spokenHistoryListArray = Intent.GetStringArrayExtra("history_list"); List <string> spokenHistoryList = spokenHistoryListArray.ToList(); // Create your application here SetContentView(Resource.Layout.History); spokenHistoryListView = FindViewById <ListView>(Resource.Id.myListView); HistoryListViewAdapter adapter = new HistoryListViewAdapter(this, spokenHistoryList); spokenHistoryListView.Adapter = adapter; context = spokenHistoryListView.Context; textToSpeech = new TextToSpeech(this, this, "com.google.android.tts"); lang = Java.Util.Locale.Default; textToSpeech.SetLanguage(lang); textToSpeech.SetPitch(.80f); textToSpeech.SetSpeechRate(1f); spokenHistoryListView.ItemClick += SpokenHistoryListView_ItemClick; }
private void InvokeRead(string TextToRead, long MillisecValue) { var editWhatToSay = FindViewById <EditText>(Resource.Id.etxtTTS); editWhatToSay.Text = TextToRead; NeedToSpeak = true; if (!string.IsNullOrEmpty(TextToRead)) { // set up the TextToSpeech object // third parameter is the speech engine to use textToSpeech = new TextToSpeech(this, this, "com.google.android.tts"); // set up the langauge spinner // set the top option to be default var langAvailable = new List <string> { "Default" }; // our spinner only wants to contain the languages supported by the tts and ignore the rest var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList(); foreach (var locale in localesAvailable) { LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale); switch (res) { case LanguageAvailableResult.Available: langAvailable.Add(locale.DisplayLanguage); break; case LanguageAvailableResult.CountryAvailable: langAvailable.Add(locale.DisplayLanguage); break; case LanguageAvailableResult.CountryVarAvailable: langAvailable.Add(locale.DisplayLanguage); break; } } langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList(); var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable); //spinLanguages.Adapter = adapter; // set up the speech to use the default langauge // if a language is not available, then the default language is used. lang = Java.Util.Locale.Default; textToSpeech.SetLanguage(lang); textToSpeech = new TextToSpeech(this, this, "com.google.android.tts"); textToSpeech.Speak(TextToRead, QueueMode.Flush, null, null); var btnAction = FindViewById <ImageButton>(Resource.Id.imgBtnListen); btnAction.SetImageResource(Resource.Drawable.micspeak); //@android:drawable/presence_audio_online + Android.Resource.Drawable.PresenceAudioOnline + Android.Resource.Drawable.IcDialogInfo NeedToSpeak = false; } }
public void OnInit([GeneratedEnum] OperationResult status) { if (status != OperationResult.Error) { mTts.SetLanguage(Locale.Us); speakUp(); } }
public void OnInit([GeneratedEnum] OperationResult status) { if (status == OperationResult.Success) { tts.SetLanguage(Locale.English); Speak(); } }
public void OnInit(OperationResult status) { if (status.Equals(OperationResult.Success)) { speaker.SetLanguage(Locale.English); SpeakIt(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); textToSpeech = new TextToSpeech(this, this, "com.google.android.tts"); textToSpeech.SetLanguage(Java.Util.Locale.Default); textToSpeech.SetPitch(1f); textToSpeech.SetSpeechRate(1f); }
TTS(string voice) { m_language = UtilsDroid.LocaleFromString(voice, false); m_textToSpeech = new TextToSpeech(Application.Context, this, "com.google.android.tts"); m_textToSpeech.SetLanguage(m_language); Console.WriteLine("Initializing TTS {0} --> {1}", voice, m_language); }
private void InitTTSMethod() { var btnSayIt = FindViewById <Button>(Resource.Id.btnSpeakEmailForm); var editWhatToSay = FindViewById <EditText>(Resource.Id.etxtTTSEmailForm); // set up the TextToSpeech object // third parameter is the speech engine to use textToSpeech = new TextToSpeech(this, this, "com.google.android.tts"); // set up the langauge spinner // set the top option to be default var langAvailable = new List <string> { "Default" }; // our spinner only wants to contain the languages supported by the tts and ignore the rest var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList(); foreach (var locale in localesAvailable) { LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale); switch (res) { case LanguageAvailableResult.Available: langAvailable.Add(locale.DisplayLanguage); break; case LanguageAvailableResult.CountryAvailable: langAvailable.Add(locale.DisplayLanguage); break; case LanguageAvailableResult.CountryVarAvailable: langAvailable.Add(locale.DisplayLanguage); break; } } langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList(); //var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable); //spinLanguages.Adapter = adapter; // set up the speech to use the default langauge // if a language is not available, then the default language is used. lang = Java.Util.Locale.Default; textToSpeech.SetLanguage(lang); // connect up the events btnSayIt.Click += delegate { // if there is nothing to say, don't say it if (!string.IsNullOrEmpty(editWhatToSay.Text)) { textToSpeech.Speak(editWhatToSay.Text, QueueMode.Flush, null, null); } }; }
public static void PlayTTS(Context context, string text, float rate, bool queueflush) { TextToSpeech tts = new TextToSpeech(context, null, "com.google.android.tts"); tts.SetSpeechRate(rate); tts.SetLanguage(Locale.Default); QueueMode mode = queueflush ? QueueMode.Flush : QueueMode.Add; tts.Speak(text, mode, null, null); }