我试图使用fs.writeFile编写.wav文件。文件已成功创建,但长度仅为8-13字节,所以显然我做错了什么。
如果blob已经是audio/wav格式的,我是否可以直接写入磁盘,还是需要将其转换为Base 64?
我几乎一无所知,在另一个类似的帖子中找到了没有答案的问题 - 在这里
任何建议都将不胜感激。
routerApp.controller('audiotest', function($scope) {
$scope.saveToDisk = function(){
var nw = require('nw.gui');
var fs = require('fs');
var path = require('path');
fs.writeFileSync('test.wav', $scope.recordedInput)
};
}
console.log($scope.recordedInput)
返回 Blob {size: 294956, type: "audio/wav"}
这并不是很相关,但这是我的HTML代码
<div class="row" ng-controller="audiotest">
<div class="row">
<button type="button" ng-click="saveToDisk()"> Write this sucker to disk </button>
</div>
<ng-audio-recorder id='audioInput' audio-model='recordedInput'>
<!-- Start controls, exposed via recorder-->
<div ng-if="recorder.isAvailable">
<button ng-click="recorder.startRecord()" type="button" ng-disabled="recorder.status.isRecording">
Start Record
</button>
<button ng-click="recorder.stopRecord()" type="button" ng-disabled="recorder.status.isRecording === false">
Stop Record
</button>
</ng-audio-recorder>
</div>
buffer.js:259 Uncaught TypeError: 第一个参数必须是字符串、缓冲区、数组缓冲区、数组或类似数组对象。
. - angularchoboconsole.log(this.result)
显示什么? - mscdexnew Uint8Array(this.result)
代替this.result
来使其正常工作。 - mscdex