Пример #1
0
        public IEnumerator TestGetVoiceModel()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to GetVoiceModel...");
            VoiceModel getVoiceModelResponse = null;

            service.GetVoiceModel(
                callback: (DetailedResponse <VoiceModel> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "GetVoiceModel result: {0}", response.Response);
                getVoiceModelResponse = response.Result;
                Assert.IsNotNull(getVoiceModelResponse);
                Assert.IsTrue(getVoiceModelResponse.CustomizationId == customizationId);
                Assert.IsTrue(getVoiceModelResponse.Name == voiceModelName);
                Assert.IsTrue(getVoiceModelResponse.Language == voiceModelLanguage);
                Assert.IsTrue(getVoiceModelResponse.Description == voiceModelDescription);
                Assert.IsNull(error);
            },
                customizationId: customizationId
                );

            while (getVoiceModelResponse == null)
            {
                yield return(null);
            }
        }
Пример #2
0
        public IEnumerator TestCreateVoiceModel()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to CreateVoiceModel...");
            VoiceModel createVoiceModelResponse = null;

            service.CreateVoiceModel(
                callback: (DetailedResponse <VoiceModel> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "CreateVoiceModel result: {0}", response.Response);
                createVoiceModelResponse = response.Result;
                customizationId          = createVoiceModelResponse.CustomizationId;
                Assert.IsNotNull(createVoiceModelResponse);
                Assert.IsNotNull(customizationId);
                Assert.IsNull(error);
            },
                name: voiceModelName,
                language: voiceModelLanguage,
                description: voiceModelDescription
                );

            while (createVoiceModelResponse == null)
            {
                yield return(null);
            }
        }
Пример #3
0
        public IActionResult Alarm(VoiceModel voiceModel)
        {
            ViewData["From.FR"] = configuration["appSettings:Nexmo.Application.Number.From.FR"];
            ViewData["From.UK"] = configuration["appSettings:Nexmo.Application.Number.From.UK"];

            // create a logger placeholder
            Logger logger = null;

            try
            {
                logger = NexmoLogger.GetLogger("VoiceAlarmLogger");
                logger.Open();

                // Get an instance of the blob storage to store the phone number to connect to
                CloudBlobContainer container = Storage.GetCloudBlobContainer("vapi-connect-container");
                ViewData["feedback"]  = "Create a blob container if it does not exist: " + container.CreateIfNotExistsAsync().Result.ToString() + " \n";
                ViewData["feedback"] += "The storage container has been loaded successfully. \n";
                logger.Log(container.Name + " has been loaded successfully.");

                var blobUpload = Storage.UploadBlobAsync(container, logger, "{\"recipient\": \"" + voiceModel.To + "\"}", "alarmAlert");
                ViewData["feedback"] += "The recipient's phone number " + voiceModel.To + " has been saved successfully.";
                logger.Log("The recipient's phone number " + voiceModel.To + " has been saved successfully.");
            }
            catch
            {
                ViewData["error"] = "The recipient's phone number " + voiceModel.To + " could not be saved. Please try again.";
            }
            finally
            {
                logger.Close();
                logger.Deregister();
            }

            return(View());
        }
Пример #4
0
 /// <summary>
 /// 发送输入的语音信息
 /// </summary>
 private void SendInputVoice()
 {
     if (!string.IsNullOrEmpty(this.InputVoiceInfo))
     {
         VoiceModel vm = new VoiceModel()
         {
             Content = this.InputVoiceInfo,
         };
         VoiceRemindHelper.SendVoiceInfoToMeasure(vm, CurClientModel.ClientId);
         #region 写日志
         LogModel log = new LogModel()
         {
             CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
             Direction    = LogConstParam.Directions_Out,
             FunctionName = "坐席_视频监控窗体_发送输入的语音信息",
             Level        = LogConstParam.LogLevel_Info,
             Msg          = "发送语音提示命令【" + SeatSendCmdEnum.cmd2client + "】给任务服务器",
             Origin       = "汽车衡_" + LoginUser.Role.Name,
             Data         = new { clientid = CurClientModel.ClientId, cmd = ParamCmd.Voice_Prompt, msg = vm },
             IsDataValid  = LogConstParam.DataValid_Ok,
             ParamList    = new List <DataParam>()
             {
                 new DataParam()
                 {
                     ParamName = "cmd", ParamValue = SeatSendCmdEnum.cmd2client
                 }
             },
             OperateUserName = LoginUser.Name
         };
         Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
         #endregion
     }
 }
Пример #5
0
        public static TropoModel VoiceToTropo(VoiceModel vmodel)
        {
            TropoModel tmodel = new TropoModel();

            switch (vmodel.GetType().ToString())
            {
            case "VoiceModel.Exit":
                tmodel = ConvertExit((Exit)vmodel);
                break;

            case "VoiceModel.Ask":
                tmodel = ConvertAsk((global::VoiceModel.Ask)vmodel);
                break;

            case "VoiceModel.Say":
                tmodel = ConvertSay((global::VoiceModel.Say)vmodel);
                break;

            default:
                tmodel = Error();
                break;
            }

            return(tmodel);
        }
Пример #6
0
        /// <summary>
        /// Create a custom model. Creates a new empty custom voice model. You must specify a name for the new custom model; you can optionally specify the language and a description of the new model. The model is owned by the instance of the service whose credentials are used to create it.  **Note:** This method is currently a beta release.
        /// </summary>
        /// <param name="createVoiceModel">A `CreateVoiceModel` object that contains information about the new custom voice model.</param>
        /// <param name="customData">Custom data object to pass data including custom request headers.</param>
        /// <returns><see cref="VoiceModel" />VoiceModel</returns>
        public VoiceModel CreateVoiceModel(CreateVoiceModel createVoiceModel, Dictionary <string, object> customData = null)
        {
            if (createVoiceModel == null)
            {
                throw new ArgumentNullException(nameof(createVoiceModel));
            }
            VoiceModel result = null;

            try
            {
                var request = this.Client.WithAuthentication(this.UserName, this.Password)
                              .PostAsync($"{this.Endpoint}/v1/customizations");
                request.WithBody <CreateVoiceModel>(createVoiceModel);
                if (customData != null)
                {
                    request.WithCustomData(customData);
                }
                result = request.As <VoiceModel>().Result;
                if (result == null)
                {
                    result = new VoiceModel();
                }
                result.CustomData = request.CustomData;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
Пример #7
0
        /// <summary>
        /// List a custom model. Lists all information about a specified custom voice model. In addition to metadata such as the name and description of the voice model, the output includes the words and their translations as defined in the model. To see just the metadata for a voice model, use the **List custom models** method.   **Note:** This method is currently a beta release.
        /// </summary>
        /// <param name="customizationId">The GUID of the custom voice model. You must make the request with service credentials created for the instance of the service that owns the custom model.</param>
        /// <param name="customData">Custom data object to pass data including custom request headers.</param>
        /// <returns><see cref="VoiceModel" />VoiceModel</returns>
        public VoiceModel GetVoiceModel(string customizationId, Dictionary <string, object> customData = null)
        {
            if (string.IsNullOrEmpty(customizationId))
            {
                throw new ArgumentNullException(nameof(customizationId));
            }
            VoiceModel result = null;

            try
            {
                var request = this.Client.WithAuthentication(this.UserName, this.Password)
                              .GetAsync($"{this.Endpoint}/v1/customizations/{customizationId}");
                if (customData != null)
                {
                    request.WithCustomData(customData);
                }
                result = request.As <VoiceModel>().Result;
                if (result == null)
                {
                    result = new VoiceModel();
                }
                result.CustomData = request.CustomData;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
Пример #8
0
 public static void RemoveVoice(this GameMasterModel gameMaster, VoiceModel voice)
 {
     if (voice != null && gameMaster.Voices.Contains(voice))
     {
         gameMaster.Voices.Remove(voice);
         gameMaster.ChartModel.UpdateChartValues();
     }
 }
Пример #9
0
 public static void AddWillpower(this GameMasterModel gameMaster, VoiceModel voice, int value)
 {
     if (voice != null && voice.Willpower + value >= 0)
     {
         voice.Willpower += value;
     }
     else if (voice != null && voice.Willpower + value < 0)
     {
         voice.Willpower = 0;
     }
 }
Пример #10
0
 internal static void AddObsessionPoint(this GameMasterModel gameMaster, VoiceModel voice, int value)
 {
     if (voice != null && voice.ScoreHistory[gameMaster.Turn].Y + value >= 0)
     {
         voice.AddObsessionPoint(gameMaster.Turn, value);
     }
     else if (voice != null && voice.ScoreHistory[gameMaster.Turn].Y + value < 0)
     {
         voice.AddObsessionPoint(gameMaster.Turn, 0);
     }
 }
Пример #11
0
        /// <summary>
        /// 向任务服务器发送语音提示的方法
        /// </summary>
        /// <param name="obj"></param>
        public static void SendVoiceInfoToMeasure(object obj, string measureClientId)
        {
            VoiceModel vm   = obj as VoiceModel;
            int        unm  = CommonMethod.CommonMethod.GetRandom();
            var        para = new
            {
                clientid = measureClientId,
                cmd      = ParamCmd.Voice_Prompt,
                msg      = vm,
                msgid    = unm
            };

            SocketCls.Emit(SeatSendCmdEnum.cmd2client, JsonConvert.SerializeObject(para));
        }
Пример #12
0
        private VoiceModel ParseArchiveNode(IElement archiveNode)
        {
            // parse nickname
            var nickName = archiveNode
                           .QuerySelectorAll("div")
                           .Single(x => x.ClassName == "thumbArea")
                           .TextContent;

            // parse voice body
            var voiceNode = archiveNode
                            .QuerySelectorAll("div")
                            .Single(x => x.ClassName == "voiced");

            var voiceSpanText = voiceNode.QuerySelectorAll("span").First().TextContent;

            var spanIdx = voiceNode.TextContent.IndexOf(voiceSpanText);
            var voice   = voiceNode.TextContent.Substring(0, spanIdx).Trim();

            // parse post_time
            var postTimeStr = archiveNode
                              .QuerySelectorAll("input")
                              .First(x => x.GetAttribute("name") == "post_time")
                              .GetAttribute("value");
            var postTime = DateTime.ParseExact(postTimeStr, "yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo).AddHours(-9);

            // parse url
            var url = voiceNode
                      .QuerySelectorAll("span")
                      .First()
                      .QuerySelectorAll("a")
                      .First()
                      .GetAttribute("href");

            var voiceModel = new VoiceModel
            {
                NickName = nickName,
                Voice    = voice,
                PostTime = postTime,
                Url      = url,
                Response = ParseVoiceResponseNode(archiveNode),
            };

            foreach (var item in voiceModel.Response)
            {
                item.Parent = voiceModel;
            }

            return(voiceModel);
        }
Пример #13
0
        private async void LoadProfile()
        {
            progressbar.Visibility = Visibility.Visible;

            Object api = settings.Values["api"];
            Object id  = settings.Values["userid"];

            if (api != null && id != null)
            {
                try
                {
                    var httpClient = new HttpClient();
                    var response   = await httpClient.GetAsync(common.getIP() + "api/getvoice/" + api.ToString() + "/" + id.ToString());

                    progressbar.Visibility = Visibility.Collapsed;

                    if (response.IsSuccessStatusCode)
                    {
                        string content = await response.Content.ReadAsStringAsync();

                        VoiceModel model = JsonConvert.DeserializeObject <VoiceModel>(content);


                        LoggingMsg("Retreiving The Created Profile...");
                        Boolean status = await GetStatusProfile(model.speechid);

                        LoggingMsg("Speaker Profile Retreived.");
                        if (status)
                        {
                            PhraseTB.Text = model.phrase;
                        }
                        else
                        {
                            LoggingMsg("Profile still training...Try again later...");
                        }
                    }
                    else
                    {
                        LoggingMsg("Retrieve Profile error...");
                    }
                }
                catch
                {
                    LoggingMsg("Error occur...please try again later...");
                    progressbar.Visibility = Visibility.Collapsed;
                }
            }
        }
Пример #14
0
        private async void CheckProfileExist()
        {
            progressbar.Visibility = Visibility.Visible;

            Object api = settings.Values["api"];
            Object id  = settings.Values["userid"];

            if (api != null && id != null)
            {
                try
                {
                    var httpClient = new HttpClient();
                    var response   = await httpClient.GetAsync(common.getIP() + "api/getvoice/" + api.ToString() + "/" + id.ToString());

                    if (response.IsSuccessStatusCode)
                    {
                        string content = await response.Content.ReadAsStringAsync();

                        VoiceModel model = JsonConvert.DeserializeObject <VoiceModel>(content);

                        VoiceProfileId             = model.speechid;
                        settings.Values["voiceid"] = VoiceProfileId;
                        LoggingMsg("Voice Id: " + VoiceProfileId);
                        LoggingMsg("Retreiving The Created Profile...");
                        UpdateProfileStatus(VoiceProfileId);
                        LoggingMsg("Speaker Profile Retreived.");
                        ProfileCB.IsChecked = true;
                        PhraseTB.Text       = model.phrase;


                        progressbar.Visibility      = Visibility.Collapsed;
                        EnrollBtn.Visibility        = Visibility.Visible;
                        CreateProfileBtn.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        CreateProfile();
                        LoggingMsg("No profile exist...creating profile..");
                    }
                }
                catch
                {
                    LoggingMsg("Error occur...please try again later...");
                    progressbar.Visibility = Visibility.Collapsed;
                }
            }
        }
Пример #15
0
        private void GetVoices()
        {
            var voices       = SpeechSynthesizer.AllVoices;
            var defaultVoice = SpeechSynthesizer.DefaultVoice;

            // Put the VoiceInformation into an VoiceModel
            foreach (VoiceInformation voice in voices)
            {
                var voiceModel = new VoiceModel(voice);
                Voices.Add(voiceModel);

                // Check for the default voice of the system and if true set it as the currently selected voice
                if (voiceModel.VoiceId == defaultVoice.Id)
                {
                    SelectedVoice = voiceModel;
                }
            }
        }
Пример #16
0
        public static void AddVoice(this GameMasterModel gameMaster, VoiceModel voice, ILogger logger)
        {
            if (voice != null)
            {
                var newVoice = new VoiceModel(voice)
                {
                    Logger       = logger,
                    ScoreHistory = new ChartValues <ObservablePoint>()
                };

                // Add zero points from turn 1 to current turn
                for (var i = 0; i <= gameMaster.Turn; i++)
                {
                    newVoice.ScoreHistory.Add(new ObservablePoint(i, 0));
                }

                gameMaster.Voices.Add(newVoice);
                gameMaster.ChartModel.UpdateChartValues();
            }
        }
Пример #17
0
        public IActionResult Index(VoiceModel voiceModel)
        {
            ViewData["From.FR"] = configuration["appSettings:Nexmo.Application.Number.From.FR"];
            ViewData["From.UK"] = configuration["appSettings:Nexmo.Application.Number.From.UK"];

            if (ModelState.IsValid)
            {
                // create a logger placeholder
                Logger logger = null;

                try
                {
                    logger = NexmoLogger.GetLogger("TTSLogger");
                    logger.Open();

                    if (NexmoApi.MakeBasicTTSCall(voiceModel, logger, configuration))
                    {
                        ViewData["feedback"] = "Your phone call is starting now...";
                    }
                    else
                    {
                        ViewData["error"] = "Your request could not be connected at this time. Please try again later.";
                    }
                }
                catch (Exception e)
                {
                    logger.Log(Level.Exception, e);
                    ViewData["error"] = "There has been an issue dealing with your request. Please try again later.";
                }
                finally
                {
                    logger.Close();
                    logger.Deregister();
                }
            }

            return(View());
        }
Пример #18
0
        public static string ConvertVoiceModelToWebApi(VoiceModel vmodel, string recordingUri)
        {
            string tropoJson = string.Empty;

            switch (vmodel.GetType().ToString())
            {
            case "VoiceModel.Exit":
                tropoJson = ConvertExit((Exit)vmodel);
                break;

            case "VoiceModel.Ask":
                tropoJson = ConvertAsk((global::VoiceModel.Ask)vmodel);
                break;

            case "VoiceModel.Say":
                tropoJson = ConvertSay((global::VoiceModel.Say)vmodel);
                break;

            case "VoiceModel.Transfer":
                tropoJson = ConvertTransfer((global::VoiceModel.Transfer)vmodel);
                break;

            case "VoiceModel.Record":
                tropoJson = ConvertRecord((global::VoiceModel.Record)vmodel, recordingUri);
                break;

            case "VoiceModel.Call":
                tropoJson = ConvertCall((global::VoiceModel.Call)vmodel);
                break;

            default:
                tropoJson = ConversionError();
                break;
            }
            return(tropoJson);
        }
Пример #19
0
 private BleController()
 {
     moveModel  = new MoveModel();
     voiceModel = new VoiceModel();
 }
Пример #20
0
        public HttpResponseMessage SmsInbound()
        {
            // create a logger placeholder
            Logger logger      = null;
            var    httpRequest = new HttpRequestMessage();

            try
            {
                logger = NexmoLogger.GetLogger("InboundMessagingSmsLogger");
                logger.Open();

                using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
                {
                    var value       = reader.ReadToEndAsync();
                    var moSmsObject = JsonConvert.DeserializeObject <InboundSmsObject>(value.Result);
                    logger.Log("Messaging SMS Inbound body: " + JsonConvert.SerializeObject(moSmsObject, Formatting.Indented));
                    logger.Log("Messaging SMS Inbound - The text message entered is: " + moSmsObject.text);
                    logger.Log("Messaging SMS Inbound - The text message reciptient is: " + moSmsObject.to);

                    if (moSmsObject.to == configuration["appSettings:Nexmo.Application.Number.From.FR"] || moSmsObject.to == configuration["appSettings:Nexmo.Application.Number.From.UK"])
                    {
                        if (moSmsObject.text.ToLower().Trim() == "trigger")
                        {
                            VoiceModel voiceModel = new VoiceModel()
                            {
                                From = moSmsObject.to,
                                To   = moSmsObject.msisdn
                            };

                            var alertNcco = NexmoApi.MakeAlertTTSCall(voiceModel, logger, configuration);
                            if (alertNcco)
                            {
                                httpRequest.CreateResponse(HttpStatusCode.UnprocessableEntity);
                            }
                        }
                        else if (moSmsObject.text.ToLower().Trim() == "rob")
                        {
                            var result = NexmoApi.MakeIvrCallWithMachineDetection(moSmsObject.text, logger, configuration);
                        }
                        else if (moSmsObject.text.ToLower().Trim() == "mason")
                        {
                            var result = NexmoApi.MakeIvrCallWithMachineDetection(moSmsObject.text, logger, configuration);
                        }
                        else if (moSmsObject.text.ToLower().Trim() == "kaine")
                        {
                            var result = NexmoApi.MakeIvrCallWithMachineDetection(moSmsObject.text, logger, configuration);
                        }
                        else if (moSmsObject.text.ToLower().Trim() == "perry")
                        {
                            var result = NexmoApi.MakeIvrCallWithMachineDetection(moSmsObject.text, logger, configuration);
                        }
                        else if (moSmsObject.text.ToLower().Trim() == "jpc")
                        {
                            var result = NexmoApi.MakeIvrCallWithMachineDetection(moSmsObject.text, logger, configuration);
                        }
                        else
                        {
                            // Add the message in a queue to be processed in the chat demo
                            var queue = Storage.CreateQueue("chat", configuration, logger);
                            Storage.InsertMessageInQueue(queue, JsonConvert.SerializeObject(moSmsObject), 3000, logger);

                            logger.Log(Level.Warning, "Messaging SMS Inbound added to the queue: " + JsonConvert.SerializeObject(moSmsObject, Formatting.Indented));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                logger.Log(Level.Exception, e);
                return(httpRequest.CreateResponse(HttpStatusCode.InternalServerError));
            }
            finally
            {
                logger.Close();
                logger.Deregister();
            }

            return(httpRequest.CreateResponse(HttpStatusCode.OK));
        }
 public void LogRemoveVoice(VoiceModel voice)
 {
 }
Пример #22
0
        public ShellViewModel(IWindowManager windowManager,
                              ClockViewModel clockView,
                              QuotesViewModel quotesView,
                              ImagesViewModel imagesView,
                              VoiceModel voiceModel,
                              ControllerViewModel controllerView)
        {
            ClockView       = clockView;
            QuotesView      = quotesView;
            ImagesView      = imagesView;
            _windowManager  = windowManager;
            _controllerView = controllerView;
            _voiceModel     = voiceModel;

            _controllerView.ControllerEvent += async(sender, eArg) =>
            {
                if (eArg is ChangeNameEventArgs nextAttendee)
                {
                    await ClockView.Stop();

                    if (DisplayTitle != "GOOD MORNING!" && DisplayTitle != "THANK YOU!")
                    {
                        //_voiceModel.Speak("Next");
                    }

                    _displayText = "------";
                    NotifyOfPropertyChange(nameof(DisplayTitle));

                    await Task.Run(() =>
                    {
                        Thread.Sleep(1000);
                    });


                    //string speechText = PronounceText(nextAttendee.Name);
                    //_voiceModel.Speak(speechText);

                    DisplayTitle = nextAttendee.Name.ToUpper();

                    await ClockView.Start();

                    NotifyOfPropertyChange(nameof(DisplayTitle));
                }

                if (eArg is ResetTimerEventArgs reset)
                {
                    if (reset.IsResetTimer)
                    {
                        DisplayTitle = "THANK YOU!";
                        await ClockView.Stop();

                        NotifyOfPropertyChange(nameof(DisplayTitle));

                        // if (_controllerView.TextBlockQuote != null)
                        // {
                        //     voiceModel.Speak("Thanks, That's all folks, let's do a trivia question");
                        //     await Task.Run(() => { Thread.Sleep(5000); });
                        //
                        //     _controllerView.PlayWaitMusic();
                        //     ShowQuotes(_controllerView.TextBlockQuote);
                        // }
                    }
                }

                if (eArg is DisplayQuotesEventArgs quotes)
                {
                    ShowQuotes(quotes.Text);
                }

                if (eArg is DisplayEmojiEventArgs displayEmojiEvent)
                {
                    ShowEmoji(displayEmojiEvent.EmojiIndex);
                }

                if (eArg is ChangeBackColorEventArgs changeColorEvent)
                {
                    BackBrush = new SolidColorBrush(changeColorEvent.BackColor);
                }
            };

            SetGreeting();
        }
Пример #23
0
 public void LogAddVoice(VoiceModel voice)
 {
     LogHistory.Add(new Log($"{voice.Name} has been added to the game"));
 }
Пример #24
0
 public void LogRemoveVoice(VoiceModel voice)
 {
     LogHistory.Add(new Log($"{voice.Name} has been removed from the game"));
 }
 public void LogAddVoice(VoiceModel voice)
 {
 }