小编ang*_*obo的帖子

如何在Javascript/Node中从blob编写.wav文件

我正在尝试使用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)
 };
}
Run Code Online (Sandbox Code Playgroud)

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> …
Run Code Online (Sandbox Code Playgroud)

javascript audio base64 node.js node-webkit

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

audio ×1

base64 ×1

javascript ×1

node-webkit ×1

node.js ×1