gpt4 book ai didi

c# - 如何修复微软认知语音错误 "Failed to initialize platform (azure-c-shared)"?

转载 作者:行者123 更新时间:2023-12-02 05:58:34 25 4
gpt4 key购买 nike

我在 Unity 中使用 Microsoft.CognitiveServices.Speech ( https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech )。

在具有 Windows 目标的编辑器中,一切正常,但我在 Linux 专用服务器构建(在 Ubuntu 22.04 LTS 上运行)中遇到错误。

错误:

ApplicationException: Runtime error: Failed to initialize platform (azure-c-shared). Error: 2153
at Microsoft.CognitiveServices.Speech.Internal.SpxExceptionThrower.ThrowIfFail (System.IntPtr hr) [0x0005d] in <439ae8e654bd4287a1d7ffd07bb64d43>:0
at Microsoft.CognitiveServices.Speech.SpeechSynthesizer.FromConfig (Microsoft.CognitiveServices.Speech.SpeechConfig speechConfig, Microsoft.CognitiveServices.Speech.Audio.AudioConfig audioConfig) [0x00030] in <439ae8e654bd4287a1d7ffd07bb64d43>:0
at Microsoft.CognitiveServices.Speech.SpeechSynthesizer..ctor (Microsoft.CognitiveServices.Speech.SpeechConfig speechConfig, Microsoft.CognitiveServices.Speech.Audio.AudioConfig audioConfig) [0x00000] in <439ae8e654bd4287a1d7ffd07bb64d43>:0
at Evo.TTS.TTSClientMicrosoft.ConvertTextToSpeechAsync (Evo.Gender gender, System.String text) [0x0004c] in <dbdd55022f014a4e90cc144f717d0703>:0
at Evo.TTS.TTSClient.ConvertTextToSpeechAsync (Evo.Gender gender, System.String text) [0x00073] in <dbdd55022f014a4e90cc144f717d0703>:0
at Evo.TTS.VoiceController.TextToAudioData (System.String text) [0x0007c] in <dbdd55022f014a4e90cc144f717d0703>:0
at Evo.TTS.VoiceController.CmdSpeak (System.String text) [0x00078] in <dbdd55022f014a4e90cc144f717d0703>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <7fb66c41b6e641fb91b7fd5e48b4c50d>:0
at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in <46e7a35cb7c643d69d5edabca2b1a316>:0
at UnityEngine.UnitySynchronizationContext.Exec () [0x00056] in <46e7a35cb7c643d69d5edabca2b1a316>:0
at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00014] in <46e7a35cb7c643d69d5edabca2b1a316>:0
public async Task<SpeechSynthesisResult> ConvertTextToSpeechAsync(Gender gender, string text)
{
var speechConfig = SpeechConfig.FromSubscription("REMOVED_THE_KEY", "eastus");
// Note: if only language is set, the default voice of that language is chosen.
speechConfig.SpeechSynthesisLanguage = "en-US"; // For example, "de-DE"
// The voice setting will overwrite the language setting.
// The voice setting will not overwrite the voice element in input SSML.
if (gender == Gender.Female)
{
speechConfig.SpeechSynthesisVoiceName = "en-US-AshleyNeural";
}
else
{
speechConfig.SpeechSynthesisVoiceName = "en-US-DavisNeural";
}

using (var synthesizer = new SpeechSynthesizer(speechConfig, null))
{
var res = await synthesizer.SpeakTextAsync(text);
Debug.Log(res.Reason);
CheckResultForErrors(res);
return res;
}
}

最佳答案

关于c# - 如何修复微软认知语音错误 "Failed to initialize platform (azure-c-shared)"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72751026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com