IBM Text-To-Speech无法在Unity中工作

问题描述

我遵循了一个教程,在Unity 2019.4.9f1中使用文本与IBM Watson Assistant进行语音对话。问题是没有将文本翻译成语音,我做了一些记录以查看它是否从Assistant接收到了结果,但确实没有变成语音。我是刚接触Unity和IBM Watson的人,所以我不明白这是什么问题。我尝试在线查找错误,但找不到任何解决方案。任何帮助将不胜感激。

我的控制台中显示的3个错误是这些

[09/10/2020 20:44:58] [RESTConnector.ProcessRequestQueue()] [错误] URL:https://api.eu-gb.text-to-speech.watson.cloud.ibm.com / v1 / synthesize?voice = zh-CN_KateVoice,错误代码:400,错误:HTTP / 1.1 400错误的请求,响应:{ “ error”:“输入包含不匹配的打开SSML标签”, “代码”:400, “ code_description”:“错误请求” } UnityEngine.Debug:LogError(Object) IBM.Cloud.SDK.Debug.DebugReactor:ProcessLog(LogRecord)(位于Assets / IBMSDKCore / Debug / DebugReactor.cs:60) IBM.Cloud.SDK.LogSystem:ProcessLog(LogRecord)(在Assets / IBMSDKCore / Logging / Logger.cs:207处) IBM.Cloud.SDK.Log:Error(String,String,Object [])(在Assets / IBMSDKCore / Logging / Logger.cs:280处) IBM.Cloud.SDK.Connection.d__33:MoveNext()(位于Assets / IBMSDKCore / Connection / RESTConnector.cs:606) IBM.Cloud.SDK.Utilities.Routine:MoveNext()(位于Assets / IBMSDKCore / Utilities / Runnable.cs:131) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator,IntPtr)

[09/10/2020 20:44:58] [Unity] [CRITICAL] Unity Exception ArgumentNullException:缓冲区不能为null。 参数名称:缓冲区:System.IO.MemoryStream..ctor(System.Byte []缓冲区,System.Boolean可写)(位于:0) (包装带检查的远程调用)System.IO.MemoryStream..ctor(byte [],bool) IBM.Cloud.SDK.Utilities.WaveFile.ParseWAV(System.String clipName,System.Byte []数据)(在Assets / IBMSDKCore / Utilities / WaveFile.cs:115处) TextToSpeech + c__displayClass18_0.b__0(IBM.Cloud.SDK.DetailedResponse`1 [T]响应,IBM.Cloud.SDK.IBMError错误)(位于Assets / Script / TextToSpeech.cs:218) IBM.Watson.TextToSpeech.V1.TextToSpeechService.OnSynthesizeResponse(IBM.Cloud.SDK.Connection.RESTConnector + Request req,IBM.Cloud.SDK.Connection.RESTConnector + Response resp)(位于Assets / Watson / Scripts / Services / TextToSpeech / V1 / TextToSpeechService.cs:357) IBM.Cloud.SDK.Connection.RESTConnector + d__33.MoveNext()(位于Assets / IBMSDKCore / Connection / RESTConnector.cs:646) IBM.Cloud.SDK.Utilities.Runnable + Routine.MoveNext()(在Assets / IBMSDKCore / Utilities / Runnable.cs:131) UnityEngine.SetupCoroutine.InvokeMoveNext(System.Collections.IEnumerator枚举器,system.intPtr returnValueAddress)(在:0) UnityEngine.Debug:LogError(Object) IBM.Cloud.SDK.Debug.DebugReactor:ProcessLog(LogRecord)(位于Assets / IBMSDKCore / Debug / DebugReactor.cs:60) IBM.Cloud.SDK.LogSystem:ProcessLog(LogRecord)(在Assets / IBMSDKCore / Logging / Logger.cs:207处) IBM.Cloud.SDK.Log:Critical(String,String,Object [])(在Assets / IBMSDKCore / Logging / Logger.cs:295处) IBM.Cloud.SDK.LogSystem:UnityLogCallback(String,String,LogType)(位于Assets / IBMSDKCore / Logging / Logger.cs:168) UnityEngine.Application:CallLogCallback(String,String,LogType,Boolean)

ArgumentNullException:缓冲区不能为null。 参数名称:缓冲区 System.IO.MemoryStream..ctor(System.Byte []缓冲区,System.Boolean可写)(位于:0) (包装带检查的远程调用)System.IO.MemoryStream..ctor(byte [],bool) IBM.Cloud.SDK.Utilities.WaveFile.ParseWAV(System.String clipName,System.Byte []数据)(在Assets / IBMSDKCore / Utilities / WaveFile.cs:115处) TextToSpeech + c__displayClass18_0.b__0(IBM.Cloud.SDK.DetailedResponse`1 [T]响应,IBM.Cloud.SDK.IBMError错误)(位于Assets / Script / TextToSpeech.cs:218) IBM.Watson.TextToSpeech.V1.TextToSpeechService.OnSynthesizeResponse(IBM.Cloud.SDK.Connection.RESTConnector + Request req,IBM.Cloud.SDK.Connection.RESTConnector + Response响应)(位于Assets / Watson / Scripts / Services / TextToSpeech / V1 / TextToSpeechService.cs:357) IBM.Cloud.SDK.Connection.RESTConnector + d__33.MoveNext()(位于Assets / IBMSDKCore / Connection / RESTConnector.cs:646) IBM.Cloud.SDK.Utilities.Runnable + Routine.MoveNext()(在Assets / IBMSDKCore / Utilities / Runnable.cs:131) UnityEngine.SetupCoroutine.InvokeMoveNext(System.Collections.IEnumerator枚举器,system.intPtr returnValueAddress)(为:0)

解决方法

如果您有固定/不变的线路,则希望将其转换为语音,最好的办法是将其转换为音频文件,然后将其导入为一个整体。 您还可以做的就是自己做演讲并导入。

这也很有帮助,因为这样您就可以在与其他对象/点发生碰撞时触发音频。例如在教程级别。

另一种解决方案是检查您的控制台,我看到3个错误,其余的看起来就像是警告,如果您修复错误,警告将消失。

第一个看起来您对服务器的请求错误,请尝试另一个sml标签并检查它是否有效。 第二个和第三个是缓冲区,应在代码中配置。因此,如果您修复所有问题,就可以解决!