예제 #1
0
        public SpeechService()
        {
            this.textToSpeech = new TextToSpeech(Application.Context, this);
            this.textToSpeech.SetOnUtteranceProgressListener(this);

            this.inFlightSpeech = new ConcurrentDictionary<int, AsyncSubject<Unit>>();
        }
 public override void StartNarration(string textInfo)
 {
     txtToSpeech = new TextToSpeech(new Ozeki.VoIP.Media.AudioFormat(8000, 1, 16, 20));
     txtToSpeech.Stopped += new EventHandler<EventArgs>(txtToSpeech_Stopped);
     OnNarrationStarting();
     txtToSpeech.AddText(textInfo);
     txtToSpeech.StartStreaming();
 }
        public void TestCreateFromTts()
        {
            TextToSpeech tts = new TextToSpeech { Message = "this is TTS message from csharp client" };
            ResourceId resourceId = Client.CampaignSoundsApi.CreateFromTts(tts);
            CampaignSound campaignSound = Client.CampaignSoundsApi.Get(resourceId.Id);
            Assert.AreEqual(resourceId.Id, campaignSound.Id);
            Assert.Greater(campaignSound.LengthInSeconds, 2);

            CampaignSound sound = Client.CampaignSoundsApi.CreateFromTtsAndGetSoundDetails(tts, "id,name");
            Assert.NotNull(sound.Id);
            Assert.NotNull(sound.Name);
            Assert.Null(sound.Status);
            Assert.AreEqual(sound.Id, campaignSound.Id);
        }
        public void TestCreateFromTts()
        {
            string responseJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSound.json");
            string requestJson = GetJsonPayload("/campaigns/campaignSoundsApi/request/createFromTts.json");
            var restRequest = MockRestResponse(responseJson);

            TextToSpeech textToSpeech = new TextToSpeech
            {
                Voice = Voice.MALE1,
                Message = "This is a TTS sound"
            };

            ResourceId id = Client.CampaignSoundsApi.CreateFromTts(textToSpeech);

            Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
        }
        public void TestCreateFromTtsAndGetSoundDetails()
        {
            string responseJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSoundWithDetails.json");
            string requestJson = GetJsonPayload("/campaigns/campaignSoundsApi/request/createFromTts.json");
            var restRequest = MockRestResponse(responseJson);

            TextToSpeech textToSpeech = new TextToSpeech
            {
                Voice = Voice.MALE1,
                Message = "This is a TTS sound"
            };

            CampaignSound sound = Client.CampaignSoundsApi.CreateFromTtsAndGetSoundDetails(textToSpeech, FIELDS);

            Assert.That(Serializer.Serialize(sound), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
            Assert.That(restRequest.Value.Parameters, Has.None.Matches<Parameter>(p => p.Name.Equals("FIELDS") && p.Value.Equals(FIELDS)));
        }
        void call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            message = "Call state: " +  e.State;

            if (e.State == CallState.Answered)
            {
                try
                {
                    TextToSpeech  TTS = new TextToSpeech();

                    mediaSender.AttachToCall(call);
                    connector.Connect(TTS, mediaSender);
                    TTS.AddAndStartText("Hello World!");
                    //call.BlindTransfer("**13000");
                    //message = "Transfered";
                }
                catch(Exception e1) { message = e1.ToString(); }
            }
            if (e.State == CallState.InCall)
            {
                message = "InCall";
            }
            if (e.State == CallState.Transferring)
            {
                message = "Transferring";
            }
            if (e.State == CallState.Ringing)
            {
                message = "Ringing";
            }
            if (e.State == CallState.Completed)
            {
                message = "Completed";
                done =1;
            }
        }
 public ResourceId CreateFromTts(TextToSpeech textToSpeech)
 {
     return Client.Post<ResourceId>(SOUNDS_TTS_PATH, textToSpeech);
 }
 /// <summary>
 /// Use this API to create a sound file via a supplied string of text.
 /// </summary>
 /// <param name="textToSpeech">TTS object to create</param>
 /// <param name="fields">Limit text fields returned. Example fields=limit,offset,items(id,message)</param>
 /// <returns> CampaignSound object with sound details</returns>
 /// <exception cref="BadRequestException">          in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
 /// <exception cref="UnauthorizedException">        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
 /// <exception cref="AccessForbiddenException">     in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
 /// <exception cref="ResourceNotFoundException">    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
 /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
 /// <exception cref="CallfireApiException">         in case HTTP response code is something different from codes listed above.</exception>
 /// <exception cref="CallfireClientException">      in case error has occurred in client.</exception>
 public CampaignSound CreateFromTtsAndGetSoundDetails(TextToSpeech textToSpeech, string fields)
 {
     var queryParams = ClientUtils.BuildQueryParams("fields", fields);
     return Client.Post<CampaignSound>(SOUNDS_TTS_PATH, textToSpeech, queryParams);
 }
예제 #9
0
        private void CallPressed(string phoneNumber)
        {
            Logger.Log("Calling " + phoneNumber);

            WaveStreamPlayback waveStream = null;

            initiatedCall = apiExt.CreateCall(UsedPhoneNumber, phoneNumber, phoneNumber);
            if (initiatedCall == null)
                return;
            bool transferStarted = false;
            initiatedCall.CallStateChanged += (sender, e) =>
            {
                try
                {

                    if (e.Item == CallState.Answered)
                    {
                        if (transferStarted)
                        {
                            initiatedCall.DisconnectAudioSender(waveStream);
                            waveStream.Dispose();

                            var tts = new TextToSpeech();

                            tts.Stopped += (sender1, e1)=>{
                                                              tts.Dispose();
                                                              initiatedCall.HangUp();
                                                          };

                            initiatedCall.ConnectAudioSender(tts);
                            tts.AddAndStartText(string.Format("Calling {0} has failed. Please try again later.", phoneNumber));
                            return;
                        }

                        var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OPSCallAssistant.Resources.ringback.wav");
                        waveStream = new WaveStreamPlayback(stream, true, true);

                        initiatedCall.ConnectAudioSender(waveStream);
                        waveStream.StartStreaming();

                        transferStarted = true;
                        initiatedCall.BlindTransfer(phoneNumber);

                    }
                    if (e.Item.IsCallEnded())
                    {
                        if (waveStream != null)
                            waveStream.Dispose();
                    }
                }
                catch(Exception ex)
                {
                    Logger.Log(ex.Message);
                    Logger.Log(ex.StackTrace);
                }

                var k = 65;

            };
            initiatedCall.Start();
        }
예제 #10
0
 private async Task SpeakNowDefaultSettings()
 {
     await TextToSpeech.SpeakAsync(transcribedText.Text);
 }
예제 #11
0
        public override IEnumerator RunTest()
        {
            LogSystem.InstallDefaultReactors();

            VcapCredentials vcapCredentials = new VcapCredentials();
            fsData          data            = null;

            string result = null;
            string credentialsFilepath = "../sdk-credentials/credentials.json";

            //  Load credentials file if it exists. If it doesn't exist, don't run the tests.
            if (File.Exists(credentialsFilepath))
            {
                result = File.ReadAllText(credentialsFilepath);
            }
            else
            {
                yield break;
            }

            //  Add in a parent object because Unity does not like to deserialize root level collection types.
            result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES");

            //  Convert json to fsResult
            fsResult r = fsJsonParser.Parse(result, out data);

            if (!r.Succeeded)
            {
                throw new WatsonException(r.FormattedMessages);
            }

            //  Convert fsResult to VcapCredentials
            object obj = vcapCredentials;

            r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
            if (!r.Succeeded)
            {
                throw new WatsonException(r.FormattedMessages);
            }

            //  Set credentials from imported credntials
            Credential credential = vcapCredentials.GetCredentialByname("text-to-speech-sdk")[0].Credentials;

            _username = credential.Username.ToString();
            _password = credential.Password.ToString();
            _url      = credential.Url.ToString();

            //  Create credential and instantiate service
            Credentials credentials = new Credentials(_username, _password, _url);

            //  Or authenticate using token
            //Credentials credentials = new Credentials(_url)
            //{
            //    AuthenticationToken = _token
            //};

            _textToSpeech = new TextToSpeech(credentials);

            //  Synthesize
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting synthesize.");
            _textToSpeech.Voice = VoiceType.en_US_Allison;
            _textToSpeech.ToSpeech(HandleToSpeechCallback, OnFail, _testString, true);
            while (!_synthesizeTested)
            {
                yield return(null);
            }

            //  Synthesize Conversation string
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting synthesize a string as returned by Watson Conversation.");
            _textToSpeech.Voice = VoiceType.en_US_Allison;
            _textToSpeech.ToSpeech(HandleConversationToSpeechCallback, OnFail, _testConversationString, true);
            while (!_synthesizeConversationTested)
            {
                yield return(null);
            }

            //	Get Voices
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get voices.");
            _textToSpeech.GetVoices(OnGetVoices, OnFail);
            while (!_getVoicesTested)
            {
                yield return(null);
            }

            //	Get Voice
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get voice {0}.", VoiceType.en_US_Allison);
            _textToSpeech.GetVoice(OnGetVoice, OnFail, VoiceType.en_US_Allison);
            while (!_getVoiceTested)
            {
                yield return(null);
            }

            //	Get Pronunciation
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get pronunciation of {0}", _testWord);
            _textToSpeech.GetPronunciation(OnGetPronunciation, OnFail, _testWord, VoiceType.en_US_Allison);
            while (!_getPronuciationTested)
            {
                yield return(null);
            }

            //  Get Customizations
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get a list of customizations");
            _textToSpeech.GetCustomizations(OnGetCustomizations, OnFail);
            while (!_getCustomizationsTested)
            {
                yield return(null);
            }

            //  Create Customization
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to create a customization");
            _textToSpeech.CreateCustomization(OnCreateCustomization, OnFail, _customizationName, _customizationLanguage, _customizationDescription);
            while (!_createCustomizationTested)
            {
                yield return(null);
            }

            //  Get Customization
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get a customization");
            if (!_textToSpeech.GetCustomization(OnGetCustomization, OnFail, _createdCustomizationId))
            {
                Log.Debug("TestTextToSpeech.RunTest()", "Failed to get custom voice model!");
            }
            while (!_getCustomizationTested)
            {
                yield return(null);
            }

            //  Update Customization
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to update a customization");
            Word[] wordsToUpdateCustomization =
            {
                new Word()
                {
                    word        = "hello",
                    translation = "hullo"
                },
                new Word()
                {
                    word        = "goodbye",
                    translation = "gbye"
                },
                new Word()
                {
                    word        = "hi",
                    translation = "ohioooo"
                }
            };

            _customVoiceUpdate = new CustomVoiceUpdate()
            {
                words       = wordsToUpdateCustomization,
                description = "My updated description",
                name        = "My updated name"
            };

            if (!_textToSpeech.UpdateCustomization(OnUpdateCustomization, OnFail, _createdCustomizationId, _customVoiceUpdate))
            {
                Log.Debug("TestTextToSpeech.UpdateCustomization()", "Failed to update customization!");
            }
            while (!_updateCustomizationTested)
            {
                yield return(null);
            }

            //  Get Customization Words
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get a customization's words");
            if (!_textToSpeech.GetCustomizationWords(OnGetCustomizationWords, OnFail, _createdCustomizationId))
            {
                Log.Debug("TestTextToSpeech.GetCustomizationWords()", "Failed to get {0} words!", _createdCustomizationId);
            }
            while (!_getCustomizationWordsTested)
            {
                yield return(null);
            }

            //  Add Customization Words
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to add words to a customization");
            Word[] wordArrayToAddToCustomization =
            {
                new Word()
                {
                    word        = "bananna",
                    translation = "arange"
                },
                new Word()
                {
                    word        = "orange",
                    translation = "gbye"
                },
                new Word()
                {
                    word        = "tomato",
                    translation = "tomahto"
                }
            };

            Words wordsToAddToCustomization = new Words()
            {
                words = wordArrayToAddToCustomization
            };

            if (!_textToSpeech.AddCustomizationWords(OnAddCustomizationWords, OnFail, _createdCustomizationId, wordsToAddToCustomization))
            {
                Log.Debug("TestTextToSpeech.AddCustomizationWords()", "Failed to add words to {0}!", _createdCustomizationId);
            }
            while (!_addCustomizationWordsTested)
            {
                yield return(null);
            }

            //  Get Customization Word
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to get the translation of a custom voice model's word.");
            string customIdentifierWord = wordsToUpdateCustomization[0].word;

            if (!_textToSpeech.GetCustomizationWord(OnGetCustomizationWord, OnFail, _createdCustomizationId, customIdentifierWord))
            {
                Log.Debug("TestTextToSpeech.GetCustomizationWord()", "Failed to get the translation of {0} from {1}!", customIdentifierWord, _createdCustomizationId);
            }
            while (!_getCustomizationWordTested)
            {
                yield return(null);
            }

            //  Delete Customization Word
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to delete customization word from custom voice model.");
            string wordToDelete = "goodbye";

            if (!_textToSpeech.DeleteCustomizationWord(OnDeleteCustomizationWord, OnFail, _createdCustomizationId, wordToDelete))
            {
                Log.Debug("TestTextToSpeech.DeleteCustomizationWord()", "Failed to delete {0} from {1}!", wordToDelete, _createdCustomizationId);
            }
            while (!_deleteCustomizationWordTested)
            {
                yield return(null);
            }

            //  Delete Customization
            Log.Debug("TestTextToSpeech.RunTest()", "Attempting to delete a customization");
            if (!_textToSpeech.DeleteCustomization(OnDeleteCustomization, OnFail, _createdCustomizationId))
            {
                Log.Debug("TestTextToSpeech.DeleteCustomization()", "Failed to delete custom voice model!");
            }
            while (!_deleteCustomizationTested)
            {
                yield return(null);
            }

            Log.Debug("TestTextToSpeech.RunTest()", "Text to Speech examples complete.");

            yield break;
        }
예제 #12
0
        public void SetMenuItemsForTab(bool speakPageName = true)
        {
            GameMenu       menu     = stardewMenu as GameMenu;
            IClickableMenu menuPage = menu.GetCurrentPage();

            ClearItems();

            if (menuPage is InventoryPage invPage)
            {
                TextToSpeech.Speak("inventory");
            }
            else if (menuPage is SkillsPage skillsPage)
            {
                TextToSpeech.Speak("skills");
                foreach (ClickableComponent comp in skillsPage.skillAreas)
                {
                    int    idx   = System.Convert.ToInt32(comp.name);
                    string label = Farmer.getSkillDisplayNameFromIndex(idx);
                    label += " level " + Game1.player.GetSkillLevel(idx);
                    AddItem(MenuItem.MenuItemFromComponent(comp, skillsPage, label));
                }
            }
            else if (menuPage is SocialPage socialPage)
            {
                TextToSpeech.Speak("social");
                //socialPage.setCurrentlySnappedComponentTo(menu.tabs[GameMenu.socialTab].myID);
                socialPage.setCurrentlySnappedComponentTo(socialPage.characterSlots[0].myID);
                int i = 0;
                foreach (ClickableComponent comp in socialPage.characterSlots)
                {
                    AddItem(MenuItem.MenuItemFromComponent(comp, socialPage, socialPage.names[i].ToString()));
                    i += 1;
                }
                NextItem();
            }
            else if (menuPage is MapPage mapPage)
            {
                TextToSpeech.Speak("map");
            }
            else if (menuPage is CraftingPage craftingPage)
            {
                if (speakPageName)
                {
                    TextToSpeech.Speak("crafting");
                }

                int currentCraftingPage = ModEntry.GetHelper().Reflection.GetField <int>(craftingPage, "currentCraftingPage").GetValue();
                Dictionary <ClickableTextureComponent, CraftingRecipe> pagesOfCraftingRecipes = ModEntry.GetHelper().Reflection.GetField <List <Dictionary <ClickableTextureComponent, CraftingRecipe> > >(craftingPage, "pagesOfCraftingRecipes").GetValue()[currentCraftingPage];
                IReflectedMethod getContainerContents = ModEntry.GetHelper().Reflection.GetMethod(craftingPage, "getContainerContents");
                int i = 0;
                foreach (ClickableTextureComponent comp in craftingPage.currentPageClickableComponents)
                {
                    CraftingRecipe        recipe             = pagesOfCraftingRecipes[comp];
                    bool                  doesFarmerHasItems = recipe.doesFarmerHaveIngredientsInInventory(getContainerContents.Invoke <IList <Item> >());
                    Dictionary <int, int> recipeList         = ModEntry.GetHelper().Reflection.GetField <Dictionary <int, int> >(recipe, "recipeList").GetValue();
                    string                description        = ModEntry.GetHelper().Reflection.GetField <string>(recipe, "description").GetValue();

                    string recipeListToDescr()
                    {
                        string result = "";

                        foreach (KeyValuePair <int, int> ingred in recipeList)
                        {
                            result += ingred.Value + " " + Game1.objectInformation[ingred.Key].Split('/')[4] + ",";
                        }
                        return(result);
                    }

                    MenuItem menuItem = MenuItem.MenuItemFromComponent(comp, craftingPage, recipe.DisplayName + (doesFarmerHasItems ? "" : " missing resources"));
                    //string craftable = doesFarmerHasItems ? "can be crafted," : "resources missing";
                    menuItem.Description = " needs " + recipeListToDescr() + " " + description;
                    AddItem(menuItem);
                    i++;
                }
            }
            else if (menuPage is CollectionsPage collectionsPage)
            {
                TextToSpeech.Speak("collections");
            }
            else if (menuPage is OptionsPage optionsPage)
            {
                TextToSpeech.Speak("options");
            }
            else if (menuPage is ExitPage exitPage)
            {
                TextToSpeech.Speak("exit");
                MenuItem exitToTitle = MenuItem.MenuItemFromComponent(exitPage.exitToTitle, menu, exitPage.exitToTitle.label);
                exitToTitle.TextOnAction = "exiting to title";
                AddItem(exitToTitle);
                MenuItem exitToDesktop = MenuItem.MenuItemFromComponent(exitPage.exitToDesktop, menu, exitPage.exitToDesktop.label);
                exitToDesktop.TextOnAction = "closing game";
                AddItem(exitToDesktop);
            }
            else
            {
                TextToSpeech.Speak("unsupported");
            }
        }
예제 #13
0
    public async void LoadModel(bool resourceLoad)
    {
        try
        {
            // Get components
            _tts  = GetComponent <TextToSpeech>();
            _user = GetComponent <UserInput>();

            // Load model
            StatusBlock.text = $"Loading {SqueezeNetModel.ModelFileName} ...";
            _dnnModel        = new SqueezeNetModel();
            await _dnnModel.LoadModelAsync(GPU, resourceLoad);

            StatusBlock.text = $"Loaded model. Starting camera...";

#if ENABLE_WINMD_SUPPORT
            // Configure camera to return frames fitting the model input size
            try
            {
                _mediaCapturer = new MediaCapturer();
                await _mediaCapturer.StartCapturing(
                    _dnnModel.InputWidth,
                    _dnnModel.InputHeight);

                StatusBlock.text = $"Camera started. Running!";
            }
            catch (Exception ex)
            {
                StatusBlock.text = $"Failed to start camera: {ex.Message}. Using loaded/picked image.";
            }
            // Load fallback frame if there's no camera like when testing with the emulator
            if (!_mediaCapturer.IsCapturing)
            {
                var loadedFrame = await _mediaCapturer.GetTestFrame();
            }

            // Run processing loop in separate parallel Task
            _isRunning = true;
            await Task.Run(async() =>
            {
                while (_isRunning)
                {
                    if (_mediaCapturer.IsCapturing)
                    {
                        using (var videoFrame = _mediaCapturer.GetLatestFrame())
                        {
                            await EvaluateFrame(videoFrame, resourceLoad);
                        }
                    }
                    // Use fallback if there's no camera like when testing with the emulator
                    else
                    {
                        var loadedFrame = await _mediaCapturer.GetTestFrame();
                        await EvaluateFrame(loadedFrame, resourceLoad);
                    }
                }
            });
#endif
        }
        catch (Exception ex)
        {
            StatusBlock.text = $"Error init: {ex.Message}";
            Debug.LogError(ex);
        }
    }
예제 #14
0
        private async void Initialize()
        {
            try
            {
                // Create the map view.
                _myMapView.Map = new Map(Basemap.CreateStreets());

                // Create the text to speech object.
                _textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

                // Create the route task, using the online routing service.
                RouteTask routeTask = await RouteTask.CreateAsync(_routingUri);

                // Get the default route parameters.
                RouteParameters routeParams = await routeTask.CreateDefaultParametersAsync();

                // Explicitly set values for parameters.
                routeParams.ReturnDirections       = true;
                routeParams.ReturnStops            = true;
                routeParams.ReturnRoutes           = true;
                routeParams.OutputSpatialReference = SpatialReferences.Wgs84;

                // Create stops for each location.
                Stop stop1 = new Stop(_conventionCenter)
                {
                    Name = "San Diego Convention Center"
                };
                Stop stop2 = new Stop(_memorial)
                {
                    Name = "USS San Diego Memorial"
                };
                Stop stop3 = new Stop(_aerospaceMuseum)
                {
                    Name = "RH Fleet Aerospace Museum"
                };

                // Assign the stops to the route parameters.
                List <Stop> stopPoints = new List <Stop> {
                    stop1, stop2, stop3
                };
                routeParams.SetStops(stopPoints);

                // Get the route results.
                _routeResult = await routeTask.SolveRouteAsync(routeParams);

                _route = _routeResult.Routes[0];

                // Add a graphics overlay for the route graphics.
                _myMapView.GraphicsOverlays.Add(new GraphicsOverlay());

                // Add graphics for the stops.
                SimpleMarkerSymbol stopSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.OrangeRed, 20);
                _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_conventionCenter, stopSymbol));
                _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_memorial, stopSymbol));
                _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_aerospaceMuseum, stopSymbol));

                // Create a graphic (with a dashed line symbol) to represent the route.
                _routeAheadGraphic = new Graphic(_route.RouteGeometry)
                {
                    Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.BlueViolet, 5)
                };

                // Create a graphic (solid) to represent the route that's been traveled (initially empty).
                _routeTraveledGraphic = new Graphic {
                    Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.LightBlue, 3)
                };

                // Add the route graphics to the map view.
                _myMapView.GraphicsOverlays[0].Graphics.Add(_routeAheadGraphic);
                _myMapView.GraphicsOverlays[0].Graphics.Add(_routeTraveledGraphic);

                // Set the map viewpoint to show the entire route.
                await _myMapView.SetViewpointGeometryAsync(_route.RouteGeometry, 100);

                // Enable the navigation button.
                _navigateButton.Enabled = true;
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.Message).SetTitle("Error").Show();
            }
        }
예제 #15
0
 public async Task Falar()
 {
     await TextToSpeech.SpeakAsync("");
 }
        //Actions

        #region 登录 —— async void Login()
        /// <summary>
        /// 登录
        /// </summary>
        public async void Login()
        {
            #region # 验证

            if (string.IsNullOrWhiteSpace(this.LoginId))
            {
                await this.Alert("用户名不可为空!");

                return;
            }
            if (string.IsNullOrWhiteSpace(this.Password))
            {
                await this.Alert("密码不可为空!");

                return;
            }

            #endregion

            this.Busy();

            LoginInfo loginInfo = await Task.Run(() => this._authenticationContract.Channel.Login(this.LoginId, this.Password));

            MembershipMediator.SetLoginInfo(loginInfo);

            this.Idle();

            TextToSpeech.SpeakAsync("登录成功");
            this.Toast($"登录成功!{loginInfo.LoginId}");

            IList <LoginMenuInfo> menuItems = new List <LoginMenuInfo>
            {
                new LoginMenuInfo
                {
                    Name         = "在线模式",
                    Icon         = "online",
                    SubMenuInfos = new List <LoginMenuInfo>
                    {
                        new LoginMenuInfo
                        {
                            Name         = "单据管理",
                            SubMenuInfos = new List <LoginMenuInfo>
                            {
                                new LoginMenuInfo
                                {
                                    Name = "收货管理",
                                    Icon = "warehouse_in",
                                },
                                new LoginMenuInfo
                                {
                                    Name = "发货管理",
                                    Icon = "warehouse_out",
                                    Url  = "url2"
                                }
                            }
                        },
                        new LoginMenuInfo
                        {
                            Name         = "托盘管理",
                            Icon         = "pallet_stacking",
                            Url          = "url3",
                            SubMenuInfos = new List <LoginMenuInfo>
                            {
                                new LoginMenuInfo
                                {
                                    Name = "装托",
                                    Icon = "pallet_stacking",
                                },
                                new LoginMenuInfo
                                {
                                    Name = "拼托",
                                    Icon = "pallet_join"
                                },
                                new LoginMenuInfo
                                {
                                    Name = "拆托",
                                    Icon = "pallet_breaking"
                                },
                                new LoginMenuInfo
                                {
                                    Name = "换托/货",
                                    Icon = "pallet_change"
                                }
                            }
                        }
                    }
                },
                new LoginMenuInfo
                {
                    Name         = "离线模式",
                    Icon         = "offline",
                    SubMenuInfos = new List <LoginMenuInfo>
                    {
                        new LoginMenuInfo
                        {
                            Name         = "单据管理",
                            SubMenuInfos = new List <LoginMenuInfo>
                            {
                                new LoginMenuInfo
                                {
                                    Name = "收货管理",
                                    Icon = "warehouse_in",
                                    Url  = "url2"
                                },
                                new LoginMenuInfo
                                {
                                    Name = "发货管理",
                                    Icon = "warehouse_out",
                                    Url  = "url2"
                                }
                            }
                        }
                    }
                },
                new LoginMenuInfo
                {
                    Name         = "个人中心",
                    Icon         = "center",
                    SubMenuInfos = new List <LoginMenuInfo>
                    {
                        new LoginMenuInfo
                        {
                            Name         = "个人中心",
                            SubMenuInfos = new List <LoginMenuInfo>
                            {
                                new LoginMenuInfo
                                {
                                    Name = "设备注册",
                                    Icon = "device_info",
                                },
                                new LoginMenuInfo
                                {
                                    Name = "修改密码",
                                    Icon = "stock_taking_order",
                                }
                            }
                        }
                    }
                }
            };
            this._navigationService
            .For <IndexViewModel>()
            .WithParam(x => x.MenuItems, new ObservableCollection <LoginMenuInfo>(menuItems))
            .Navigate(false);
        }
예제 #17
0
        static void Render_Span(int ToFolder, int FormFolder, string language)
        {
            try
            {
                CodeFFMPEG code = new CodeFFMPEG();


                Process          process   = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WindowStyle      = ProcessWindowStyle.Hidden;
                startInfo.WorkingDirectory = string.Format(@"C:\RACC");
                startInfo.FileName         = "copy.bat";
                process.StartInfo          = startInfo;
                process.Start();
                process.Close();
                Console.WriteLine("Edit Image....");
                #region Edit Image
                #region Xử lý video0
                try
                {
                    if (!File.Exists(string.Format(@"C:\RACC\Data\Video0\Image\image1.jpg")))
                    {
                        Edit_Image.Convert_All_Jpg(0);
                        Thread.Sleep(5000);
                        Edit_Image.Keep_Origin_Image(0);
                        Thread.Sleep(3000);
                        File.Delete(@"C:\RACC\Data\Video0\Image\image.jpg");
                    }
                }
                catch (Exception)
                {
                }

                #endregion

                for (int i = ToFolder; i < FormFolder; i++)
                {
                    if (File.Exists(string.Format(@"C:\RACC\Data\Video{0}\Image\image1.jpg", FormFolder - 1)))
                    {
                        break;
                    }
jump:
                    if (i >= FormFolder)
                    {
                        break;
                    }
                    try
                    {
                        if (File.Exists(string.Format(@"C:\RACC\Data\Video{0}\Image\image1.jpg", i)))
                        {
                            i++;
                            goto jump;
                        }
                        Edit_Image.Convert_All_Jpg(i);
                        Thread.Sleep(1000);

                        Edit_Image.Keep_Origin_Image(i);
                        string path = string.Format(@"C:\RACC\Data\Video{0}\Image\image.jpg", i);
                        Thread.Sleep(5000);
                        File.Delete(path);

                        Thread.Sleep(1000);
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Không xử lý đk ảnh thứ : " + i);
                    }
                    Thread.Sleep(1000);
                }

                #endregion

                #region Code trong theard

                for (int k = ToFolder; k < FormFolder; k++)
                {
Jump:

                    if (k >= FormFolder)
                    {
                        break;
                    }
                    #region Kiểm tra File tồn tại và xử lý chuỗi input

                    // nếu file đã được tạo thì pass qua
                    if (File.Exists("C:\\RACC\\Data\\Video" + (k) + "\\Image\\VideoImage.mp4"))
                    {
                        Console.WriteLine("\n Đã hoàn thành Video:" + k + " OK");
                        k++;
                        goto Jump;
                    }
                    if (language == "english")
                    {
                        Standardize_The_String.English(k);
                    }


                    #endregion
                    #region Hàm code
                    if (!File.Exists(string.Format(@"C:\RACC\Data\Video{0}\Image\1.jpg", k)))
                    {
                        if (!File.Exists(string.Format(@"C:\RACC\Data\Video{0}\Image\2.jpg", k)))
                        {
                            Edit_Image.Change_Image_Name(k);
                            // Thread.Sleep(1000);
                            Thread.Sleep(5000);
                        }
                    }

                    if (!File.Exists(string.Format(@"C:\RACC\Data\Video{0}\Image\TotalMusic.mp3", k)))
                    {
                        Console.WriteLine(" TextToSpeech .....");
                        Console.WriteLine();
                        TextToSpeech.Start(k, language);
                        // Thread.Sleep(1000);
                        Thread.Sleep(3000);
                        Join_Voice.Follow_INPUTtxt(k);
                        // Thread.Sleep(1000);
                        Thread.Sleep(2000);
                    }

                    try
                    {
                        Console.WriteLine(" Create Video .....");
                        code.Create_Video(k);
                    }
                    catch (Exception)
                    {
                        goto ketthuc;
                    }

                    #endregion


                    bool check    = false;
                    int  SolanLap = 0;
                    do
                    {
                        if (File.Exists("C:\\RACC\\Data\\Video" + k + "\\Image\\VideoImage.mp4"))
                        {
                            Console.WriteLine("\n Đã hoàn thành Video:" + k + " OK");
                            check = true;
                        }
                        SolanLap++;
                        if (SolanLap == 2)
                        {
                            goto ketthuc;
                        }
                        Thread.Sleep(5000);
                    } while (!check);

ketthuc:
                    #region Create Thumb
                    Create_Thumbnail.Origin(k);
                    #endregion
                }

                #endregion
            }
            catch (Exception)
            {
            }
        }
예제 #18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.sport);
            AdView mAdView   = FindViewById <AdView>(Resource.Id.adView1);
            var    adRequest = new AdRequest.Builder().Build();

            // Start loading the ad.
            mAdView.LoadAd(adRequest);
            b1  = FindViewById <Button>(Resource.Id.b1);
            b2  = FindViewById <Button>(Resource.Id.b2);
            b3  = FindViewById <Button>(Resource.Id.b3);
            b4  = FindViewById <Button>(Resource.Id.b4);
            b5  = FindViewById <Button>(Resource.Id.b5);
            b6  = FindViewById <Button>(Resource.Id.b6);
            b7  = FindViewById <Button>(Resource.Id.b7);
            b8  = FindViewById <Button>(Resource.Id.b8);
            b9  = FindViewById <Button>(Resource.Id.b9);
            b10 = FindViewById <Button>(Resource.Id.b10);
            b11 = FindViewById <Button>(Resource.Id.b11);
            b12 = FindViewById <Button>(Resource.Id.b12);
            b13 = FindViewById <Button>(Resource.Id.b13);
            b14 = FindViewById <Button>(Resource.Id.b14);
            b15 = FindViewById <Button>(Resource.Id.b15);
            b16 = FindViewById <Button>(Resource.Id.b16);
            b17 = FindViewById <Button>(Resource.Id.b17);
            b18 = FindViewById <Button>(Resource.Id.b18);
            b19 = FindViewById <Button>(Resource.Id.b19);
            b20 = FindViewById <Button>(Resource.Id.b20);
            b21 = FindViewById <Button>(Resource.Id.b21);
            b22 = FindViewById <Button>(Resource.Id.b22);
            b23 = FindViewById <Button>(Resource.Id.b23);
            b24 = FindViewById <Button>(Resource.Id.b24);
            b25 = FindViewById <Button>(Resource.Id.b25);
            b26 = FindViewById <Button>(Resource.Id.b26);
            b27 = FindViewById <Button>(Resource.Id.b27);
            b28 = FindViewById <Button>(Resource.Id.b28);
            b29 = FindViewById <Button>(Resource.Id.b29);
            b30 = FindViewById <Button>(Resource.Id.b30);
            b31 = FindViewById <Button>(Resource.Id.b31);
            b32 = FindViewById <Button>(Resource.Id.b32);
            b33 = FindViewById <Button>(Resource.Id.b33);

            /*      b34 = FindViewById<Button>(Resource.Id.b34);
             *    b35 = FindViewById<Button>(Resource.Id.b35);
             *    b36 = FindViewById<Button>(Resource.Id.b36);
             *    b37 = FindViewById<Button>(Resource.Id.b37);
             *    b38 = FindViewById<Button>(Resource.Id.b38);
             *    b39 = FindViewById<Button>(Resource.Id.b39);
             *    b40= FindViewById<Button>(Resource.Id.b40);
             *    b41 = FindViewById<Button>(Resource.Id.b41);
             *    b42 = FindViewById<Button>(Resource.Id.b42);
             *    b43 = FindViewById<Button>(Resource.Id.b43);
             *    b44= FindViewById<Button>(Resource.Id.b44);
             *    b45= FindViewById<Button>(Resource.Id.b45);
             *    b46 = FindViewById<Button>(Resource.Id.b46);
             *    b47 = FindViewById<Button>(Resource.Id.b47);
             *    b48 = FindViewById<Button>(Resource.Id.b48);
             *    b49 = FindViewById<Button>(Resource.Id.b49);
             *    b50 = FindViewById<Button>(Resource.Id.b50);*/
            b1.Click  += B1_Click;
            b2.Click  += B2_Click;
            b3.Click  += B3_Click;
            b4.Click  += B4_Click;
            b5.Click  += B5_Click;
            b6.Click  += B6_Click;
            b7.Click  += B7_Click;
            b8.Click  += B8_Click;
            b9.Click  += B9_Click;
            b10.Click += B10_Click;
            b11.Click += B11_Click;
            b12.Click += B12_Click;
            b13.Click += B13_Click;
            b14.Click += B14_Click;
            b15.Click += B15_Click;
            b16.Click += B16_Click;
            b17.Click += B17_Click;
            b18.Click += B18_Click;
            b19.Click += B19_Click;
            b20.Click += B20_Click;
            b21.Click += B21_Click;
            b22.Click += B22_Click;
            b23.Click += B23_Click;
            b24.Click += B24_Click;
            b25.Click += B25_Click;
            b26.Click += B26_Click;
            b27.Click += B27_Click;
            b28.Click += B28_Click;
            b29.Click += B29_Click;
            b30.Click += B30_Click;
            b31.Click += B31_Click;
            b32.Click += B32_Click;
            b33.Click += B33_Click;

            /*  b34.Click += B34_Click;
             * b35.Click += B35_Click;
             * b36.Click += B36_Click;
             * b37.Click += B37_Click;
             * b38.Click += B38_Click;
             * b39.Click += B39_Click;
             * b40.Click += B40_Click;
             * b41.Click += B41_Click;
             * b42.Click += B42_Click;
             * b43.Click += B43_Click;
             * b44.Click += B44_Click;
             * b45.Click += B45_Click;
             * b46.Click += B46_Click;
             * b47.Click += B47_Click;
             * b48.Click += B48_Click;
             * b49.Click += B49_Click;
             * b50.Click += B50_Click;*/


            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);
        }
예제 #19
0
 private void Awake()
 {
     textToSpeech = GetComponent <TextToSpeech>();
 }
예제 #20
0
 private async void Button_Clicked(object sender, EventArgs e)
 {
     var Texto = voz.Text;
     await TextToSpeech.SpeakAsync(Texto);
 }
예제 #21
0
 void Awake()
 {
     textToSpeech = this.gameObject.GetComponentInChildren <TextToSpeech>();
 }
예제 #22
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Hide the window title and go fullscreen.
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.AddFlags(WindowManagerFlags.Fullscreen);

            // Create our Preview view and set it as the content of our activity.
            mPreview = new CameraView(this);

            FrameLayout.LayoutParams tparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                            ViewGroup.LayoutParams.WrapContent);                            //定义显示组件参数

            View   mainView  = View.Inflate(this, Resource.Layout.Main, null);
            Button btn       = mainView.FindViewById <Button> (Resource.Id.takepicb);
            Button enrollbtn = mainView.FindViewById <Button> (Resource.Id.enrollbtn);
            Button kechenbtn = mainView.FindViewById <Button> (Resource.Id.button1);

            Spinner spinner = mainView.FindViewById <Spinner> (Resource.Id.spinner1);

            tv      = mainView.FindViewById <TextView> (Resource.Id.statustext);
            tv.Text = "开始指纹识别。。。";
            result  = mainView.FindViewById <TextView> (Resource.Id.resulttext);

            Switch autoSw = mainView.FindViewById <Switch> (Resource.Id.switch1);

            iv        = mainView.FindViewById <ImageView> (Resource.Id.imageView1);
            frameView = mainView.FindViewById <TextView> (Resource.Id.textView1);

            tts = new TextToSpeech(this, this);

            FrameLayout fl = new FrameLayout(this);

            fl.AddView(mPreview);
            fl.AddView(mainView);

            //保持屏幕常亮
            Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);
            SetContentView(fl, tparams);

            // Initialize SourceAFIS
            Afis = new AfisEngine();
            // Look up the probe using Threshold = 10
            Afis.Threshold = 25;
            // Enroll some people
            database = new List <MyPerson>();
            lessons  = new List <MyLesson> ();

            if (System.IO.File.Exists(ImagePath + "lessons"))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                using (FileStream stream = File.OpenRead(ImagePath + "lessons"))
                    lessons = (List <MyLesson>)formatter.Deserialize(stream);
            }
            else
            {
                tv.Text = "无课程,请添加课程。。。";
            }

            List <string> lessonname = new List <string> ();

            foreach (MyLesson ml in lessons)
            {
                lessonname.Add(ml.name);
            }
            ArrayAdapter <string> adapter = new ArrayAdapter <string> (Application.Context, Android.Resource.Layout.SimpleSpinnerItem, lessonname);

            spinner.Adapter       = adapter;
            spinner.ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e) {
                Spinner s = (Spinner)sender;
                nowLesson = s.GetItemAtPosition(e.Position).ToString();

                //判断数据库是否存在
                if (System.IO.File.Exists(ImagePath + nowLesson + ".dat"))
                {
                    tv.Text = "已载入" + nowLesson + "数据库,开始识别。。。";
                    BinaryFormatter formatterr = new BinaryFormatter();
                    Console.WriteLine("Reloading database...");
                    using (FileStream stream = File.OpenRead(ImagePath + nowLesson + ".dat"))
                        database = (List <MyPerson>)formatterr.Deserialize(stream);
                }
                else
                {
                    tv.Text  = "数据库" + nowLesson + "中无数据,请录入指纹。。。";
                    database = new List <MyPerson>();
                }

                //判断本课程今天的考勤是否已经建立
                todayisbuld = false;
                for (int i = 0; i < lessons.Count; i++)
                {
                    if (lessons[i].name.Equals(nowLesson))
                    {
                        //获取当前课程的数据库中的标号
                        nowLessonNum = i;
                        for (int j = 0; j < lessons[i].attendance.Count; j++)
                        {
                            DateTime nowTime = DateTime.Now;
                            if ((lessons[i].attendance[j].date.Year == nowTime.Year) &&
                                (lessons[i].attendance[j].date.Month == nowTime.Month) &&
                                (lessons[i].attendance[j].date.Day == nowTime.Day)
                                )
                            {
                                todayisbuld = true;
                                //如果本课程今天已经建立了考勤,则获取当前考勤的数据库标号
                                todayNum = j;
                                //校准考勤时间的日期到今天的课程设置时间,方便比较
                                //lessons[nowLessonNum].time = new DateTime(nowTime.Year,nowTime.Month,nowTime.Day,
                                //	lessons[nowLessonNum].time.Hour,lessons[nowLessonNum].time.Minute,0);
                            }
                        }
                    }
                }

                //如果没建立,就新建一个
                if (!todayisbuld)
                {
                    DateTime nowTime = DateTime.Now;
                    //校准考勤时间的日期到今天的课程设置时间,方便比较
                    //lessons[nowLessonNum].time = new DateTime(nowTime.Year,nowTime.Month,nowTime.Day,
                    //	lessons[nowLessonNum].time.Hour,lessons[nowLessonNum].time.Minute,0);

                    //新建今天的考勤
                    Attendance att = new Attendance(new DateTime(nowTime.Year, nowTime.Month, nowTime.Day,
                                                                 lessons[nowLessonNum].time.Hour, lessons[nowLessonNum].time.Minute, 0));
                    lessons[nowLessonNum].attendance.Add(att);
                    todayNum    = lessons[nowLessonNum].attendance.IndexOf(att);
                    todayisbuld = true;
                }
            };

            btn.Click += delegate {
                try{
                    auto = false;
                    mCamera.TakePicture(null, null, this);
                    //设置、输出相机参数
                    Android.Hardware.Camera.Parameters p = mCamera.GetParameters();
                    string s = p.Flatten();
                    Console.WriteLine(s);
                    //					p.Set("iso",100.ToString());
                    //					p.Set("jpeg-quality",100.ToString());
                    //					mCamera.SetParameters(p);

                    //输出支持的图片分辨率
                    //					IList<Android.Hardware.Camera.Size> ss =  p.SupportedPictureSizes;
                    //					foreach(Android.Hardware.Camera.Size aa in ss)
                    //					{
                    //						Console.WriteLine(aa.Height +"," + aa.Width);
                    //					}
                }
                catch (Exception e)
                {
                    e.ToString();
                }
            };

            btn.SetOnTouchListener(this);
            enrollbtn.SetOnTouchListener(this);
            kechenbtn.SetOnTouchListener(this);

            btn.LongClick += delegate {
                mCamera.AutoFocus(null);
                tv.Text     = lessons[nowLessonNum].attendance[todayNum].attend.Count + "";
                result.Text = lessons[nowLessonNum].attendance[todayNum].late.Count + "";
                //hdler.PostDelayed (this,DELAY_MILLIS);
            };

            enrollbtn.Click += delegate {
                EditText            editT       = new EditText(this);
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetTitle("请输入学号后3位:");
                alertDialog.SetView(editT);
                alertDialog.SetPositiveButton("确认", delegate {
                    xuehao     = editT.Text;
                    tv.Text    = "学号为" + xuehao + ",开始录入指纹。。。";
                    isIdentify = false;
                });
                alertDialog.SetNegativeButton("取消", delegate {
                });
                alertDialog.Show();
            };

            kechenbtn.Click += delegate {
                View     base2        = View.Inflate(this, Resource.Layout.kecheng, null);
                Button   deletelesson = base2.FindViewById <Button>(Resource.Id.button3);
                Button   backbtn      = base2.FindViewById <Button>(Resource.Id.button1);
                Button   addbtn       = base2.FindViewById <Button>(Resource.Id.button2);
                ListView listLesson   = base2.FindViewById <ListView>(Resource.Id.listView1);

                //SimpleAdapter sAdapter = new SimpleAdapter(Application.Context,

                deletelesson.Click += delegate {
                };

                addbtn.Click += delegate {
                    EditText     editT    = new EditText(this);
                    EditText     edittime = new EditText(this);
                    LinearLayout ll       = new LinearLayout(this);
                    ll.Orientation = Orientation.Vertical;
                    ll.AddView(editT);
                    ll.AddView(edittime);
                    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                    alertDialog.SetTitle("请输入课程名和时间:");
                    alertDialog.SetView(ll);
                    alertDialog.SetPositiveButton("确认", delegate {
                        //lessons.Add(editT.Text);
                        MyLesson myl = new MyLesson(editT.Text, Convert.ToDateTime(edittime.Text.Insert(2, ":")));
                        lessons.Add(myl);
                        adapter.Add(editT.Text);
                        adapter.NotifyDataSetChanged();
                        Console.WriteLine("添加课程...");
                        BinaryFormatter formatters = new BinaryFormatter();
                        using (Stream stream = File.Open(ImagePath + "lessons", FileMode.OpenOrCreate))
                            formatters.Serialize(stream, lessons);
                        tv.Text = "课程名为" + editT.Text + ",请录入指纹。。。";
                    });
                    alertDialog.SetNegativeButton("取消", delegate {
                    });
                    alertDialog.Show();
                };

                //返回
                backbtn.Click += delegate {
                    SetContentView(fl);
                };

                //如果开了自动,则关闭
                if (autoSw.Checked)
                {
                    hdler.RemoveCallbacks(this);
                    autoSw.Checked = false;
                }
                SetContentView(base2);
            };

            autoSw.CheckedChange += delegate {
                if (autoSw.Checked)
                {
                    hdler.PostDelayed(this, DELAY_MILLIS);
                }
                else
                {
                    hdler.RemoveCallbacks(this);
                }
            };


            //zoom放大
//			sk.ProgressChanged += delegate {
//				Android.Hardware.Camera.Parameters  p = mCamera.GetParameters();
//				int maxPa = p.MaxZoom;
//				int maxCa = sk.Max;
//				p.Zoom = maxPa * sk.Progress / maxCa;
//				mCamera.SetParameters(p);
//			};
        }
예제 #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.main);
            key = true;
            EditText        tb1     = FindViewById <EditText>(Resource.Id.text);
            SeekBar         ss      = FindViewById <SeekBar>(Resource.Id.speed);
            TextView        sst     = FindViewById <TextView>(Resource.Id.textSpeed);
            SeekBar         sp      = FindViewById <SeekBar>(Resource.Id.ton);
            TextView        spt     = FindViewById <TextView>(Resource.Id.textton);
            Button          button1 = FindViewById <Button>(Resource.Id.buttonread);
            ttsListFragment frag    = SupportFragmentManager.FindFragmentById(Resource.Id.tts_list_fragment) as ttsListFragment;

            ttslist     = new List <elemTts>();
            ss.Progress = sp.Progress = 127;
            sst.Text    = spt.Text = "0,5";
            context     = button1.Context;

            tt = new TextToSpeech(this, this);
            tt.SetPitch(1.25f);
            tt.SetSpeechRate(1f);
            sp.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                tt.SetPitch(seek.Progress / 170f + 0.5f);
                spt.Text = progress.ToString("F2");
            };
            ss.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                tt.SetSpeechRate(seek.Progress / 255f + 0.1f);
                sst.Text = progress.ToString("F2");
            };
            button1.Click += delegate
            {
                try
                {
                    if (new Regex(@"[А-Яа-я]").Match(tb1.Text).Success)
                    {
                        tb1.FindFocus();
                        throw new Exception("возможно чтение только символов английского алфавита");
                    }

                    ttslist.Add(new elemTts(tb1.Text, ss.Progress / 255f + 0.1f, sp.Progress / 170f + 0.5f));
                    frag.OnResume();
                    if (ttslist.Count == 1)
                    {
                        Dictionary <string, string> param = new Dictionary <string, string> {
                            { TextToSpeech.Engine.KeyParamUtteranceId, "1" }
                        };
                        tt.PlaySilence(10, QueueMode.Add, param);
                    }
                }
                catch (Exception E)
                {
                    Toast.MakeText(this, E.Message, ToastLength.Short).Show();
                }
            };
            Button button2 = FindViewById <Button>(Resource.Id.buttonload);

            button2.Click += delegate
            {
                StartActivityForResult(new Intent(this, typeof(FilePickerActivity)), tkey);
            };
        }