/// <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); }
private void Button_Click(object sender, RoutedEventArgs e) { startButton.IsEnabled = false; stopButton.IsEnabled = true; Recognize.StartRecordingAsync(confidence, language, serviceAcc); }
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); }
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(); }
public ActionResult DeleteConfirmed(int id) { Recognize recognize = db.Recognizes.Single(r => r.RecognitionId == id); db.Recognizes.DeleteObject(recognize); db.SaveChanges(); return(RedirectToAction("Index")); }
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); }
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)); }
// // 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)); }
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)); }
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(); }
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(); }
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); } }
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)); }
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); } }
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(); }
// // 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)); }
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) }
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)); }
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); } }
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; }
// // 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)); }
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); } } } }
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(); }