Created
June 4, 2024 02:10
-
-
Save xximjasonxx/db7778aa2a2e7e394c6055374b5ccaf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Function("SendSpeechTestFunction")] | |
public async Task<HttpResponseData> SendSpeech([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "send/text")] HttpRequestData request) | |
{ | |
var model = await request.ReadFromJsonAsync<SendSpeedRequestModel>(); | |
var callAutomationClient = new CallAutomationClient(_configuration["AcsConnectionString"]); | |
var callConnection = callAutomationClient.GetCallConnection(model.CallConnectionId); | |
var callMedia = callConnection.GetCallMedia(); | |
var playSource = new TextSource(model.Text) | |
{ | |
SourceLocale = "en-US", | |
CustomVoiceEndpointId = _configuration["CustomVoiceEndpointId"], | |
VoiceName = _configuration["NeuralVoiceName"] | |
}; | |
await callMedia.PlayToAllAsync(playSource); | |
return request.CreateResponse(HttpStatusCode.Accepted); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment