optimize input audio transcription

This commit is contained in:
nick.yi 2025-03-12 22:57:12 +08:00
parent b9e9d5865f
commit 025b0a1d5c
2 changed files with 9 additions and 2 deletions

View file

@ -72,4 +72,10 @@ public class InputAudioTranscription
{
[JsonPropertyName("model")]
public string Model { get; set; } = null!;
[JsonPropertyName("language")]
public string Language { get; set; } = "en";
[JsonPropertyName("prompt")]
public string Prompt { get; set; }
}

View file

@ -138,7 +138,7 @@ public class RealTimeCompletionProvider : IRealTimeCompletion
{
result = await _webSocket.ReceiveAsync(
new ArraySegment<byte>(buffer), CancellationToken.None);
// Convert received data to text/audio (Twilio sends Base64-encoded audio)
string receivedText = Encoding.UTF8.GetString(buffer, 0, result.Count);
if (string.IsNullOrEmpty(receivedText))
@ -319,6 +319,7 @@ public class RealTimeCompletionProvider : IRealTimeCompletion
InputAudioTranscription = new InputAudioTranscription
{
Model = "whisper-1",
Language = "en",
},
Voice = "alloy",
Instructions = instruction,
@ -329,7 +330,7 @@ public class RealTimeCompletionProvider : IRealTimeCompletion
MaxResponseOutputTokens = 512,
TurnDetection = new RealtimeSessionTurnDetection
{
Threshold = 0.8f,
Threshold = 0.9f,
PrefixPadding = 300,
SilenceDuration = 800
}