我可以使用以下代码从我的DialogFlow实现内联编辑器webhook中播放声音。
function saySSML (request, response) {
  const app = new DialogflowApp({request: request, response: response});
  const textToSpeech = '<speak>'
    + 'I can play a sound'
    + '<audio src="https://actions.google.com/sounds/v1/animals/animal_bark_and_growl.ogg">a digital watch alarm</audio>'
    + '</speak>';
  app.ask(textToSpeech);
}但是,我不知道如何在Firebase存储中播放音频文件。我已经尝试将音频url替换为文件的存储位置,也尝试将DownloadUrl1 url替换为单击Firebase存储中的文件时显示的url。
我还考虑了按照https://firebase.google.com/docs/storage/web/create-reference创建存储引用,但当我添加对存储服务的引用时,我收到了“firebase未定义”错误。
function saySSML (request, response) {
  const app = new DialogflowApp({request: request, response: response});
  // Get a reference to the storage service, which is used to create references in your storage bucket
  var storage = firebase.storage();
  // Create a storage reference from our storage service
  var storageRef = storage.ref();
  const textToSpeech = '<speak>'
    + 'I can play a sound'
    + '<audio src="https://firebasestorage.googleapis.com/v0/b/andrewdittmer-c301f.appspot.com/o/alarm_clock.ogg?alt=media&token=d66a4055-5365-4061-b50d-0b6a126841f3">a digital watch alarm</audio>'
    + '</speak>';
  app.ask(textToSpeech);
}有没有人能够成功地做到这一点?
感谢您的帮助/建议。
发布于 2018-02-02 07:24:41
Google Assistant的SSML解析器非常严格。需要对URL中的&进行转义,因此结果应该为&。Line可能看起来像这样:
    + '<audio src="https://firebasestorage.googleapis.com/v0/b/andrewdittmer-c301f.appspot.com/o/alarm_clock.ogg?alt=media&token=d66a4055-5365-4061-b50d-0b6a126841f3">a digital watch alarm</audio>'或者,如果您已经在使用Firebase,并且您的音频资源是静态的,那么您可能希望将音频存储在Firebase Hosting中。
https://stackoverflow.com/questions/48572676
复制相似问题