Skip to content

Commit 3518a7c

Browse files
authored
Merge pull request #373 from Resgrid/develop
RE1-T115 Outbound TTS work
2 parents 034e26f + feb3018 commit 3518a7c

3 files changed

Lines changed: 563 additions & 558 deletions

File tree

Providers/Resgrid.Providers.Number/OutboundVoiceProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public async Task<bool> CommunicateCallAsync(string phoneNumber, UserProfile pro
3737
var options = new CreateCallOptions(new PhoneNumber(profile.GetPhoneNumber()), new PhoneNumber(number));
3838
options.Url = new Uri(string.Format(Config.NumberProviderConfig.TwilioVoiceCallApiUrl, profile.UserId, call.CallId));
3939
options.Method = "GET";
40+
options.MachineDetection = "Enable";
4041
//options.IfMachine = "Continue";
4142

4243
var phoneCall = await CallResource.CreateAsync(options);
@@ -51,6 +52,7 @@ public async Task<bool> CommunicateCallAsync(string phoneNumber, UserProfile pro
5152
var options = new CreateCallOptions(new PhoneNumber(profile.GetHomePhoneNumber()), new PhoneNumber(number));
5253
options.Url = new Uri(string.Format(Config.NumberProviderConfig.TwilioVoiceCallApiUrl, profile.UserId, call.CallId));
5354
options.Method = "GET";
55+
options.MachineDetection = "Enable";
5456
//options.IfMachine = "Continue";
5557

5658
var phoneCall = await CallResource.CreateAsync(options);

Web/Resgrid.Web.Services/Controllers/TwilioController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,17 @@ public async Task<ActionResult> VoiceCall(string userId, int callId, [FromQuery]
492492
return CreateVoiceContentResult(response);
493493
}
494494

495+
// For outbound calls, allow a brief pause for the audio bridge to
496+
// stabilize after the callee answers before attempting playback.
497+
response.Pause(length: 1);
498+
495499
// For dispatch playback, attempt to fetch (or pre-warm) the TTS URL
496500
// within a short timeout so that the TwiML response is returned before
497501
// Twilio's 15-second webhook timeout expires. If the dispatch text is
498502
// not yet cached, we play a brief "please wait" prompt and redirect
499503
// back to this endpoint, giving the TTS service time to complete
500504
// generation in the background.
501505
var dispatchReady = await TryAppendDispatchPlaybackAsync(response, call);
502-
503506
if (!dispatchReady)
504507
{
505508
// Parse and increment the retry counter from the incoming request.

0 commit comments

Comments
 (0)