public List <Recognition> Add() { Console.WriteLine("ADD"); var a = new List <Recognition>(); lock (Program.Recognitions) { foreach (var b in Program.Recognitions) { var c = new Recognition { Count = b.Count, Title = b.Title, Photos = new ObservableCollection <Photo>() }; foreach (var d in b.Photos) { c.Photos.Add(new Photo { Path = d.Path }); } a.Add(c); } Program.Recognitions.Clear(); } Console.WriteLine("add"); return(a); }
private void ComputePaintColors(starPadSDK.MathRecognizer.Line root, Recognition update) { string path = FindPath(root, update); if (path == "" || path == "X") { return; } colTime ct; if (_recent.TryGetValue(path, out ct)) // refresh the time for this path { _recent[path] = new colTime(ct.col, ++colTime.timestamp); return; } // if there are no colors left, recycle the color assigned to the LRU path if (_colors.Count == 0) { //var oldest = _recent.Aggregate(new Pair<int, string>(colTime.timestamp, null), // (min, old) => old.Value.time <= min.First ? new Pair<int, string>(old.Value.time, old.Key) : min); var oldest = _recent.Min(colTime.timestamp, (kvp) => kvp.Value.time); if (oldest.Key != null) { _colors.Add(oldest.Value.col); _recent.Remove(oldest.Key); } } // choose a color for this path _recent.Add(path, new colTime(_colors[_colors.Count - 1], ++colTime.timestamp)); _colors.RemoveAt(_colors.Count - 1); }
public void DetectShapes() { int count = 40; int minSize = 5; int maxSize = 80; var image = (Bitmap)Image.FromFile(@"C:\Users\marco\Downloads\PanoBeam\capture_pattern0.png"); Rectangle clippingRectangle = new Rectangle(new Point(563, 360), new Size(1156, 382)); var clippingRectangleCorners = new[] { new AForge.IntPoint(clippingRectangle.X, clippingRectangle.Y), new AForge.IntPoint(clippingRectangle.X + clippingRectangle.Width, clippingRectangle.Y), new AForge.IntPoint(clippingRectangle.X + clippingRectangle.Width, clippingRectangle.Y + clippingRectangle.Height), new AForge.IntPoint(clippingRectangle.X, clippingRectangle.Y + clippingRectangle.Height) }; Helpers.FillOutsideBlack(image, clippingRectangleCorners); var blobCounter = new AForge.Imaging.BlobCounter(); AForge.Imaging.Blob[] blobs; blobCounter.FilterBlobs = true; blobCounter.MaxHeight = maxSize; blobCounter.MaxWidth = maxSize; blobCounter.MinHeight = minSize; blobCounter.MinWidth = minSize; var threshold = Recognition.GetThreshold(image); blobCounter.BackgroundThreshold = Color.FromArgb(255, threshold, threshold, threshold); blobCounter.ProcessImage(image); blobs = blobCounter.GetObjectsInformation(); }
public ActionResult Create([Bind(Include = "RecognitionID,value,recognitionDescription,recognitionDate,profileID")] Recognition recognition) { Guid memberId; Guid.TryParse(User.Identity.GetUserId(), out memberId); if (memberId == recognition.profileID) { return(View("selfRecognition")); } else { { if (ModelState.IsValid) { db.recognition.Add(recognition); recognition.userName = HttpContext.User.Identity.GetUserId(); db.SaveChanges(); return(RedirectToAction("Index")); } } } ViewBag.CoreValueTypeID = new SelectList(db.recognition, "Value", "CoreValue", recognition.value); ViewBag.profileID = new SelectList(db.profile, "profileID", "employeeFullName", recognition.profileID); return(View(recognition)); }
public Value Parse(ParserContext context) { // Invoke the kind parser. Kind kind = new KindParser().Parse(context); // Abstract current token. Token token = context.Stream.Current; // Abstract the token's value. string tokenValue = token.Value; // Ensure current token is recognized as a valid value. if (!Recognition.IsLiteral(token)) { throw new Exception($"Invalid token provided as value: {token.Type}"); } // Strip character/string delimiters if applicable. else if (token.Type == TokenType.LiteralString || token.Type == TokenType.LiteralCharacter) { tokenValue = Util.ExtractStringLiteralValue(tokenValue); } // Create the value construct. Value value = new Value(kind, tokenValue); context.Stream.Skip(); // Return the construct. return(value); }
public override string ToString() { StringBuilder sb = new StringBuilder("Resource("); sb.Append("Guid: "); sb.Append(Guid); sb.Append(",NoteGuid: "); sb.Append(NoteGuid); sb.Append(",Data: "); sb.Append(Data == null ? "<null>" : Data.ToString()); sb.Append(",Mime: "); sb.Append(Mime); sb.Append(",Width: "); sb.Append(Width); sb.Append(",Height: "); sb.Append(Height); sb.Append(",Duration: "); sb.Append(Duration); sb.Append(",Active: "); sb.Append(Active); sb.Append(",Recognition: "); sb.Append(Recognition == null ? "<null>" : Recognition.ToString()); sb.Append(",Attributes: "); sb.Append(Attributes == null ? "<null>" : Attributes.ToString()); sb.Append(",UpdateSequenceNum: "); sb.Append(UpdateSequenceNum); sb.Append(",AlternateData: "); sb.Append(AlternateData == null ? "<null>" : AlternateData.ToString()); sb.Append(")"); return(sb.ToString()); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //string profileID = User.Identity.GetUserId(); //SelectList profiles = new SelectList(db.profile, "profileID", "fullName"); //profiles = new SelectList(profiles.Where(x => x.Value != profileID).ToList(), "Value", "Text"); Recognition recognition = db.recognition.Find(id); if (recognition == null) { return(HttpNotFound()); } Guid recognitionID; Guid.TryParse(User.Identity.GetUserId(), out recognitionID); if (recognitionID == recognition.recognizor) { return(View(recognition)); } else { return(View("notAuthorizedRecognition")); } }
protected Action AskQuestion(string question, Action <GrammarBuilder> matching, Action <RecognitionResult> answer, Action next) { var gb = new GrammarBuilder(); matching(gb); var grammar = new Grammar(gb); grammar.Enabled = false; recognizer.LoadGrammar(grammar); grammar.SpeechRecognized += (s, e) => { if (Recognition.ProcessCommand(e.Result)) { DisableGrammar(grammar); answer(e.Result); next(); } }; return(() => { grammar.Enabled = true; synthesizer.SpeakAsync(question); timer = new Timer(DisableGrammar, grammar, 15000, Timeout.Infinite); }); }
public void When_I_view_my_point_balance() { using (var context = new HighFiveContext(_config, _options)) { var repo = new HighFiveRepository(context, _repoLogger); var controller = new UsersController(repo, _controllerLogger); var result = controller.GetByEmail("*****@*****.**"); result.Should().BeOfType <OkObjectResult>(); var okResult = result as OkObjectResult; _userViewModelOutput = okResult.Value as UserViewModel; IEnumerable <Recognition> recognitionList = new List <Recognition>(); recognitionList = repo.GetAllRecognitions(); _recognition = null; foreach (Recognition rec in recognitionList) { if (rec.Receiver.Email == "*****@*****.**") { _recognition = rec; } } _userViewModelOutput.PointBalance = _recognition.Points; } }
/// <summary> /// Recognition (LoadBanknotesTrain) => ImageAnalyze (PreProcess) => Recognition (DetectBanknotesResults) /// </summary> private void runToolStripMenuItem_Click(object sender, EventArgs e) { if (_pathImageMain != null) { _recognition = new Recognition(); _recognition.LoadImagesTrain(); Stopwatch watch = new Stopwatch(); _imageAnalyze = new ImageAnalyze(_recognition); var imageResult = new Mat(_pathImageMain, LoadImageType.Color); watch.Start(); _imageAnalyze.RunEvaluateImage(imageResult); watch.Stop(); MessageBox.Show($"Time Evaluate: {watch.Elapsed}"); } else { MessageBox.Show("Select One Image for Evaluate"); } }
public async Task <int> CreateRequest(NewRequest request) { try { var newRecognition = new Recognition { Name = request.Name, StatusId = 1, NeuralNetworkId = request.NeuralNetworkId, Image = request.Files.Select(x => new ImageAttachment { Name = x.FileName, ImageAttachmentTypeId = ImageTypes.Recognition }).FirstOrDefault() }; recoRepo.Add(newRecognition); recoRepo.Save(); await filesService.Upload(request.Files, $"{nameof(ImageTypes.Recognition)}/{newRecognition.Id}"); return(newRecognition.Id); } catch (Exception ex) { logger.LogError(ex, "Exception when creating face recognition request "); throw; } }
public RecognitionMessage GetRecognitionData(ReportRequest reportRequest) { var recognitions = new List <Recognition>(); var parameters = DataHelper.BuildParameters(reportRequest); int recognitionQuestionID = GetQuestionByQuestionTypeID(reportRequest.SurveyID, 10); parameters = parameters.Update(new SqlParameter("@QuestionID", recognitionQuestionID)); var dsRecognitionData = HaloDatabase.GetDataTable("dbo.rptGetRecognitionData", parameters.ToArray()); if (dsRecognitionData.Rows.Count > 0) { // get promptId for comment and name var namePromptID = dsRecognitionData.AsEnumerable() .Where(r => r.IsNull("Prompt") || string.IsNullOrEmpty(r.Field <string>("Prompt"))) .Select(s => (int)s.Field <int>("PromptID")) .FirstOrDefault(); var commentPromptID = dsRecognitionData.AsEnumerable() .Where(r => !r.IsNull("Prompt") && !string.IsNullOrEmpty(r.Field <string>("Prompt"))) .Select(s => (int)s.Field <int>("PromptID")) .FirstOrDefault(); // Get names and respondentID var peopleList = dsRecognitionData.AsEnumerable() .Where(r => (r.Field <int>("PromptID") == namePromptID)) .Select(s => new { RespondentID = s.Field <int>("RespondentID"), Name = s.Field <string>("TextResponse") }) .Distinct() .OrderBy(r => r.Name).ThenBy(r => r.RespondentID) .ToList(); var commentList = dsRecognitionData.AsEnumerable() .Where(r => (r.Field <int>("PromptID") == commentPromptID)) .Select(s => new { RespondentID = s.Field <int>("RespondentID"), Comment = s.Field <string>("TextResponse") }) .Distinct() .ToList(); var duplicates = 0; foreach (var person in peopleList) { if (recognitions.Where(r => r.Name.ToLower().Trim() == person.Name.ToLower().Trim()).Count() == 0) { var recog = new Recognition() { Name = person.Name, Comments = commentList.Where(c => c.RespondentID == person.RespondentID).Select(c => c.Comment).ToList(), Count = peopleList.Where(p => p.Name.ToLower().Trim() == person.Name.ToLower().Trim()).Count() }; recognitions.Add(recog); } else { recognitions.Where(w => w.Name.ToLower().Trim() == person.Name.ToLower().Trim()) .ToList() .ForEach(s => s.Comments.Add(commentList.Where(c => c.RespondentID == person.RespondentID).Select(c => c.Comment).FirstOrDefault())); duplicates++; } } } return(new RecognitionMessage { Recognitions = recognitions }); }
private IdentificationResponse streamJob(JobInput input) { // perform Console.WriteLine("Installing ffmpeg..."); var ffmpegPath = InstallDependencies.Run(); Console.WriteLine("Getting m3u8 link..."); var m3u8Link = M3U8.GetAudioOnlyM3U8(input.Identifier); Console.WriteLine("Listening to channel..."); var mp3 = ListenToChannel.Listen(m3u8Link); Console.WriteLine("Running recognition..."); var result = Recognition.Run(mp3); Console.WriteLine(result); Console.WriteLine("Finished..."); // cleanup Console.WriteLine("Cleaning up..."); System.IO.File.Delete("/tmp/audio.mp3"); System.IO.File.Delete("/tmp/audio.mp3.cli.lo"); return(result); }
public void ConvalidandoRecuentosPorFiscales() { ConvalidandoRecuentosPorSuplentes(); var recuento0001 = blockchain.GetRecount(mesa0001Id); var recognition0001FrenteDeTodos = new Recognition { Id = Guid.NewGuid(), UrnId = mesa0001Id, Content = recuento0001.GetData() }; signer.Sign(recognition0001FrenteDeTodos, lucia); var recuento5468 = blockchain.GetRecount(mesa5468Id); var recognition5468JuntosPorElCambio = new Recognition { Id = Guid.NewGuid(), UrnId = mesa5468Id, Content = recuento5468.GetData() }; signer.Sign(recognition5468JuntosPorElCambio, mateo); var recognition5468FrenteDeTodos = new Recognition { Id = Guid.NewGuid(), UrnId = mesa5468Id, Content = recuento5468.GetData() }; signer.Sign(recognition5468FrenteDeTodos, juan); var block = blockchain.MineNextBlock(new BlockItem[] { recognition0001FrenteDeTodos, recognition5468JuntosPorElCambio, recognition5468FrenteDeTodos }); Assert.IsNotNull(block); Assert.AreEqual(3, block.Recognitions.Count); }
public void ConvalidandoRecuentosPorSuplentes() { RegistrandoRecuentos(); var recuento0001 = blockchain.GetRecount(mesa0001Id); var recognition0001 = new Recognition { Id = Guid.NewGuid(), UrnId = mesa0001Id, Content = recuento0001.GetData() }; signer.Sign(recognition0001, albin); var recuento5468 = blockchain.GetRecount(mesa5468Id); var recognition5468 = new Recognition { Id = Guid.NewGuid(), UrnId = mesa5468Id, Content = recuento5468.GetData() }; signer.Sign(recognition5468, ana); var block = blockchain.MineNextBlock(new BlockItem[] { recognition0001, recognition5468 }); Assert.IsNotNull(block); Assert.AreEqual(2, block.Recognitions.Count); }
public MainView() { InitializeComponent(); _pathImageMain = String.Empty; _imageMain = null; _svmBof = new SvmBof(); _recognition = new Recognition(); }
public ActionResult DeleteConfirmed(int id) { Recognition recognition = db.recognition.Find(id); db.recognition.Remove(recognition); db.SaveChanges(); return(RedirectToAction("Index")); }
private void button2_Click(object sender, EventArgs e) { Recognition RC = new Recognition(imgProcessing, 60); pictureBox3.Image = RC.HSV; pictureBox4.Image = RC.Lines; pictureBox2.Image = RC.Temp; }
private bool IsLassoSelect(Stroq stroq) { if (stroq.OldPolylineCusps().Length <= 4 && stroq.Count > 4) { Stroq estroq = stroq; CuspDetector.CuspSet cs = CuspDetector.FeaturePoints(estroq); Pt[] first = new Pt[cs.pts.Count / 2]; for (int i = 0; i < first.Length; i++) { if (cs.distances[i] > cs.dist / 2) { break; } else { first[i] = cs.pts[i]; } } Pt[] second = new Pt[cs.pts.Count - first.Length]; for (int j = 0; j < second.Length; j++) { second[j] = cs.pts[first.Length + j]; } Stroq s1 = new Stroq(first); Stroq s2 = new Stroq(second); float d1, d2; s1.OldNearestPoint(s2[-1], out d1); s2.OldNearestPoint(s1[0], out d2); if (Math.Min(d1, d2) / Math.Max(estroq.GetBounds().Width, estroq.GetBounds().Height) < 0.3f) { StroqCollection stqs = _mathStroqs.HitTest(estroq, 50); StroqCollection stqs2 = _mathStroqs.HitTest(estroq.Reverse1(), 50); if (stqs2.Count > stqs.Count) { stqs = stqs2; } stqs.Remove(estroq); StroqCollection stqs3 = new StroqCollection(stqs.Where((Stroq s) => _mrec.Charreco.Classification(_mrec.Sim[s]) != null)); stqs = stqs3; Recognition rtemp = _mrec.ClassifyOneTemp(estroq); if (stqs.Count > 0 && (rtemp == null || !rtemp.alts.Contains(new Recognition.Result(Unicode.S.SQUARE_ROOT)))) { if (rtemp != null) { Console.WriteLine("select recognized for " + rtemp.allograph); } return(true); } else { // Generic additional selections would be called here. return(false); } } } return(false); }
public ActionResult Edit([Bind(Include = "recognitionId,recognizedBy,description,recognitionPoints")] Recognition recognition) { if (ModelState.IsValid) { db.Entry(recognition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recognition)); }
public static void LeftClickImage(string image) { if (Recognition.ImageExists(image)) { Point coords = Recognition.ImageCoords(image); Mouse.Move(coords.X, coords.Y); Mouse.PressButton(Mouse.MouseKeys.Left, 150); } }
public ActionResult Edit([Bind(Include = "recognitionID,employeeName,description,dateOfRecognition")] Recognition recognition) { if (ModelState.IsValid) { db.Entry(recognition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recognition)); }
public static void WaitForImage(string imagePath) { bool exists = Recognition.ImageExists(imagePath); while (!exists) { exists = Recognition.ImageExists(imagePath); Thread.Sleep(1000); } }
public Adaption(All all, Recognition r) { this.all = all; this.r = r; sentenceCnt = 0; absX = new List <Vector2>(); absY = new List <Vector2>(); relX = new List <Vector2>(); relY = new List <Vector2>(); }
public ActionResult Edit([Bind(Include = "ID,award,recognizor,recognized,recognizationDate")] Recognition recognition) { if (ModelState.IsValid) { db.Entry(recognition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recognition)); }
public ActionResult Create([Bind(Include = "ID,award,recognizor,recognized,recognizationDate")] Recognition recognition) { if (ModelState.IsValid) { db.recognition.Add(recognition); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recognition)); }
public ActionResult Create([Bind(Include = "recognitionID,employeeName,description,dateOfRecognition")] Recognition recognition) { if (ModelState.IsValid) { db.Recognitions.Add(recognition); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recognition)); }
public ActionResult Edit([Bind(Include = "recognitionID,recognitionTitle,recognitionExplanation,employeeID")] Recognition recognition) { if (ModelState.IsValid) { db.Entry(recognition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.employeeID = new SelectList(db.Employees, "employeeID", "firstName", recognition.employeeID); return(View(recognition)); }
public ActionResult Edit([Bind(Include = "recognitionID,description,values,id")] Recognition recognition) { if (ModelState.IsValid) { db.Entry(recognition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id = new SelectList(db.Profile, "id", "firstName", recognition.id); return(View(recognition)); }
public ActionResult Create([Bind(Include = "ID,award,recognizer,recognized,recognizationDate")] Recognition recognition) { if (ModelState.IsValid) { db.Recognitions.Add(recognition); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.recognizer = new SelectList(db.employeeData, "ID", "fullName"); return(View(recognition)); }
/// <summary> /// Initializes a new instance of the PhoneCntrl class. /// </summary> /// <param name="spee">The speeach generator</param> /// <param name="Recog">The voice recognition</param> public PhoneCntrl(Speech.SpeechMain spee, Recognition.RecognitionMain Recog) { }
/// <summary>Utility method to get the first text result from recognition</summary> /// <param name="results">Recognition result data</param> private String getResultString(Recognition results) { String output = ""; if (results.getResultCount() > 0) { output = results.getResult(0).getText(); //for (int i = 0; i < results.length; i++) // _.add("[" + results[i].getScore() + "]: " + results[i].getText()); } return output; }
private void _mrec_ParseUpdated(MathRecognition source, Recognition chchanged, bool updateMath) { /* Evaluate math if necessary */ if (updateMath) try { Evaluator.UpdateMath(_mrec.Ranges.Select((Parser.Range r) => r.Parse)); } catch { } /* reset geometry displayed: range displays, etc */ underlay.Children.Clear(); inqCanvas.Children.Clear(); /* set up to draw background yellow thing for range displays */ Brush fill3 = new SolidColorBrush(Color.FromArgb(50, 255, 255, 180)); Brush fill2 = new SolidColorBrush(Color.FromArgb(75, 255, 255, 180)); Brush fill1 = new SolidColorBrush(Color.FromArgb(100, 255, 255, 180)); Brush sqr3 = new SolidColorBrush(Color.FromArgb(50, 0, 255, 0)); Brush sqr2 = new SolidColorBrush(Color.FromArgb(75, 0, 255, 0)); Brush sqr1 = new SolidColorBrush(Color.FromArgb(100, 0, 255, 0)); foreach (Parser.Range rrr in _mrec.Ranges) { Rct rangebbox = bbox(rrr.Strokes); CurrentStrokesBoudningBox = rangebbox; Rct box = rangebbox.Inflate(8, 8); /* draw yellow box */ DrawingVisual dv = new DrawingVisual(); DrawingContext dc = dv.RenderOpen(); dc.DrawRoundedRectangle(fill3, null, box, 4, 4); dc.DrawRoundedRectangle(fill2, null, box.Inflate(-4, -4), 4, 4); dc.DrawRoundedRectangle(fill1, null, box.Inflate(-8, -8), 4, 4); dc.Close(); underlay.Children.Add(dv); if (rrr.Parse != null) { /* draw interpretation of entry */ if (rrr.Parse.expr != null) { dv = new DrawingVisual(); dc = dv.RenderOpen(); // this is an example of normal drawing of an expr Rct nombb = starPadSDK.MathExpr.ExprWPF.EWPF.DrawTop(rrr.Parse.expr, 22, dc, Colors.Blue, new Pt(box.Left, box.Bottom + 24), true); dc.Close(); underlay.Children.Add(dv); } /* draw result of computation, if any */ if (rrr.Parse.finalSimp != null) { Rct nombb; Expr result = rrr.Parse.matrixOperationResult == null ? rrr.Parse.finalSimp : rrr.Parse.matrixOperationResult; // this is an example of drawing an expr by getting a geometry of it first, so can be used for special effects, etc. Geometry g = starPadSDK.MathExpr.ExprWPF.EWPF.ComputeGeometry(result, 22, out nombb); System.Windows.Shapes.Path p = new System.Windows.Shapes.Path(); p.Data = g; p.Stroke = Brushes.Red; p.Fill = Brushes.Transparent; p.StrokeThickness = 1; p.RenderTransform = new TranslateTransform(box.Right + 10, box.Center.Y); inqCanvas.Children.Add(p); } /* colorize ink. Ideally we would have kept track of which ink strokes had changes and only update colorization in those ranges affected * by the changes. */ if (rrr.Parse.root != null) _colorizer.Colorize(rrr.Parse.root, rrr.Strokes, _mrec); } } /* Update alternates menu if user wrote a char */ if (chchanged != null) { showSidebarAlts(new[] { chchanged }, new StroqCollection(_mrec.Sim[chchanged.strokes])); } #if false /* print out log of current 1st-level parse, for debugging */ List<string> resstrs = new List<string>(); foreach(Parser.Range r in _mrec.Ranges) { Parser.ParseResult p = r.Parse; if(p != null && p.root != null) resstrs.Add(p.root.Print()); } if(resstrs.Count > 0) Console.WriteLine(resstrs.Aggregate((string a, string b) => a + " // " + b)); foreach(Parser.Range r in _mrec.Ranges) { Parser.ParseResult pr = r.Parse; if(pr != null && pr.expr != null) Console.WriteLine(Text.Convert(pr.expr)); } #endif }
/// <summary>Callback method for recognition complete with results</summary> public void onResults(Recognizer recognizer, Recognition results) { System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onResults: Entered method."); currentRecognizer = null; recording = false; lastResult = results; string resultString = results.getResult(0).getText(); ReturnObject returnObject = new ReturnObject(); try{ setReturnCode(returnObject, RC_SUCCESS, "Reco Success"); returnObject.eventName = EVENT_RECO_COMPLETE; returnObject.result = resultString; returnObject.results = getResultArray(results); //returnObject.put("results", resultArray); } catch(Exception je){ System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onResults: Error storing results: " + je.ToString()); } //success(returnObject, recognitionCallbackId); PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject); DispatchCommandResult(result); // for debugging purpose: printing out the speechkit session id System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onResults: Leaving method. Results = " + resultString); }
public void onResults(Recognizer recognizer, Recognition results) { Logger.info(this, "onResults()"); // for debugging purpose: logging the speechkit session id Logger.info(this, "session id: [" + _speechKit.getSessionId() + "]"); hidePopup(); Deployment.Current.Dispatcher.BeginInvoke(() => { block.Text = results.getResult(0).getText(); }); _recognizer.cancel(); _recognizer = null; }
/// <summary> Method to start speech recognition</summary> /// <param name="args">JSON encoded request parameters</param> public void startRecognition(string args) { System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startRecognition: Entered method."); PluginResult result = null; StartRecoParameters startParams = JsonHelper.Deserialize<StartRecoParameters>(args); ReturnObject returnObject = new ReturnObject(); if (speechKit != null){ if (recording == false) { // get the recognition type String recognitionType = startParams.recognitionType; System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: startReco: Reco Type = [" + recognitionType + "]"); String recognizerType = RecognizerRecognizerType.Dictation; if ("websearch".Equals(recognitionType, StringComparison.CurrentCultureIgnoreCase)) { recognizerType = RecognizerRecognizerType.Search; } // get the language String language = startParams.language; System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: startReco: Language = [" + language + "]"); lastResult = null; // create and start the recognizer reference Thread thread = new Thread(() => { currentRecognizer = speechKit.createRecognizer(recognizerType, RecognizerEndOfSpeechDetection.Long, language, this, null); currentRecognizer.start(); }); thread.Start(); //_currentRecognizer = _speechKit.createRecognizer(recognizerType, RecognizerEndOfSpeechDetection.Long, language, this, new object()); //_currentRecognizer.start(); System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Recognition started."); setReturnCode(returnObject, RC_SUCCESS, "Reco Start Success"); returnObject.eventName = EVENT_RECO_STARTED; } else { System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Recognition already started."); setReturnCode(returnObject, RC_SUCCESS, "Reco Already Active"); returnObject.eventName = EVENT_RECO_ALREADY_STARTED; } } else { System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Speech kit was null, initialize not called."); setReturnCode(returnObject, RC_NOT_INITIALIZED, "Reco Start Failure: Speech Kit not initialized."); } result = new PluginResult(PluginResult.Status.OK, returnObject); result.KeepCallback = true; DispatchCommandResult(result); System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startRecognition: Leaving method."); //return result; }
/// <summary>Creates a RecoResult array representation of the results passed in to be returned to the front end</summary> /// <param name="results">Recognition result data</param> private RecoResult[] getResultArray(Recognition results) { RecoResult[] resultArray = null; int resultCount = results.getResultCount(); if (resultCount > 0) { resultArray = new RecoResult[resultCount]; System.Diagnostics.Debug.WriteLine("Recognizer.Listener.onResults: Result count: " + resultCount); for (int i = 0; i < resultCount; i++) { resultArray[i] = new RecoResult(); resultArray[i].value = results.getResult(i).getText(); resultArray[i].confidence = results.getResult(i).getScore(); } } return resultArray; }
public void onResults(Recognizer recognizer, Recognition results) { string text = results.getResult(0).getText(); TraceHelper.AddMessage("onResults: " + text); speechStateDelegate.DynamicInvoke(SpeechHelper.SpeechState.Finished, "Finished: " + text); speechToTextDelegate.DynamicInvoke(text); // trace a bad state if (recognizer != _recognizer) TraceHelper.AddMessage("recognizer doesn't match"); _recognizer.cancel(); _recognizer = null; speechOperationInProgress = false; }