Ejemplo n.º 1
0
        //Java.Util.Locale lang;
        //Context context;

        //TextToSpeech textToSpeech;

        async public void Main_speaker(string Text)
        {
            //textToSpeech = new TextToSpeech(cuntext, cuntext, "com.google.android.tts");
            //var crossLocale = true;
            //CrossTextToSpeech.Current.Speak("I'm am Dhruv Kanojia, Devesh Shyngle, Ankit Passi, Nishit Bose", crossLocale);
            Plugin.TextToSpeech.TextToSpeech ttse = new Plugin.TextToSpeech.TextToSpeech();

            CrossLocale localeen;
            var         items = CrossTextToSpeech.Current.GetInstalledLanguages();
            //var lang = items.ToString();
            var evenScores = items.Where(i => true).ToList();

            Console.WriteLine("This is ITEM : " + evenScores);
            var lang = evenScores[110];

            Console.WriteLine("This is ITEM2 : " + lang);

            //foreach (var item in items)
            //{
            //    Console.WriteLine("This is ITEM : " + item);
            //}

            //localeen.Country = "en-IN";
            //localeen.Language = "en-IN";
            ttse.Speak(Text, false, lang);
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);
            PopulateLanguagesAsync();

            #region ControlsInitialisation

            tts             = new Plugin.TextToSpeech.TextToSpeech();
            textbox         = FindViewById <TextView>(Resource.Id.textBox);
            button          = FindViewById <Button>(Resource.Id.btnPlay);
            spitch          = FindViewById <SeekBar>(Resource.Id.seekerPitch);
            svolume         = FindViewById <SeekBar>(Resource.Id.seekerVolume);
            sspeed          = FindViewById <SeekBar>(Resource.Id.seekerSpeed);
            pitchtext       = FindViewById <TextView>(Resource.Id.textPitch);
            speedtext       = FindViewById <TextView>(Resource.Id.textSpeed);
            volumetext      = FindViewById <TextView>(Resource.Id.textVolume);
            languageSpinner = FindViewById <Spinner>(Resource.Id.langspinner);
            crosslocale     = new CrossLocale?();



            #endregion

            #region seekCalculation

            spitch.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    pitch          = e.Progress;
                    pitch         /= 100;
                    pitchtext.Text = string.Format("Pitch {0:0.00}", pitch);
                }
            };
            sspeed.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    speed          = e.Progress;
                    speed         /= 50;
                    speedtext.Text = string.Format("Speed {0:0.00}", speed);
                }
            };
            svolume.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    volume          = e.Progress;
                    volume         /= 100;
                    volumetext.Text = string.Format("Volume {0:0.00}", volume);
                }
            };
            #endregion

            languageSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs m) =>
            {
                crosslocale = locale.ElementAt(int.Parse(m.Id.ToString()));
            };



            button.Click += async delegate {
                button.Enabled = false;
                await tts.Speak(textbox.Text, crosslocale, pitch, speed, volume, CancellationToken.None);

                button.Enabled = true;
            };
        }