我正在创建一个涉及Google Text-To-Speech服务的实时语音应用程序。但是,我的延迟时间在600-1100ms之间,这对我的应用来说太慢了。音频只有3秒左右,我怎么能改进这个? (该延迟是衡量我发送请求然后接收音频所需时间的度量)。
UPDATE
我使用的代码是:
//I call this at the start of my program
TTSclient = TextToSpeechClient.Create();
//This is the method that I call everytime I make a TTS call in my program
public static Google.Protobuf.ByteString MakeTTS(string text)
{
SynthesisInput input = new SynthesisInput
{
Text = text
};
VoiceSelectionParams voice = new VoiceSelectionParams
{
LanguageCode = "en-AU",
Name = "en-AU-Wavenet-A"
};
AudioConfig config = new AudioConfig
{
AudioEncoding = AudioEncoding.Linear16,
SampleRateHertz = 16000,
SpeakingRate = 0.9
};
var TTSresponse = TTSclient.SynthesizeSpeech(new SynthesizeSpeechRequest
{
Input = input,
Voice = voice,
AudioConfig = config
});
return TTSresponse.AudioContent;
}
谢谢
我建议首先通过metrics page of the TTS API中的API方法检查延迟中位数。如果您发现延迟在600到1,100毫秒之间,那么我没有太多事情要做,因为所有请求都是同步完成的,因为这是一个共享资源,这些API的SLA仅涵盖可用性,而不是延迟。
如果你得到的结果更低,那么我只能想到两个可能会降低结果的因素:网络自身的延迟或任何其他正在进行的处理。如果是最新情况,那么您必须尝试为您的请求设置错误的不同设置(例如,我想知道是否指定设备配置文件,因为此功能目前处于测试阶段,可能会导致响应稍慢) 。