com.microsoft.cognitiveservices.speech.SpeechSynthesizer 失败并显示“USP 错误:等待第一个音频块超时”
因此,我正在尝试使用官方docs
= script%2cBrowserjs%2cwindowsInstall& pivots = programming- language
class TextToSpeech(val context: Context) {
private val speechConfig: SpeechConfig = SpeechConfig.fromSubscription(SPEECH_SUBSCRIPTION_KEY, "southeastasia")
private var speechSynthesizer: SpeechSynthesizer
init {
speechConfig.speechSynthesisLanguage = "fa-IR"
speechConfig.speechSynthesisVoiceName = "fa-IR-DilaraNeural"
speechConfig.enableAudioLogging()
val audioConfig = AudioConfig.fromDefaultSpeakerOutput()
speechSynthesizer = SpeechSynthesizer(speechConfig, audioConfig)
}
fun speak(pText: String) {
speechSynthesizer.SynthesisStarted.addEventListener { _, _ ->
Log.d(TAG, "speak: SynthesisStarted")
}
speechSynthesizer.SynthesisCompleted.addEventListener { _, _ ->
Log.d(TAG, "speak: SynthesisCompleted")
}
speechSynthesizer.SynthesisCanceled.addEventListener { any: Any, speechSynthesisEventArgs: SpeechSynthesisEventArgs ->
val details = SpeechSynthesisCancellationDetails.fromResult(speechSynthesisEventArgs.result)
Log.d(TAG, "speak: SynthesisCanceled")
}
speechSynthesizer.Synthesizing.addEventListener { _, _ ->
Log.d(TAG, "speak: Synthesizing")
}
speechSynthesizer.SpeakText(text)
}
}
> “综合启动”将触发,然后几秒钟后,“综合验证”触发了以下结果
comcellationReason:错误 错误代码:ServicEtimeOut errordetails:USP错误:超时等待第一个音频块
so im trying to implement microsoft tts on android using Official Docs
my code looks like :
class TextToSpeech(val context: Context) {
private val speechConfig: SpeechConfig = SpeechConfig.fromSubscription(SPEECH_SUBSCRIPTION_KEY, "southeastasia")
private var speechSynthesizer: SpeechSynthesizer
init {
speechConfig.speechSynthesisLanguage = "fa-IR"
speechConfig.speechSynthesisVoiceName = "fa-IR-DilaraNeural"
speechConfig.enableAudioLogging()
val audioConfig = AudioConfig.fromDefaultSpeakerOutput()
speechSynthesizer = SpeechSynthesizer(speechConfig, audioConfig)
}
fun speak(pText: String) {
speechSynthesizer.SynthesisStarted.addEventListener { _, _ ->
Log.d(TAG, "speak: SynthesisStarted")
}
speechSynthesizer.SynthesisCompleted.addEventListener { _, _ ->
Log.d(TAG, "speak: SynthesisCompleted")
}
speechSynthesizer.SynthesisCanceled.addEventListener { any: Any, speechSynthesisEventArgs: SpeechSynthesisEventArgs ->
val details = SpeechSynthesisCancellationDetails.fromResult(speechSynthesisEventArgs.result)
Log.d(TAG, "speak: SynthesisCanceled")
}
speechSynthesizer.Synthesizing.addEventListener { _, _ ->
Log.d(TAG, "speak: Synthesizing")
}
speechSynthesizer.SpeakText(text)
}
}
The Problem is when i call speak method the "SynthesisStarted" will trigger and then after a few seconds the "SynthesisCanceled" going triggered with following result
CancellationReason:Error
ErrorCode: ServiceTimeout
ErrorDetails:USP error: timeout waiting for the first audio chunk
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存在网络套接字连接问题。首先需要检查即使没有识别输入,您想让连接保持多长时间。
对于访问令牌,应将访问令牌作为 Authorization: Bearer 标头发送到服务。每个访问令牌的有效期为 10 分钟。您可以随时获取新令牌,但是,为了最大限度地减少网络流量和延迟,我们建议在九分钟内使用相同的令牌。
以下是短音频场景的示例。
There is a web socket connection problem. First need to check with how long you want to make the connection alive even there is no recognition of input.
For access token, the access token should be sent to the service as the Authorization: Bearer header. Each access token is valid for 10 minutes. You can get a new token at any time, however, to minimize network traffic and latency, we recommend using the same token for nine minutes.
The below is the example of short audio scenario.