Beispiel #1
0
 public static TextToSpeechLib Instance()
 {
     if (instance == null)
     {
         instance = new TextToSpeechLib();
     }
     return(instance);
 }
Beispiel #2
0
 public PhoneCallBroadcastReceiver(Context context)
 {
     Log.Info(TAG, "Contructor");
     _context = context;
     _config  = Config.Instance();
     _tts     = TextToSpeechLib.Instance();
     _stt     = STTLib.Instance();
 }
Beispiel #3
0
 public SMSBroadcastReceiver(Context context)
 {
     Log.Info(TAG, "test contructor broadcast service");
     _messengeQueue = Model.MessengeQueue.GetInstance();
     _config        = Config.Instance();
     _context       = context;
     //_activity = act;
     ttsLib = TextToSpeechLib.Instance();
     _stt   = STTLib.Instance();
 }
Beispiel #4
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.Main_layout);
     RequestPermission();
     StartReadConfig();
     _tts = TextToSpeechLib.Instance();
     _tts.SetMainContext(this);
     MessengeServiceToStart  = new Intent(this, typeof(MessengeService));
     PhoneCallServiceToStart = new Intent(this, typeof(PhoneCallService));
     InitUiListener();
     Log.Info(TAG, "Start service Messenge.");
     if (savedInstanceState == null)
     {
         APP_RUNNIG = false;
     }
     //button.Click += delegate { button.Text = $"{count++} clicks!"; };
     //TextView callSetting = FindViewById<TextView>(Resource.Id.call_setting);
     //TextView smsSetting = FindViewById<TextView>(Resource.Id.sms_setting);
     //TextView status = FindViewById<TextView>(Resource.Id.status);
     //        callSetting.Click += delegate {
     //            {
     //                Intent callSettingIntent = new Intent(this, typeof(TestActivity));
     //                StartActivity(callSettingIntent);
     //            }
     //        };
     //        smsSetting.Click += delegate {
     //            Intent smsSettingIntent = new Intent(this, typeof(Test_STT_Activity));
     //StartActivity(smsSettingIntent);
     //};
     //-----------//
     //int count = 0;
     //if (savedInstanceState == null) APP_RUNNIG = false;
     //var imageButton = FindViewById<ImageButton>(Resource.Id.btn_power);
     //imageButton.Click += async delegate {
     //    if (!APP_RUNNIG)
     //    { // Start Application
     //        imageButton.SetImageResource(Resource.Drawable.start);
     //        //status.Text = "Click to turn off";
     //        //status.SetTextColor(Android.Graphics.Color.Red);
     //        Toast.MakeText(this, "Application Started", ToastLength.Long).Show();
     //        APP_RUNNIG = true;
     //        await StartApplication();
     //    }
     //    else
     //    { // Stop Application
     //        imageButton.SetImageResource(Resource.Drawable.end);
     //        //status.Text = "Click to turn on";
     //        //status.SetTextColor(Android.Graphics.Color.Green);
     //        Toast.MakeText(this, "Application Stopped", ToastLength.Long).Show();
     //        APP_RUNNIG = false;
     //        await StopApplication();
     //    }
     //};
 }
Beispiel #5
0
        async Task StartTTS(string text)
        {
            TextToSpeechLib tts = TextToSpeechLib.Instance();

            //text = "Hello";
            text = "Và tôi cầm lấy đóm, vo viên một điếu. Tôi rít một hơi xong, thông điếu\nrồi mới đặt vào lòng lão. Lão bỏ thuốc, nhưng chưa hút vội. Lão cầm lấy\nđóm, gạt tàn, và bảo :\n- Có lẽ tôi bán con chó đấy, ông giáo ạ";
            if (!string.IsNullOrEmpty(text))
            {
                //CheckLangHasIntall();
                await tts.SpeakMessenger(text);
            }
        }
Beispiel #6
0
        //private IList<String> _voices;
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Layout_Speech_Setting);
            SetBehavior();
            ttsLib                 = TextToSpeechLib.Instance();
            _listLang              = new List <string> {
            };
            btn_getInstance.Click += delegate {
                ttsLib = TextToSpeechLib.Instance();
            };

            btn_getEngines.Click += async delegate {
                await GetEngines();
            };

            spn_engines.ItemSelected += async(object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                _selectEngine = _listEngines[(int)e.Id];
                int i = await GetLanguageSupportByEngine(_selectEngine);

                await ttsLib.GetTTS(this);
            };
            spn_lang.ItemSelected += async(object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                //var s = ((Spinner)sender).GetItemAtPosition((int)e.Id);
                //Log.Debug(TAG, s.ToString());
                //_selectLang = new Locale("en-US");
                //_selectLang = _languageSupport.F(t => t.DisplayLanguage == langAvailable[(int)e.Id]);
                _selectLang = new Locale(_listLang[(int)e.Id]);
                Log.Debug(TAG, _listLang[(int)e.Id]);
                ttsLib.SetLang(_selectLang);
            };
            btn_Speak.Click += async delegate
            {
                //ttsLib.CreateTtsAsync(this,);
                int i = await ttsLib.SpeakMessenger("ss");

                Log.Info(TAG, "result speak " + i.ToString());
            };
            // Create your application here
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //Load Font
            CalligraphyConfig.InitDefault(new CalligraphyConfig.Builder()
                                          .SetDefaultFontPath("Fonts/HELR45W.ttf")
                                          .SetFontAttrId(Resource.Attribute.fontPath)
                                          .Build());
            SetContentView(Resource.Layout.Speech);
            _changeEngine = false;
            _tts          = TextToSpeechLib.Instance();
            _config       = Config.Instance();
            // Create your application here
            Button btn_engine = FindViewById <Button>(Resource.Id.item_1);
            Button btn_test   = FindViewById <Button>(Resource.Id.item_3);
            Button btn_ok     = FindViewById <Button>(Resource.Id.item_4);

            spn_eng  = FindViewById <Spinner>(Resource.Id.spinner_engine);
            spn_lang = FindViewById <Spinner>(Resource.Id.spinner_lang);

            btn_engine.Click += async delegate {
                await BtnEngineClick();

                //GetLangSTT();
            };

            btn_test.Click += async delegate {
                var locale = new Locale(_config.GetTtsLang());
                if (_changeEngine)
                {
                    await _tts.GetTTS(this);
                }
                _changeEngine = false;
                //await SampleText();

                /*TODO
                 * ADD funtion get messenger sample for test tts config
                 */

                _tts.SetLang(locale);
                _config.RunningSMSHandle = false;
                var k = await _tts.SpeakMessenger("this is messenger test");
            };

            spn_eng.ItemSelected += async(object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                Log.Info(TAG, "Select Engine");
                _changeEngine        = true;
                _selectEngine        = _listEngine[(int)e.Id];
                _listLangDisplayName = new List <string>();
                _listLangCode        = new List <string>();
                _listLangCollect     = await _tts.GetLanguageSupportByEngineAsync(this, _selectEngine);

                foreach (var it in _listLangCollect)
                {
                    tmp = it;
                    _listLangDisplayName.Add(it.DisplayName);
                    _listLangCode.Add(it.ISO3Language);
                }
                var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, _listLangDisplayName);
                spn_lang.Adapter = adapter;
            };

            spn_lang.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                _selectLang = _listLangCode[(int)e.Id];
            };
            btn_ok.Click += delegate {
                _config.SetTtsLang(_selectLang);
                _config.SetTtsEngine(_selectEngine);
                _config.UpdateConfig = true;
                _config.WriteConfig  = true;
            };
        }
Beispiel #8
0
 public UtteranceProgressLs(TextToSpeechLib p_parent)
 {
     _parent = p_parent;
 }