Google TTS 标签无法正常工作

问题描述 投票:0回答:1

我正在研究Google TTS,发现以下带有par标签的示例:

https://cloud.google.com/text-to-speech/docs/ssml#par

在示例中,音频正确构建。背景中有两个句子和一些声音。但是,如果您实际上将其与他们的API或控制台一起使用,则无法使用。您只会收到两个句子,并且不会播放音频。链接到TTS控制台:

https://cloud.google.com/text-to-speech

这是我正在使用的SSML:

<par>
    <media xml:id="question" begin="0.5s">
      <speak>Who invented the Internet?</speak>
    </media>
    <media xml:id="answer" begin="question.end+2.0s">
      <speak>The Internet was invented by cats.</speak>
    </media>
    <media begin="answer.end-0.2s" soundLevel="-6dB">
      <audio
        src="https://actions.google.com/sounds/v1/cartoon/cartoon_boing.ogg"/>
    </media>
    <media repeatCount="3" soundLevel="+2.28dB"
      fadeInDur="2s" fadeOutDur="0.2s">
      <audio
        src="https://actions.google.com/sounds/v1/animals/cat_purr_close.ogg"/>
    </media>
  </par>

我做错了什么?还是TTS服务本身有问题?

actions-on-google google-text-to-speech
1个回答
1
投票

对于初学者来说,TTS控制台肯定有些奇怪。如果查看它说应该使用的JSON,您会注意到它已经省略了<par>标签。检查网络流量显示了同样的事情。我还注意到<speech>标签需要省略。

如果您在Action Simulator控制台中尝试此操作,则输出将正常工作。您可以转到https://console.actions.google.com/,选择要使用的项目,然后转到“测试”选项卡,以进入动作模拟器。然后,在模拟器本身中,选择“音频”选项卡,然后可以在编辑器中输入SSML(包括<speech>标签),然后按“更新和收听”按钮。

illustration of simulator highlighting steps to take

© www.soinside.com 2019 - 2024. All rights reserved.