public void Init()
        {
            _gcTextToSpeech = GCTextToSpeech.Instance;

            _networking = new Networking();
            _networking.NetworkResponseEvent += NetworkResponseEventHandler;
        }
Пример #2
0
        private void Awake()
        {
            if (_Instance != null)
            {
                Destroy(gameObject);
                return;
            }

            if (isDontDestroyOnLoad)
            {
                DontDestroyOnLoad(gameObject);
            }

            _Instance = this;

            _serviceLocator = new ServiceLocator();
            _serviceLocator.InitServices();

            _textToSpeechManager = _serviceLocator.Get <ITextToSpeechManager>();
            _mediaManager        = _serviceLocator.Get <IMediaManager>();

            _textToSpeechManager.GetVoicesSuccessEvent  += GetVoicesSuccessEventHandler;
            _textToSpeechManager.SynthesizeSuccessEvent += SynthesizeSuccessEventHandler;

            _textToSpeechManager.GetVoicesFailedEvent  += GetVoicesFailedEventHandler;
            _textToSpeechManager.SynthesizeFailedEvent += SynthesizeFailedEventHandler;
        }
Пример #3
0
        private void OnDestroy()
        {
            if (_Instance == this)
            {
                _textToSpeechManager.GetVoicesSuccessEvent  -= GetVoicesSuccessEventHandler;
                _textToSpeechManager.SynthesizeSuccessEvent -= SynthesizeSuccessEventHandler;

                _textToSpeechManager.GetVoicesFailedEvent  -= GetVoicesFailedEventHandler;
                _textToSpeechManager.SynthesizeFailedEvent -= SynthesizeFailedEventHandler;

                _Instance = null;
                _serviceLocator.Dispose();
            }
        }
        private void Start()
        {
            _gcTextToSpeech = GCTextToSpeech.Instance;

            _gcTextToSpeech.GetVoicesSuccessEvent  += _gcTextToSpeech_GetVoicesSuccessEvent;
            _gcTextToSpeech.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;

            _gcTextToSpeech.GetVoicesFailedEvent  += _gcTextToSpeech_GetVoicesFailedEvent;
            _gcTextToSpeech.SynthesizeFailedEvent += _gcTextToSpeech_SynthesizeFailedEvent;

            synthesizeButton.onClick.AddListener(SynthesizeButtonOnClickHandler);
            getVoicesButton.onClick.AddListener(GetVoicesButtonOnClickHandler);

            voicesDropdown.onValueChanged.AddListener(VoiceSelectedDropdownOnChangedHandler);
            voiceTypesDropdown.onValueChanged.AddListener(VoiceTypeSelectedDropdownOnChangedHandler);

            _provider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
            _provider.NumberFormat.NumberDecimalSeparator = ".";


            int           length   = Enum.GetNames(typeof(Enumerators.LanguageCode)).Length;
            List <string> elements = new List <string>();

            for (int i = 0; i < length; i++)
            {
                elements.Add(((Enumerators.LanguageCode)i).ToString());
            }

            languageCodesDropdown.ClearOptions();
            languageCodesDropdown.AddOptions(elements);
            languageCodesDropdown.value = 0;

            length = Enum.GetNames(typeof(Enumerators.VoiceType)).Length;
            elements.Clear();

            for (int i = 0; i < length; i++)
            {
                elements.Add(((Enumerators.VoiceType)i).ToString());
            }

            voiceTypesDropdown.ClearOptions();
            voiceTypesDropdown.AddOptions(elements);
            voiceTypesDropdown.value = 0;

            GetVoicesButtonOnClickHandler();
        }
Пример #5
0
        void Start()
        {
            StartCoroutine(API_getWords());
            StartCoroutine(PlayerInfo());

            mobileKeys = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false);


            MC = GCTextToSpeech.Instance;
            MC.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;
            MC.SynthesizeFailedEvent  += _gcTextToSpeech_SynthesizeFailedEvent;

            /*
             * myvoice.gender = Enumerators.SsmlVoiceGender.FEMALE;
             * myvoice.languageCode = "en_AU";
             * myvoice.name = "en-AU-Wavenet-A";
             */

            answer.onEndEdit.AddListener(val =>
            {
                if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter) || mobileKeys.status == TouchScreenKeyboard.Status.Done)
                {
                    Submit();
                }
            });

            answer.onValueChange.AddListener(val =>
            {
                if (answer.text.Length > 0)
                {
                    var myletter = answer.text.Substring(answer.text.Length - 1, 1);
                    speakLetter(myletter);
                }
            });

            switch (PlayerPrefs.GetString("voice"))
            {
            case "English":
                myvoice.languageCode = "en-US";
                myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
                myvoice.name         = "en-US-Wavenet-E";
                break;

            case "Español":
                myvoice.languageCode = "es-ES";
                myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
                myvoice.name         = "es-ES-Standard-A";
                break;

            case "Français":
                myvoice.languageCode = "fr-FR";
                myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
                myvoice.name         = "fr-FR-Wavenet-E";
                break;

            case "Portuguese":
                myvoice.languageCode = "pt-BR";
                myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
                myvoice.name         = "pt-BR-Wavenet-A";
                break;

            case "Italiano":
                myvoice.languageCode = "it-IT";
                myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
                myvoice.name         = "it-IT-Wavenet-B";
                break;
            }


            //Init GUI
            answer.text = "";
            score.text  = right.Count + " of " + (right.Count + wrong.Count);
            focusoninput();

            switch (PlayerPrefs.GetString("level"))
            {
            case "E": level.text = "Level: Easy"; break;

            case "M": level.text = "Level: Normal"; break;

            case "H": level.text = "Level: Hard"; break;
            }
        }