gpt4 book ai didi

javascript - 未捕获无法加载内存初始化程序 Mp3LameEncoder.min.js.mem

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:24:04 24 4
gpt4 key购买 nike

我一直在做一个项目,我需要从 MIC 录制语音并将其上传到 Web 服务器。我想要 .mp3 格式的文件。为此经历了this tutorial .

使用 demo 时效果很好但是当我使用相同的编码并提供所有文件时,它会在本地主机和网络上显示错误。

未捕获无法加载内存初始化程序 Mp3LameEncoder.min.js.mem

我完全按照他们的要求修改了demo中的代码页面,但它不起作用。

我正在使用 ASP.NET C# 并使用 Chrome 作为我的用户代理。

我的文件结构是:

enter image description here

示例代码如下:

<script>
(function () {
var audioContext, gumStream, recorder, input, encodingType, encodeAfterRecord = true, startRecording, stopRecording;

URL = window.URL || window.webkitURL;

var AudioContext = window.AudioContext || window.webkitAudioContext;

//window.AudioContext = window.AudioContext || window.webkitAudioContext;

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;


startRecording = function () {
var constraints = { audio: true, video: false };
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
audioContext = new AudioContext();
gumStream = stream;
input = audioContext.createMediaStreamSource(stream);
//input.connect(audioContext.destination);
encodingType = 'mp3';
recorder = new WebAudioRecorder(input, {
workerDir: '/vendors/_war/',
encoding: encodingType,
numChannels:2
});

recorder.onComplete = function (recorder, blob) {
createDownloadLink(blob, recorder.encoding);
alert('recording done');
}

recorder.setOptions({
timeLimit: 120,
encodeAfterRecord: encodeAfterRecord,
ogg:{ quality: 0.5},
mp3: { bitRate: 160 }
});

recorder.startRecording();
}).catch(function (err) {
alert('Exception: ' + err);
});
};

stopRecording = function () {
gumStream.getAudioTracks()[0].stop();
recorder.finishRecording();
};

$('#recordButton').on('click', function () {
startRecording();
});
$('#stopButton').on('click', function () {
stopRecording(true);
});
}).call(this);
function createDownloadLink(blob, encoding) {

var url = URL.createObjectURL(blob);
var au = $('#au'); //document.createElement('audio');
//var li = document.createElement('li');
//var link = document.createElement('a');

//add controls to the &amp;amp;lt;audio&amp;amp;gt; element
au.controls = true;
au.src = url;

//link the a element to the blob
//link.href = url;
//link.download = new Date().toISOString() + '.' + encoding;
//link.innerHTML = link.download;

//add the new audio and a elements to the li element
//li.appendChild(au);
//li.appendChild(link);

//add the li element to the ordered list
//var recordingsList = $('#recordingsList');
//recordingsList.appendChild(li);
}
</script>

最佳答案

在我的例子中,我需要为 .mem 文件扩展名添加 MIME 类型,我想为 Web 配置提供服务:

<system.webServer>
<staticContent>
<mimeMap fileExtension=".mem" mimeType="text/html" />
</staticContent>
</system.webServer>

关于javascript - 未捕获无法加载内存初始化程序 Mp3LameEncoder.min.js.mem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53757608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com