Exemple #1
0
        /// <summary>
        /// Playbacks a wave file.
        /// </summary>
        /// <param name="waveUrl">URL of the audio wave file to play.</param>
        public ProgramHelperBase Play(string waveUrl)
        {
            try
            {
                string outputDirectory = Utility.GetTmpFolder();
                string file            = Path.Combine(outputDirectory, "_wave_tmp." + Path.GetExtension(waveUrl));
                using (var webClient = new WebClient())
                {
                    byte[] audiodata = webClient.DownloadData(waveUrl);

                    if (!Directory.Exists(outputDirectory))
                    {
                        Directory.CreateDirectory(outputDirectory);
                    }
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }

                    var stream = File.OpenWrite(file);
                    stream.Write(audiodata, 0, audiodata.Length);
                    stream.Close();

                    webClient.Dispose();
                }

                SpeechUtils.Play(file);
            }
            catch (Exception e)
            {
                HomeGenieService.LogError(e);
            }
            return(this);
        }
Exemple #2
0
 public void Say(string sentence, string locale = null, bool goAsync = false)
 {
     if (string.IsNullOrWhiteSpace(locale))
     {
         locale = Thread.CurrentThread.CurrentCulture.Name;
     }
     try
     {
         SpeechUtils.Say(sentence, locale, goAsync);
     }
     catch (Exception e)
     {
         HomeGenieService.LogError(e);
     }
 }
        // Token: 0x06001159 RID: 4441 RVA: 0x00065A68 File Offset: 0x00063C68
        public static List <string> GetNormalizedNames(List <string> inputNames, NameNormalizer nameNormalizer, RecipientType recipientType, GrammarGenerationLog generationLog)
        {
            UMTracer.DebugTrace("NormalizationHelper.GetNormalizedNames", new object[0]);
            List <string> list = new List <string>();
            int           i    = 0;

            while (i < inputNames.Count)
            {
                string text = inputNames[i];
                UMTracer.DebugTrace("NormalizationHelper.GetNormalizedName inputName='{0}', recipientType={1}", new object[]
                {
                    text,
                    recipientType
                });
                string input = GrammarRecipientHelper.CharacterMapReplaceString(text);
                Dictionary <string, bool> dictionary = GrammarRecipientHelper.ApplyExclusionList(input, recipientType);
                if (dictionary.Count != 0)
                {
                    using (Dictionary <string, bool> .KeyCollection.Enumerator enumerator = dictionary.Keys.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            string text2 = enumerator.Current;
                            if (!string.IsNullOrEmpty(text2) && NormalizationHelper.IsGrammarEntryFormatValid(text2))
                            {
                                bool   flag  = false;
                                string text3 = SpeechUtils.SrgsEncode(text2);
                                if (dictionary[text2])
                                {
                                    if (nameNormalizer.IsNameAcceptable(text3))
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        generationLog.WriteLine(Strings.NormalizationFailedError(text));
                                    }
                                }
                                else
                                {
                                    flag = true;
                                }
                                if (flag && !string.IsNullOrEmpty(text3))
                                {
                                    UMTracer.DebugTrace("Adding name '{0}'", new object[]
                                    {
                                        text3
                                    });
                                    list.Add(text3);
                                }
                            }
                        }
                        goto IL_12D;
                    }
                    goto IL_11C;
                }
                goto IL_11C;
IL_12D:
                i++;
                continue;
IL_11C:
                generationLog.WriteLine(Strings.EntryExcludedFromGrammar(text));
                goto IL_12D;
            }
            if (list.Count != 0)
            {
                return(list);
            }
            return(null);
        }
Exemple #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     SpeechUtils.speechPlay(lblresult.Text);
 }
Exemple #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     SpeechUtils.speechPlay(lblquestion.Text.Split('.')[1]);
 }