音频无法在React中播放

时间:2019-08-21 08:39:42

标签: javascript reactjs

在我的应用中,我通过JSON引用了我的音频文件。从下面的代码中可以看到。

$("#sortable").sortable({
      update: function(event, ui) {
         var updatedPositions = "";
         $("#sortable li").each(function(idx, li){
         updatedPositions += $(li).html() + " New position: " + idx + '\n';
      })
      alert(updatedPositions)
    }
})  

音频文件保存在公用文件夹中。

enter image description here

问题是当我转到应用程序中的特定项目时,我的音频不起作用。从下图可以看到,播放按钮被禁用。请问你能帮帮我吗。我尝试了一些解决方案,但是它们不起作用。

enter image description here

BubbleSpeechFrame.js

const lines = [
  {
    id: 'dialogue1',
    parts: [
      {
        text: `как дела?`,
        audio: 'audio/audio1.mp3',
        prompt: '',
        speaker: 1,
        id: 1
      },
      {
        text: 'у меня все хорошо, а как ты?',
        audio: 'audio/аудио2.mp3',
        prompt: 'Say that: I am OK, how about you?',
        speaker: 2,
        id: 2,
        helpers: [
          {
            word_mother: "I'm all right",
            word_target: 'У меня все хорошо'
          },
          {
            word_mother: 'And you?',
            word_target: 'А как ты?'
          }
        ]
      }
}]

1 个答案:

答案 0 :(得分:1)

我终于解决了我的问题。在result = raw / counter 数组的tensor([[[[1., 2., 4., 6., 7.], [1., 2., 4., 6., 7.]]]]) 字段中,有必要提供音频的路径。例如,audio。所有音频文件都存储在音频文件夹中,该文件夹存储在公用文件夹中。