Skip to content

Commit 77f0827

Browse files
committed
feat: add new provider and options on Voice Talk action
1 parent 3625015 commit 77f0827

File tree

3 files changed

+136
-16
lines changed

3 files changed

+136
-16
lines changed

Vonage.Test/Voice/Data/TestTalk-request.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
"loop": "2",
77
"level": "0",
88
"language": "en-US",
9-
"style": 0
9+
"style": 0,
10+
"provider": "ElevenLabs",
11+
"providerOptions": {
12+
"voice_id": "NFG5qt843uXKj4pFvR7C",
13+
"model_id": "eleven_multilingual_v2",
14+
"voice_settings": {
15+
"stability": 1.5,
16+
"use_speaker_boost": true,
17+
"similarity_boost": 2.4,
18+
"style": 1.4,
19+
"speed": 2.5
20+
}
21+
}
1022
}
1123
]

Vonage.Test/Voice/NccoTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ public void TestTalk() =>
207207
Level = "0",
208208
Language = "en-US",
209209
Style = 0,
210+
Provider = TalkAction.TalkProvider.ElevenLabs,
211+
ProviderOptions = new TalkProviderOptions
212+
{
213+
VoiceId = "NFG5qt843uXKj4pFvR7C",
214+
ModelId = "eleven_multilingual_v2",
215+
Settings = new TalkProviderSettings
216+
{
217+
Speed = (decimal) 2.5,
218+
SimilarityBoost = (decimal) 2.4,
219+
UseSpeakerBoost = true,
220+
Stability = (decimal) 1.5,
221+
Style = (decimal) 1.4,
222+
},
223+
},
210224
});
211225

212226
[Fact]

Vonage/Voice/Nccos/TalkAction.cs

Lines changed: 109 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
1-
using Newtonsoft.Json;
1+
#region
2+
using System.Runtime.Serialization;
3+
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Converters;
5+
#endregion
26

37
namespace Vonage.Voice.Nccos;
48

59
public class TalkAction : NccoAction
610
{
11+
/// <summary>
12+
/// </summary>
13+
public enum TalkProvider
14+
{
15+
/// <summary>
16+
/// </summary>
17+
[EnumMember(Value = "ElevenLabs")] ElevenLabs,
18+
19+
/// <summary>
20+
/// </summary>
21+
[EnumMember(Value = "Google")] Google,
22+
23+
/// <summary>
24+
/// </summary>
25+
[EnumMember(Value = "Polly")] Polly,
26+
}
27+
728
[JsonProperty("action", Order = 0)] public override ActionType Action => ActionType.Talk;
829

930
/// <summary>
10-
/// Set to true so this action is terminated when the user presses a button on the keypad.
11-
/// Use this feature to enable users to choose an option without having to listen to the whole message
12-
/// in your Interactive Voice Response (IVR ). If you set bargeIn to true on one more Stream actions then
13-
/// the next non-stream action in the NCCO stack must be an input action. The default value is false.
14-
/// Once bargeIn is set to true it will stay true (even if bargeIn: false is set in a following action)
15-
/// until an input action is encountered
31+
/// Set to true so this action is terminated when the user presses a button on the keypad.
32+
/// Use this feature to enable users to choose an option without having to listen to the whole message
33+
/// in your Interactive Voice Response (IVR ). If you set bargeIn to true on one more Stream actions then
34+
/// the next non-stream action in the NCCO stack must be an input action. The default value is false.
35+
/// Once bargeIn is set to true it will stay true (even if bargeIn: false is set in a following action)
36+
/// until an input action is encountered
1637
/// </summary>
1738
[JsonProperty("bargeIn", Order = 2)]
1839
public bool BargeIn { get; set; }
1940

2041
/// <summary>
21-
/// The language (<see href="https://tools.ietf.org/html/bcp47">BCP-47</see>format) for the message you are sending. Default: en-US. Possible values are listed in the <see href="https://developer.nexmo.com/voice/voice-api/guides/text-to-speech#supported-languages">Text-To-Speech guide</see>.
42+
/// The language (<see href="https://tools.ietf.org/html/bcp47">BCP-47</see>format) for the message you are sending.
43+
/// Default: en-US. Possible values are listed in the
44+
/// <see href="https://developer.nexmo.com/voice/voice-api/guides/text-to-speech#supported-languages">
45+
/// Text-To-Speech
46+
/// guide
47+
/// </see>
48+
/// .
2249
/// </summary>
2350
[JsonProperty("language", Order = 6)]
2451
public string Language { get; set; }
2552

2653
/// <summary>
27-
/// The volume level that the speech is played. This can be any value between -1 to 1 with 0 being the default.
54+
/// The volume level that the speech is played. This can be any value between -1 to 1 with 0 being the default.
2855
/// </summary>
2956
[JsonProperty("level", Order = 4)]
3057
public string Level { get; set; }
3158

3259
/// <summary>
33-
/// The number of times text is repeated before the Call is closed. The default value is 1. Set to 0 to loop infinitely.
60+
/// The number of times text is repeated before the Call is closed. The default value is 1. Set to 0 to loop
61+
/// infinitely.
3462
/// </summary>
3563
[JsonProperty("loop", Order = 3)]
3664
public string Loop { get; set; }
@@ -43,17 +71,83 @@ public class TalkAction : NccoAction
4371
public bool Premium { get; set; }
4472

4573
/// <summary>
46-
/// The vocal style (vocal range, tessitura and timbre). Default: 0. Possible values are listed in the <see href="https://developer.nexmo.com/voice/voice-api/guides/text-to-speech#supported-languages">Text-To-Speech guide</see>.
74+
/// The vocal style (vocal range, tessitura and timbre). Default: 0. Possible values are listed in the
75+
/// <see href="https://developer.nexmo.com/voice/voice-api/guides/text-to-speech#supported-languages">
76+
/// Text-To-Speech
77+
/// guide
78+
/// </see>
79+
/// .
4780
/// </summary>
4881
[JsonProperty("style", Order = 7)]
4982
public int? Style { get; set; }
5083

5184
/// <summary>
52-
/// A string of up to 1,500 characters (excluding SSML tags) containing the message to be
53-
/// synthesized in the Call or Conversation. A single comma in text adds a short pause to the
54-
/// synthesized speech. To add a longer pause a break tag needs to be used in SSML.
55-
/// To use SSML tags, you must enclose the text in a speak element.
85+
/// A string of up to 1,500 characters (excluding SSML tags) containing the message to be
86+
/// synthesized in the Call or Conversation. A single comma in text adds a short pause to the
87+
/// synthesized speech. To add a longer pause a break tag needs to be used in SSML.
88+
/// To use SSML tags, you must enclose the text in a speak element.
5689
/// </summary>
5790
[JsonProperty("text", Order = 1)]
5891
public string Text { get; set; }
92+
93+
/// <summary>
94+
/// </summary>
95+
[JsonProperty("provider", Order = 9)]
96+
[JsonConverter(typeof(StringEnumConverter))]
97+
public TalkProvider? Provider { get; set; }
98+
99+
/// <summary>
100+
/// </summary>
101+
[JsonProperty("providerOptions", Order = 10)]
102+
public TalkProviderOptions? ProviderOptions { get; set; }
103+
}
104+
105+
/// <summary>
106+
/// </summary>
107+
public struct TalkProviderOptions
108+
{
109+
/// <summary>
110+
/// </summary>
111+
[JsonProperty("voice_id", Order = 0)]
112+
public string VoiceId { get; set; }
113+
114+
/// <summary>
115+
/// </summary>
116+
[JsonProperty("model_id", Order = 1)]
117+
public string ModelId { get; set; }
118+
119+
/// <summary>
120+
/// </summary>
121+
[JsonProperty("voice_settings", Order = 1)]
122+
public TalkProviderSettings Settings { get; set; }
123+
}
124+
125+
/// <summary>
126+
/// </summary>
127+
public struct TalkProviderSettings
128+
{
129+
/// <summary>
130+
/// </summary>
131+
[JsonProperty("stability", Order = 0)]
132+
public decimal Stability { get; set; }
133+
134+
/// <summary>
135+
/// </summary>
136+
[JsonProperty("use_speaker_boost", Order = 1)]
137+
public bool UseSpeakerBoost { get; set; }
138+
139+
/// <summary>
140+
/// </summary>
141+
[JsonProperty("similarity_boost", Order = 2)]
142+
public decimal SimilarityBoost { get; set; }
143+
144+
/// <summary>
145+
/// </summary>
146+
[JsonProperty("style", Order = 3)]
147+
public decimal Style { get; set; }
148+
149+
/// <summary>
150+
/// </summary>
151+
[JsonProperty("speed", Order = 4)]
152+
public decimal Speed { get; set; }
59153
}

0 commit comments

Comments
 (0)