/// <summary>
        /// Setups the initial menu.
        /// </summary>
        /// <returns></returns>
        private Recognize SetupInitialMenu()
        {
            var callerChoices = new List <RecognitionOption>()
            {
                new RecognitionOption()
                {
                    Name = "1", DtmfVariation = '1'
                },
                new RecognitionOption()
                {
                    Name = "2", DtmfVariation = '2'
                },
                new RecognitionOption()
                {
                    Name = "3", DtmfVariation = '3'
                },
                new RecognitionOption()
                {
                    Name = "#", DtmfVariation = '#'
                }                                                          // for navigating back
            };

            // create recognize action for caller
            var recognize = new Recognize
            {
                OperationId    = Guid.NewGuid().ToString(),
                PlayPrompt     = GetPromptForText(IVROptions.MainMenuPrompt),
                BargeInAllowed = true,
                InitialSilenceTimeoutInSeconds = 10,
                Choices = callerChoices
            };

            return(recognize);
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            startButton.IsEnabled = false;
            stopButton.IsEnabled  = true;

            Recognize.StartRecordingAsync(confidence, language, serviceAcc);
        }
예제 #3
0
        private static Recognize CreateIvrOptions(string textToBeRead, int numberOfOptions, bool includeBack)
        {
            var id      = Guid.NewGuid().ToString();
            var choices = new List <RecognitionOption>();

            choices.Add(new RecognitionOption
            {
                Name            = "Yes",
                SpeechVariation = new List <string>()
                {
                    "Yes", "Okay", "yeah"
                }
            });
            choices.Add(new RecognitionOption
            {
                Name            = "No",
                SpeechVariation = new List <string>()
                {
                    "No", "None", "Nope", "get me out of here"
                }
            });


            var recognize = new Recognize
            {
                OperationId    = Guid.NewGuid().ToString(),
                PlayPrompt     = GetPromptForText(textToBeRead),
                BargeInAllowed = true,
                Choices        = choices
            };

            return(recognize);
        }
예제 #4
0
        private static Recognize CreateIvrOptions(string textToBeRead, int numberOfOptions, bool includeBack)
        {
            if (numberOfOptions > 9)
            {
                throw new Exception("too many options specified");
            }

            var choices = new List <RecognitionOption>();

            for (int i = 1; i <= numberOfOptions; i++)
            {
                choices.Add(new RecognitionOption {
                    Name = Convert.ToString(i), DtmfVariation = (char)('0' + i)
                });
            }

            if (includeBack)
            {
                choices.Add(new RecognitionOption {
                    Name = "#", DtmfVariation = '#'
                });
            }

            var recognize = new Recognize
            {
                OperationId    = Guid.NewGuid().ToString(),
                PlayPrompt     = GetPromptForText(textToBeRead),
                BargeInAllowed = true,
                Choices        = choices
            };

            return(recognize);
        }
        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", apikey);

            Recognize.doMain(args);

            //InfiniteStreaming.RecognizeAsync().Wait();
        }
예제 #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Recognize recognize = db.Recognizes.Single(r => r.RecognitionId == id);

            db.Recognizes.DeleteObject(recognize);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #7
0
        protected override void Execute(CodeActivityContext context)
        {
            var             text         = Text.Get(context);
            var             languageCode = LanguageCode.Get(context);
            var             serviceAcc   = ServiceAccountFile.Get(context);
            SsmlVoiceGender gender       = (SsmlVoiceGender)Enum.Parse(typeof(SsmlVoiceGender), Gender.ToString());

            Recognize.TextToSpeech(text, languageCode, gender, serviceAcc);
        }
예제 #8
0
        private Task <string> ExecuteAsync(AsyncCodeActivityContext context, double confidence, string language, string serviceAcc)
        {
            speechDesign = new SpeechControl(confidence, language, serviceAcc);
            speechDesign.ShowDialog();

            speechDesign.stopButton.Click += new RoutedEventHandler(StopClickedAsync);
            Thread.Sleep(TimeSpan.FromSeconds(2));
            return(Recognize.StopRecording(confidence));
        }
예제 #9
0
        //
        // GET: /Award/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Recognize recognize = db.Recognizes.Single(r => r.RecognitionId == id);

            if (recognize == null)
            {
                return(HttpNotFound());
            }
            return(View(recognize));
        }
예제 #10
0
        public ArrayList getCommand(String l)  //This function calls googles api to get a verbal command from user.
        {
            ArrayList     word_list = new ArrayList();
            Task <object> task      = Recognize.StreamingMicRecognizeAsync(5, l);

            task.Wait();
            Object result = task.Result;

            word_list = (ArrayList)result;
            return(word_list);
        }
        /// <summary>
        /// Called when [play prompt completed].
        /// </summary>
        /// <param name="playPromptOutcomeEvent">The play prompt outcome event.</param>
        /// <returns></returns>
        private Task OnPlayPromptCompleted(PlayPromptOutcomeEvent playPromptOutcomeEvent)
        {
            // Add Choices for the caller
            telemetryClient.TrackTrace($"PlayPromptCompleted - {playPromptOutcomeEvent.ConversationResult.Id}");
            Recognize recognize = SetupInitialMenu();

            playPromptOutcomeEvent.ResultingWorkflow.Actions = new List <ActionBase> {
                recognize
            };
            return(Task.FromResult(true));
        }
예제 #12
0
파일: Game.cs 프로젝트: stephica/SNGEGT
 public Game()
 {
     deck = new int[52];
     myHand = new int[2];
     oppHand = new int[2];
     random = new Random();
     calcranges = new calcRanges();
     icm = new ICM();
     recognize = new Recognize();
     reset();
 }
예제 #13
0
        private void BuySelected()
        {
            Log("Attempting to buy");
            WINAPI.click(int.Parse(reagentXBox.Text) + 106, int.Parse(reagentYBox.Text) + 550);
            Thread.Sleep(300);
            WINAPI.mDown(int.Parse(reagentXBox.Text) + 588, int.Parse(reagentYBox.Text) + 343);
            Thread.Sleep(300);
            WINAPI.mDragTo(int.Parse(reagentXBox.Text) + 643, int.Parse(reagentYBox.Text) + 343);
            Thread.Sleep(300);
            WINAPI.click(int.Parse(reagentXBox.Text) + 313, int.Parse(reagentYBox.Text) + 527);
            Cursor.Position = new Point(0, 0);
            Thread.Sleep(500);
            Log("Clicked buy");
            WINAPI.click(int.Parse(reagentXBox.Text) + 313, int.Parse(reagentYBox.Text) + 527);
            Cursor.Position = new Point(0, 0);
            Recognize.makeScreen().Save(Path.Combine(Directory.GetCurrentDirectory(), $"Purchases/{DateTime.Now.ToBinary()}.png"));
            Image <Bgr, byte> source   = new Image <Bgr, byte>(Recognize.makeScreen());                                                          // Image B
            Image <Bgr, byte> template = new Image <Bgr, byte>(new Bitmap(Path.Combine(Directory.GetCurrentDirectory(), "BazaarUtils/ok.png"))); // Image A

            using (Image <Gray, float> result = source.MatchTemplate(template, TemplateMatchingType.CcoeffNormed))
            {
                double[] minValues, maxValues;
                Point[]  minLocations, maxLocations;
                result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

                // You can try different values of the threshold. I guess somewhere between 0.75 and 0.95 would be good.
                if (maxValues[0] > 0.85)
                {
                    DebugLog("Found ok button at X: " + maxLocations[0].X + " Y: " + maxLocations[0].Y);
                    // This is a match. Do something with it, for example draw a rectangle around it.
                    Rectangle match = new Rectangle(maxLocations[0], template.Size);
                    WINAPI.click(match.X, match.Y);
                    Thread.Sleep(50);
                    DebugLog("Clicked ok button");
                }
                else
                {
                    Log("I couldn't find the ok button!");
                }
            }

            WINAPI.click(1250, 780);
            Cursor.Position = new Point(0, 0);
            Thread.Sleep(50);
            WINAPI.click(1140, 620);
            Cursor.Position = new Point(0, 0);
            Thread.Sleep(50);
            source.Dispose();
            template.Dispose();
        }
예제 #14
0
 private bool NextPage()
 {
     WINAPI.click(int.Parse(reagentXBox.Text) + 633, int.Parse(reagentYBox.Text) + 510);
     Thread.Sleep(300);
     Cursor.Position = new Point(0, 0);
     if (Recognize.Contains(new Bitmap(Path.Combine(Directory.GetCurrentDirectory(), "BazaarUtils/nextpage.png"))))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #15
0
 public ActionResult Edit(Recognize recognize)
 {
     if (ModelState.IsValid)
     {
         db.Recognizes.Attach(recognize);
         db.ObjectStateManager.ChangeObjectState(recognize, EntityState.Modified);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AwardTypeId = new SelectList(db.AwardTypes, "AwardTypeId", "Name", recognize.AwardTypeId);
     ViewBag.RecogTypeId = new SelectList(db.RecognitionTypes, "RecognitionTypeId", "Name", recognize.RecogTypeId);
     ViewBag.OfficeId    = new SelectList(db.Offices, "OfficeID", "Name", recognize.OfficeId);
     ViewBag.AppEntityID = new SelectList(db.People, "AppEntityID", "FirstName", recognize.AppEntityID);
     return(View(recognize));
 }
예제 #16
0
        private bool ContainsNext(Bitmap bitmapToSearchFor)
        {
            Rectangle rect           = new Rectangle(new Point(0, 0), bitmapToSearchFor.Size);
            Bitmap    formattedImage = bitmapToSearchFor.Clone(rect, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            if (Recognize.FindBitmapsEntry(Recognize.makeScreen2(), formattedImage).Count > 0)
            {
                formattedImage.Dispose();
                return(true);
            }
            else
            {
                formattedImage.Dispose();
                return(false);
            }
        }
예제 #17
0
        static async Task Main(string[] args)
        {
            try
            {
                var assembly     = Assembly.GetExecutingAssembly();
                var resourceName = "NumberParserExtended.NumberParserExtended.txt";

                string contentFile = string.Empty;

                using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        contentFile = await reader.ReadToEndAsync();
                    }

                BuildContentField buildContentField = new BuildContentField();
                ContentField      readField         = buildContentField.Build(contentFile);

                Recognize recognize = new Recognize();
                if (recognize.DoRecognize <NumberOneConfiguration>(readField))
                {
                    Console.WriteLine("Recognized one");
                }
                if (recognize.DoRecognize <NumberTwoConfiguration>(readField))
                {
                    Console.WriteLine("Recognized two");
                }
                if (recognize.DoRecognize <NumberThreeConfiguration>(readField))
                {
                    Console.WriteLine("Recognized three");
                }
                if (recognize.DoRecognize <NumberFourConfiguration>(readField))
                {
                    Console.WriteLine("Recognized four");
                }
                if (recognize.DoRecognize <NumberFiveConfiguration>(readField))
                {
                    Console.WriteLine("Recognized five");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }

            Console.ReadLine();
        }
예제 #18
0
        //
        // GET: /Award/Edit/5

        public ActionResult Edit(int id = 0)
        {
            Recognize recognize = db.Recognizes.Single(r => r.RecognitionId == id);

            if (recognize == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Employee = db.People.Where(p => p.AppEntityID == id).Select(p => p.LastName);

            ViewBag.AwardTypeId = new SelectList(db.AwardTypes, "AwardTypeId", "Name", recognize.AwardTypeId);
            ViewBag.RecogTypeId = new SelectList(db.RecognitionTypes, "RecognitionTypeId", "Name", recognize.RecogTypeId);

            ViewBag.OfficeId    = new SelectList(db.Offices, "OfficeID", "Name", recognize.OfficeId);
            ViewBag.AppEntityID = new SelectList(db.People, "AppEntityID", "FullName", recognize.AppEntityID);
            return(View(recognize));
        }
예제 #19
0
        static void Main(string[] args)
        {
            //recognize wav file
            string audioFilePath       = "audio file path";
            string credentialsFilePath = "credentials file path(json)";
            int    samplingRate        = 16000;

            Recognize.AsyncRecognizeGcsWordsWithCredentials(audioFilePath, credentialsFilePath, samplingRate);

            //mic reccognition
            int recognitionTime = 100;

            while (true)
            {
                var temp = Recognize.StreamingMicRecognizeAsyncWithCredentials(recognitionTime, credentialsFilePath).Result;
            }

            //tcp streaming recognition (implement in the near future)
        }
예제 #20
0
        public ActionResult Create(Recognize recognize)
        {
            //var x = recognize.AppEntityID;
            //var id = db.People.Where(p => p.AppEntityID == x).Select(p => p.OfficeID);

            //Recognize recognizeFromDb = db.Recognizes.Single(y => y.AppEntityID == recognize.AppEntityID);



            if (ModelState.IsValid)
            {
                db.Recognizes.AddObject(recognize);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AwardTypeId = new SelectList(db.AwardTypes, "AwardTypeId", "Name", recognize.AwardTypeId);
            ViewBag.RecogTypeId = new SelectList(db.RecognitionTypes, "RecognitionTypeId", "Name", recognize.RecogTypeId);
            ViewBag.OfficeId    = new SelectList(db.Offices, "OfficeID", "Name", recognize.OfficeId);
            ViewBag.AppEntityID = new SelectList(db.People, "AppEntityID", "FirstName", recognize.AppEntityID);
            return(View(recognize));
        }
예제 #21
0
    public SpellResult GetSpell()
    {
        List <CoverageResult> coverageResults = new List <CoverageResult>();

        int   index = defaultUnchangedValue;
        float max   = defaultUnchangedValue;

        for (int i = 0; i < recognizeablePatterns.Count; i++)
        {
            float result      = recognizeablePatterns[i].Pattern.GetResult();
            float minCoverage = recognizeablePatterns[i].Pattern.GetMinCoverage();

            coverageResults.Add(new CoverageResult(recognizeablePatterns[i].Id, result, minCoverage));

            if ((minCoverage <= result) && (result > max))
            {
                index = recognizeablePatterns[i].Id;
                max   = result;
            }
        }

        Recognize?.Invoke(coverageResults);

        if (index != defaultUnchangedValue)
        {
            SpellResult spellResult = new SpellResult
            {
                Index    = index,
                Coverage = max,
            };

            return(spellResult);
        }
        else
        {
            return(null);
        }
    }
예제 #22
0
    void Process()
    {
        flag = true;
        string re = Recognize.init_audio(app_id, session_begin_params, AudioData);

        if (re == null)
        {
            flag = false;
            return;
        }
        Debug.Log(re);
        if (re.Contains("forward") || re.Contains("Forward"))
        {
            dir[0] = true;
        }
        if (re.Contains("back") || re.Contains("Back"))
        {
            dir[1] = true;
        }
        if (re.Contains("left") || re.Contains("Left"))
        {
            dir[2] = true;
        }
        if (re.Contains("right") || re.Contains("Right"))
        {
            dir[3] = true;
        }
        if (re.Contains("up") || re.Contains("Up"))
        {
            dir[4] = true;
        }
        if (re.Contains("down") || re.Contains("Down"))
        {
            dir[5] = true;
        }
        flag = false;
    }
예제 #23
0
        //
        // GET: /Award/Details/5
        public ActionResult Details(int id = 0)
        {
            Recognize recognize = db.Recognizes.Single(r => r.RecognitionId == id);

            if (recognize == null)
            {
                return(HttpNotFound());
            }
            else
            {
                string docpath;
                if (recognize.DocPath == null)
                {
                    docpath = @"/Images/Daniel.pdf";
                }
                else
                {
                    docpath = recognize.DocPath;
                }

                ViewBag.DocPaths = docpath;
            }
            return(View(recognize));
        }
예제 #24
0
        private void Main()
        {
            /*Image<Bgr, byte> Image1 = new Image<Bgr, byte>(Recognize.makeScreen(true)); //Your first image
             * Image<Bgr, byte> Image2 = new Image<Bgr, byte>(new Bitmap(Path.Combine(Directory.GetCurrentDirectory(), "BazaarItems/titanium.png")).ConvertToFormat(System.Drawing.Imaging.PixelFormat.Format24bppRgb)); //Your second image
             *
             * double Threshold = 0.9; //set it to a decimal value between 0 and 1.00, 1.00 meaning that the images must be identical
             *
             * Image<Gray, float> Matches = Image1.MatchTemplate(Image2, TemplateMatchingType.CcoeffNormed);
             *
             * for (int y = 0; y < Matches.Data.GetLength(0); y++)
             * {
             *  for (int x = 0; x < Matches.Data.GetLength(1); x++)
             *  {
             *      if (Matches.Data[y, x, 0] >= Threshold) //Check if its a valid match
             *      {
             *
             *          Log("Hey I found titanium!");
             *      }
             *  }
             * }*/
            Log("Main Logic Initialized");
            while (true)//Main loop
            {
                int counter = 1;
                //Refresh layer
                DebugLog("Trying to refresh Reagents (clicking X: " + int.Parse(reagentXBox.Text) + " Y: " + int.Parse(reagentYBox.Text) + ")");
                WINAPI.click(int.Parse(reagentXBox.Text), int.Parse(reagentYBox.Text));
                Cursor.Position = new Point(0, 0);
                Thread.Sleep(50);
                DebugLog("Clicked refresh, waiting for loading to finish");
                while (ContainsLoading(new Bitmap(Path.Combine(Directory.GetCurrentDirectory(), "BazaarUtils/isloading.png"))))
                {
                    Thread.Sleep(1);
                }
                DebugLog("Load finished");
                bool runAgain = true;
                while (runAgain)
                {
                    DebugLog("Scanning page " + counter);
                    counter++;
                    foreach (var item in selectedBox.Items)
                    {
                        DebugLog("Looking for " + item);
                        Image <Bgr, byte> source   = new Image <Bgr, byte>(Recognize.makeScreen(true));                                                                                                                                   // Image B
                        Image <Bgr, byte> template = new Image <Bgr, byte>(new Bitmap(Path.Combine(Directory.GetCurrentDirectory(), "BazaarItems/" + item + ".png")).ConvertToFormat(System.Drawing.Imaging.PixelFormat.Format24bppRgb)); // Image A

                        using (Image <Gray, float> result = source.MatchTemplate(template, TemplateMatchingType.CcoeffNormed))
                        {
                            double[] minValues, maxValues;
                            Point[]  minLocations, maxLocations;
                            result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

                            if (maxValues[0] > 0.9)
                            {
                                // This is a match. Do something with it, for example draw a rectangle around it.
                                Rectangle match = new Rectangle(maxLocations[0], template.Size);
                                Log("Found " + item);
                                WINAPI.click(match.X + 800, match.Y + 380);
                                DebugLog("Clicked on Item");
                                Thread.Sleep(50);
                                BuySelected();
                            }
                            else
                            {
                                DebugLog("Not found");
                            }
                        }

                        source.Dispose();
                        template.Dispose();
                    }
                    Thread.Sleep(100);
                    DebugLog("Checking if there are more pages");
                    if (ContainsNext(new Bitmap(Path.Combine(Directory.GetCurrentDirectory(), "BazaarUtils/nextpagegray.png"))))
                    {
                        DebugLog("This was the last page");
                        runAgain = false;
                    }
                    else
                    {
                        DebugLog("Found another page, clicking to hardcoded Position");
                        WINAPI.click(1250, 780);
                        Cursor.Position = new Point(0, 0);
                        Thread.Sleep(50);
                    }
                }
            }
        }
예제 #25
0
        private static Recognize CreateIvrOptions(string textToBeRead, int numberOfOptions, bool includeBack)
        {
            if (numberOfOptions > 9)
            {
                throw new Exception("too many options specified");
            }

            var choices = new List <RecognitionOption>();

            //for (int i = 1; i <= numberOfOptions; i++)
            //{
            //    //choices.Add(new RecognitionOption { Name = Convert.ToString(i), DtmfVariation = (char)('0' + i), SpeechVariation = { "one" } });
            //    choices.Add(new RecognitionOption { Name = Convert.ToString(i),SpeechVariation = new List<string>{ "one" } });

            //}
            choices.Add(new RecognitionOption {
                Name = "Register", SpeechVariation = new List <string> {
                    "register"
                }
            });
            choices.Add(new RecognitionOption {
                Name = "Register", SpeechVariation = new List <string> {
                    "schedule"
                }
            });
            choices.Add(new RecognitionOption {
                Name = "Change", SpeechVariation = new List <string> {
                    "change"
                }
            });
            choices.Add(new RecognitionOption {
                Name = "Change", SpeechVariation = new List <string> {
                    "alter"
                }
            });
            choices.Add(new RecognitionOption {
                Name = "Cancel", SpeechVariation = new List <string> {
                    "cancel"
                }
            });
            choices.Add(new RecognitionOption {
                Name = "Cancel", SpeechVariation = new List <string> {
                    "remove"
                }
            });
            choices.Add(new RecognitionOption {
                Name = "Cancel", SpeechVariation = new List <string> {
                    "delete"
                }
            });

            if (includeBack)
            {
                choices.Add(new RecognitionOption {
                    Name = "#", DtmfVariation = '#'
                });
            }

            var recognize = new Recognize
            {
                OperationId    = Guid.NewGuid().ToString(),
                PlayPrompt     = GetPromptForText(textToBeRead),
                BargeInAllowed = true,
                Choices        = choices
            };

            return(recognize);
        }
 private void AnyPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     OpenCommand.RaiseCanExecuteChanged();
     Recognize.RaiseCanExecuteChanged();
 }