/// <summary> /// Is the command only a simple or dynamic string? /// </summary> /// <param name="command">the command to evaluate</param> /// <returns>true if it is a string command only</returns> public static bool IsStringOnlyCommand(TalkCommand command) { if (command == TalkCommand.PlainString || command == TalkCommand.AvatarsName || command == TalkCommand.NewLine || command == TalkCommand.Rune) { return(true); } return(false); }
/// <summary> /// Add to the current script line /// For example: STRING <NEWLINE><AVATARNAME> /// </summary> /// <param name="talkCommand"></param> /// <param name="talkStr"></param> public void AddTalkCommand(TalkCommand talkCommand, string talkStr) { if (talkCommand == TalkCommand.PlainString) { _currentScriptLine.AddScriptItem(new ScriptItem(talkCommand, talkStr)); } else { _currentScriptLine.AddScriptItem(new ScriptItem(talkCommand)); } }
/// <summary> /// Determines if a particular talk command is present in a script line /// <remarks>This particularly helpful when looking for looking for <AvatarName></remarks> /// </summary> /// <param name="command">the command to search for</param> /// <returns>true if it's present, false if it isn't</returns> public bool ContainsCommand(TalkCommand command) { for (int nItem = 0; nItem < ScriptItems.Count; nItem++) { if (ScriptItems[nItem].Command == command) { return(true); } } return(false); }
public void TestStartTalk(bool passCreds, bool kitchenSink) { var uuid = "63f61863-4a51-4f6b-86e1-46edebcf9356"; var expectedUri = $"{ApiUrl}/v1/calls/{uuid}/talk"; var expectedResponse = @"{ ""message"": ""Talk started"", ""uuid"": ""63f61863-4a51-4f6b-86e1-46edebcf9356"" }"; string expectedRequestContent; TalkCommand command; if (kitchenSink) { expectedRequestContent = @"{""text"":""Hello. How are you today?"",""voice_name"":""salli"",""loop"":0,""level"":""0.4"",""language"":""en-US"",""style"":1}"; command = new TalkCommand { Text = "Hello. How are you today?", Loop = 0, Level = "0.4", VoiceName = "salli", Language = "en-US", Style = 1 }; } else { expectedRequestContent = @"{""text"":""Hello. How are you today?""}"; command = new TalkCommand { Text = "Hello. How are you today?" }; } Setup(expectedUri, expectedResponse, expectedRequestContent); var creds = Request.Credentials.FromAppIdAndPrivateKey(AppId, PrivateKey); var client = new VonageClient(creds); CallCommandResponse response; if (passCreds) { response = client.VoiceClient.StartTalk(uuid, command, creds); } else { response = client.VoiceClient.StartTalk(uuid, command); } Assert.Equal("Talk started", response.Message); Assert.Equal(uuid, response.Uuid); }
/// <summary> /// Add a talk label. /// </summary> /// <param name="talkCommand">Either GotoLabel or DefineLabel</param> /// <param name="nLabel">label # (0-9)</param> public void AddTalkLabel(TalkCommand talkCommand, int nLabel) { if (nLabel < 0 || nLabel > TOTAL_LABELS) { throw new Ultima5ReduxException("Label Number: " + nLabel.ToString() + " is out of range"); } if (talkCommand == TalkCommand.GotoLabel || talkCommand == TalkCommand.DefineLabel) { _currentScriptLine.AddScriptItem(new ScriptItem(talkCommand, nLabel)); //System.Console.Write("<" + (talkCommand.ToString() + " " + nLabel + ">")); } else { throw new Ultima5ReduxException("You passed a talk command that isn't a label! "); } }
public void Execute() { var VONAGE_APPLICATION_ID = Environment.GetEnvironmentVariable("VONAGE_APPLICATION_ID") ?? "VONAGE_APPLICATION_ID"; var VONAGE_PRIVATE_KEY_PATH = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; var UUID = Environment.GetEnvironmentVariable("UUID") ?? "UUID"; var TEXT = Environment.GetEnvironmentVariable("TEXT") ?? "TEXT"; var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH); var client = new VonageClient(credentials); var command = new TalkCommand() { Text = TEXT }; var response = client.VoiceClient.StartTalk(UUID, command); Console.WriteLine($"Play Text-To-Speech complete message: {response.Message}"); }
/// <summary> /// PUT /v1/calls/{uuid}/talk - send a synthesized speech message to an active Call /// </summary> /// <param name="id">id of call</param> /// <param name="cmd">Command to execute against call</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> public static CallCommandResponse BeginTalk(string id, TalkCommand cmd, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("PUT", ApiRequests.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}/talk"), cmd, creds); return(JsonConvert.DeserializeObject <CallCommandResponse>(response.JsonResponse)); }
//交谈 protected virtual CommandReplyType CheckTalk(TalkCommand cmd) { ChangeState <ActorTalkFsm>(cmd); return(CommandReplyType.YES); }
/// <summary> /// PUT /v1/calls/{uuid}/talk - send a synthesized speech message to an active Call /// </summary> /// <param name="id">id of call</param> /// <param name="cmd">Command to execute against call</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> public CallCommandResponse BeginTalk(string id, TalkCommand cmd, Credentials creds = null) { return(BeginTalk(id, cmd, creds ?? Credentials)); }
/// <summary> /// A talk command with an associated string /// </summary> /// <param name="command"></param> /// <param name="str"></param> public ScriptItem(TalkCommand command, string str) { Command = command; this._str = str; }
/// <summary> /// Creates a label /// </summary> /// <param name="command">a GotoLabel or DefineLabel</param> /// <param name="nLabelNum">number of the label</param> public ScriptItem(TalkCommand command, int nLabelNum) { Command = command; LabelNum = nLabelNum; }
/// <summary> /// Simple constructor for basic commands /// </summary> /// <param name="command"></param> public ScriptItem(TalkCommand command) : this(command, string.Empty) { }
/// <summary> /// Add to the current script line, but no string associated /// For example: STRING <NEWLINE><AVATARNAME> /// </summary> /// <param name="talkCommand"></param> public void AddTalkCommand(TalkCommand talkCommand) { //System.Console.Write("<" + (talkCommand.ToString() + ">")); _currentScriptLine.AddScriptItem(new ScriptItem(talkCommand, string.Empty)); }