我发现了Azure认知语音TTS服务的一个问题;Azure认知语音TTS API在Windows 8、/8.1/Server 2012/Server2012R2上自2022-01以来不起作用。
我用微软认知服务语音SDK编写了一个程序,它在Windows 8/8.1/Server 2012/Server2012R2和Windows 10/Server 2019上运行良好。
我证实,至少在2021-11-30年之前,有一些日志是正确工作的。然而,它今天不起作用。
所以,我用Microsoft.CognitiveServices.Speech.csharp nuget包做了一个简单的示例。
我的示例代码如下;
public static async Task SynthesisToAudioFileAsync(string text, string outputFileName)
{
var config = SpeechConfig.FromSubscription("xxxxx", "westus2");
config.SpeechSynthesisLanguage = "ko-KR";
config.SetSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3);
config.SpeechSynthesisVoiceName = "ko-KR-SunHiNeural";
using (var fileOutput = AudioConfig.FromWavFileOutput(outputFileName))
{
using (var synthesizer = new SpeechSynthesizer(config, fileOutput))
{
var result = await synthesizer.SpeakTextAsync(text);
if (result.Reason == ResultReason.SynthesizingAudioCompleted)
{
Console.WriteLine($"Speech synthesized to [{outputFileName}]");
}
else if (result.Reason == ResultReason.Canceled)
{
var cancellation = SpeechSynthesisCancellationDetails.FromResult(result);
Console.WriteLine($"CANCELED: Reason={cancellation.Reason}");
if (cancellation.Reason == CancellationReason.Error)
{
Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
Console.WriteLine($"CANCELED: ErrorDetails=[{cancellation.ErrorDetails}]");
Console.WriteLine($"CANCELED: Did you update the subscription info?");
}
}
else
{
Console.Write(result.Reason.ToString());
}
}
}
}它在Windows 10/Server2019 2019上运行良好,没有错误。但是,它不适用于Windows 8、/8.1/Server 2012/Server2012R2。当然,我完全执行了windows更新。
错误消息如下;
CANCELED: Reason=Error
CANCELED: ErrorCode=ConnectionFailure
CANCELED: ErrorDetails=[Connection failed (no connection to the remote host). In
ternal error: 11. Error details: Code: 0. USP state: 2. Received audio size: 0 b
ytes.]
CANCELED: Did you update the subscription info?我怀疑这可能是TLS 1.2的问题,并尝试了如下;
根据许多谷歌搜索结果,https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/security/enable-tls-1-2-client
还有其他很多帖子。
但是,这是行不通的。
它不使用Azure,而是在低级别上实现https rest。这样我就可以检查和修改密码了。
它也在Windows 10上工作,但在Windows 81./Server2012 2012上不起作用,因为有以下错误信息;
Starting TTSSample request code execution.
Unhandled Exception: System.AggregateException: One or more errors occurred. --->
System.Net.Http.HttpRequestException: An error occurred while sending the request. --->
System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)我确认令牌API (https://westus2.api.cognitive.microsoft.com/sts/v1.0/issueToken)调用得很好,但是没有使用错误消息调用that (https://westus2.tts.speech.microsoft.com/cognitiveservices/v1)。
根据错误信息,似乎是TLS 1.2的问题。
所以,我加入了下面的一行;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;该错误消息在Windows 10和Windows8.1/Server2012 2012上更改如下
Starting Authtentication
Unhandled Exception: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. --->
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host --->
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)这是预期的行为,因为我强制TLS 1.1。然而,该错误发生在认证步骤中,与上述结果相反--上述测试通过了身份验证。
因此,TLS 1.2可能在我的Windows81.server 2012上启用,因为根据上面的测试结果,令牌Uri可能需要TLS 1.2。
我厌倦了语音识别的C#样本在认知服务-语音sdk-硕士。
https://github.com/Azure-Samples/cognitive-services-speech-sdk
Windows 81.Server 2012和Windows 10运行良好。
doc女士说Azure认知服务需要TLS 1.2。
如果我的Windows8.1/ Service 2012中没有TLS 1.2,则所有Azure认知服务API都必须失败。但是,只有TTS API失败。此外,它至少在2021-11年才开始运作。
我几乎尽我所能,但都失败了。
最后,我怀疑在2021年年底Azure认知TTS系统可能会发生一些变化,这可能会导致与Windows 8/8.1/Server2012 2012/Server2012R2的TLS连接相关的问题。
事实上,这个问题是在我客户的机器上报告的,由于许多原因,将Windows OS升级到Windows 10/Server2019 2019并不是一种选择。因此,我必须在Windows 8/8.1/Server2012 2012/Server2012R2上找到解决办法。
你能告诉我如何解决这个问题吗?
诚挚的问候。
附注:
我使用C#捕获了认知-语音-TTS样本的网络数据包,并确认使用了TLS1.2。
第一次握手检索令牌(westus2.api.cognitive.microsoft.com- 20.51.8.244)成功,但第二次握手到Azure认知TTS服务(westus2.tts.speech.microsoft.com- 20.51.12.193)失败与以下消息;
TLSv1.2 Record Layer: Handshake Protocol: Client Hello
TLSv1.2 Record Layer: Alert (Level: Fatal, Description: Handshake Failure). 我在Windows 10上进行了测试,使用相同的测试控制台程序,所有TLS 1.2握手都成功了。
我添加了以下代码来忽略证书验证,但它没有工作;
ServicePointManager.ServerCertificateValidationCallback += (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) =>
{
return true;
};发布于 2022-01-22 00:59:38
我找到了真正的理由。这是Azure TTS服务API服务器的TLS密码套件问题。
我对westus2.tts.speech.microsoft.com执行sslscan,结果如下;
westus2.tts.speech.microsoft.com
Preferred TLSv1.2 128 bits ECDHE-RSA-AES128-GCM-SHA256 Curve 25519 DHE 253
Accepted TLSv1.2 256 bits ECDHE-RSA-AES256-GCM-SHA384 Curve 25519 DHE 253
Accepted TLSv1.2 256 bits ECDHE-RSA-CHACHA20-POLY1305 Curve 25519 DHE 253 我比较了Windows8.1和Windows10的WireShark包捕获结果。
Windows 10的结果有ECDHE-RSA- does 128-GCM- The 256和ECDHE-RSA-美学256-GCM- the 384,但Windows 8.1的结果并非如此。
因此,Azure TTS API不能在Windows8 8/8.1/Server2012 2012/Server2012R2上工作,必须由MS.修复。
https://stackoverflow.com/questions/70800703
复制相似问题